<commit_before><commit_msg>test: Add BaseHandlerTest<commit_after><?php

use Casperlaitw\LaravelFbMessenger\Contracts\BaseHandler;
use Casperlaitw\LaravelFbMessenger\Contracts\Bot;
use Casperlaitw\LaravelFbMessenger\Messages\Deletable;
use Casperlaitw\LaravelFbMessenger\Messages\Message;
use Mockery as m;

/**
 * User: casperlai
 * Date: 2016/9/4
 * Time: 下午11:25
 */
class BaseHandlerTest extends TestCase
{
    protected function tearDown()
    {
        m::close();
    }

    public function test_get_messages()
    {
        $expected = [
            'test',
            'test2'
        ];
        $handler = $this->getMockForAbstractClass(BaseHandler::class);
        $handler->setMessages($expected);

        $this->assertEquals($expected, $handler->getMessages());
    }

    public function test_send()
    {
        $bot = m::mock(Bot::class)
            ->shouldReceive('send')
            ->withAnyArgs()
            ->andReturnNull()
            ->getMock();
        $handler = $this->getMockForAbstractClass(BaseHandler::class);
        $this->getPrivateProperty(BaseHandler::class, 'bot')->setValue($handler, $bot);

        $message = new MessageStub(null);
        $message->setDelete(true);
        $handler->send($message);
    }
}

class MessageStub extends Message
{
    use Deletable;

    /**
     * Message to send object
     * @return \pimax\Messages\Message|array
     */
    public function toData()
    {
        // TODO: Implement toData() method.
    }
}
{'fraction_non_alphanumeric': 0.13239247311827956, 'fraction_numerical': 0.00739247311827957, 'mean_word_length': 2.694789081885856, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6327073', 'n_tokens_mistral': 472, 'n_tokens_neox': 452, 'n_words': 78}