<commit_before><?php
namespace Jimphle\Test\Messaging;

use Jimphle\Messaging\GenericMessage;
use Jimphle\Messaging\Message;
use Jimphle\Messaging\MessageHandlerMetadataProvider;

class MessageHandlerMetadataProviderTest extends \PHPUnit_Framework_TestCase
{
    const SOME_ANNOTATION = 'Jimphle\Test\Messaging\SomeAnnotation';
    const SOME_MESSAGE_NAME = 'a_message';
    const ANOTHER_ANNOTATION = 'Jimphle\Test\Messaging\AnotherAnnotation';
    const UNKNOWN_ANNOTATION = 'Jimphle\Test\Messaging\UnknownAnnotation';

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    private $messageHandlerFake;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    private $reader;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    private $messageHandlerProvider;

    public function setUp()
    {
        $this->reader = $this->getMock('\Doctrine\Common\Annotations\Reader');
        $this->messageHandlerFake = new MessageHandlerFake();
        $this->messageHandlerProvider = $this->messageHandlerProviderMock();
        $this->messageHandlerProvider->expects($this->any())
            ->method('getMessageHandlers')
            ->will($this->returnValue(array($this->messageHandlerFake)));
    }

    /**
     * @test
     */
    public function itShouldGetTheMessageHandlers()
    {
        $this->messageHandlerProvider = $this->messageHandlerProviderMock();
        $this->messageHandlerProvider->expects($this->once())
            ->method('getMessageHandlers')
            ->with(
                $this->callback(
                    function (Message $message) {
                        return $message->equals($this->someMessage());
                    }
                )
            )
            ->will($this->returnValue(array($this->messageHandlerFake)));
        $this->reader->expects($this->any())
            ->method('getClassAnnotations')
            ->with($this->equalTo(new \ReflectionClass($this->messageHandlerFake)))
            ->will($this->returnValue(array()));
        $this->readAnnotations();
    }

    /**<commit_msg>fix tests for php 5.3<commit_after><?php
namespace Jimphle\Test\Messaging;

use Jimphle\Messaging\GenericMessage;
use Jimphle\Messaging\Message;
use Jimphle\Messaging\MessageHandlerMetadataProvider;

class MessageHandlerMetadataProviderTest extends \PHPUnit_Framework_TestCase
{
    const SOME_ANNOTATION = 'Jimphle\Test\Messaging\SomeAnnotation';
    const SOME_MESSAGE_NAME = 'a_message';
    const ANOTHER_ANNOTATION = 'Jimphle\Test\Messaging\AnotherAnnotation';
    const UNKNOWN_ANNOTATION = 'Jimphle\Test\Messaging\UnknownAnnotation';

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    private $messageHandlerFake;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    private $reader;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    private $messageHandlerProvider;

    public function setUp()
    {
        $this->reader = $this->getMock('\Doctrine\Common\Annotations\Reader');
        $this->messageHandlerFake = new MessageHandlerFake();
        $this->messageHandlerProvider = $this->messageHandlerProviderMock();
        $this->messageHandlerProvider->expects($this->any())
            ->method('getMessageHandlers')
            ->will($this->returnValue(array($this->messageHandlerFake)));
    }

    /**
     * @test
     */
    public function itShouldGetTheMessageHandlers()
    {
        $this->messageHandlerProvider = $this->messageHandlerProviderMock();
        $this->messageHandlerProvider->expects($this->once())
            ->method('getMessageHandlers')
            ->with(
                $this->callback(
                    function (Message $message) {
                        return $message->equals(GenericMessage::generate(self::SOME_MESSAGE_NAME));
                    }
                )
            )
            ->will($this->returnValue(array($this->messageHandlerFake)));
        $this->reader->expects($this->any())
            ->method('getClassAnnotations')
            ->with($this->equalTo(new \ReflectionClass($this->messageHandlerFake)))
            ->will($this->returnValue(array()));
        $this->readAnnotations();
    }

    /**
{'fraction_non_alphanumeric': 0.13042458362655407, 'fraction_numerical': 0.0004691531785127844, 'mean_word_length': 2.796972395369546, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 72, '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': '4045034', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1137, 'n_words': 148}