<commit_before><?php

namespace ColtTest\Query\Event;

use Colt\Query\Event\InvariableExecutionEventBuilder;

/**
 * Colt Invariable Query Execution Event Builder unit test suite
 * 
 * @category   ColtTest
 * @package    Query
 * @subpackage Event
 * @version    $id$
 * @copyright  2013 <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>> 
 * @license    The MIT License (MIT) {@link http://opensource.org/licenses/MIT}
 */
class InvariableExecutionEventBuilderTest extends \PHPUnit_Framework_TestCase
{
    public $fixture;
    public $mockPublisher;

    public function setUp()
    {
        $this->fixture = new InvariableExecutionEventBuilder();
        $this->mockPublisher = $this->getMock('Colt\Query\InvariableQueryInterface');
    }

    public function testWithTopicImplementsFluentInterface()
    {
        $this->assertSame($this->fixture, $this->fixture->withTopic('foo'));
    }

    public function testWithContentImplementsFluentInterface()
    {
        $this->assertSame($this->fixture, $this->fixture->withContent('bar'));
    }

    public function testWithPublisherImplementsFluentInterface()
    {
        $this->assertSame($this->fixture, $this->fixture->withPublisher($this->mockPublisher));
    }

    public function testWithTopicTypeStrength()
    {
        $this->setExpectedException('Colt\Exception\Type\NonStringException');
        $this->fixture->withTopic(null);
        $this->fixture->withTopic(1234);
        $this->fixture->withTopic(array ());
        $this->fixture->withTopic(new \stdClass());
    }

    public function testBuildThrowsExceptionIfTopicIsEmpty()
    {
        $this->setExpectedException('LogicException');
        $this->fixture->withContent('foo')->withPublisher($this->mockPublisher)->build();
    }

    public function testBuildThrowsExceptionIfContentIsUnset()
    {
        $this->setExpectedException('LogicException');
        $this->fixture->withTopic('foo')->withPublisher($this->mockPublisher)->build();
    }

    public function testBuildThrowsExceptionIfPublisherIsUnset()
    {
        $this->setExpectedException('LogicException');
        $this->fixture->withTopic('foo')->withContent('bar')->build();
    }

    public function testBuildReturnsInstanceOfInvariableExecutionEvent()
    {
        $pub   = $this->mockPublisher;
        $built = $this->fixture->withTopic('foo')->withContent('bar')->withPublisher($pub)->build();
        $this->assertInstanceOf('Colt\Query\Event\InvariableExecutionEvent', $built);
    }

    public function testBuildUsesSetTopic()
    {
        $pub   = $this->mockPublisher;
        $built = $this->fixture->withTopic('foo')->withContent('bar')->withPublisher($pub)->build();
        $this->assertSame('foo', $built->getTopic());
    }

    public function testBuildUsesSetContent()
    {
        $pub   = $this->mockPublisher;
        $built = $this->fixture->withTopic('foo')->withContent('bar')->withPublisher($pub)->build();
        $this->assertSame('bar', $built->getContent());
    }

    public function testBuildUsesSetPublisher()
    {
        $pub   = $this->mockPublisher;
        $built = $this->fixture->withTopic('foo')->withContent('bar')->withPublisher($pub)->build();
        $this->assertSame($pub, $built->getPublisher());
    }
}<commit_msg>Code readability tweak<commit_after><?php

namespace ColtTest\Query\Event;

use Colt\Query\Event\InvariableExecutionEventBuilder;

/**
 * Colt Invariable Query Execution Event Builder unit test suite
 * 
 * @category   ColtTest
 * @package    Query
 * @subpackage Event
 * @version    $id$
 * @copyright  2013 <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>> 
 * @license    The MIT License (MIT) {@link http://opensource.org/licenses/MIT}
 */
class InvariableExecutionEventBuilderTest extends \PHPUnit_Framework_TestCase
{
    public $fixture;
    public $mockPublisher;

    public function setUp()
    {
        $this->fixture = new InvariableExecutionEventBuilder();
        $this->mockPublisher = $this->getMock('Colt\Query\InvariableQueryInterface');
    }

    public function testWithTopicImplementsFluentInterface()
    {
        $this->assertSame($this->fixture, $this->fixture->withTopic('foo'));
    }

    public function testWithContentImplementsFluentInterface()
    {
        $this->assertSame($this->fixture, $this->fixture->withContent('bar'));
    }

    public function testWithPublisherImplementsFluentInterface()
    {
        $this->assertSame($this->fixture, $this->fixture->withPublisher($this->mockPublisher));
    }

    public function testWithTopicTypeStrength()
    {
        $this->setExpectedException('Colt\Exception\Type\NonStringException');
        $this->fixture->withTopic(null);
        $this->fixture->withTopic(1234);
        $this->fixture->withTopic(array ());
        $this->fixture->withTopic(new \stdClass());
    }

    public function testBuildThrowsExceptionIfTopicIsEmpty()
    {
        $this->setExpectedException('LogicException');
        $this->fixture
            ->withContent('foo')
            ->withPublisher($this->mockPublisher)
            ->build();
    }

    public function testBuildThrowsExceptionIfContentIsUnset()
    {
        $this->setExpectedException('LogicException');
        $this->fixture
            ->withTopic('foo')
            ->withPublisher($this->mockPublisher)
            ->build();
    }

    public function testBuildThrowsExceptionIfPublisherIsUnset()
    {
        $this->setExpectedException('LogicException');
        $this->fixture
            ->withTopic('foo')
            ->withContent('bar')
            ->build();
    }

    public function testBuildReturnsInstanceOfInvariableExecutionEvent()
    {
        $built = $this->fixture
            ->withTopic('foo')
            ->withContent('bar')
            ->withPublisher($this->mockPublisher)
            ->build();
        $this->assertInstanceOf('Colt\Query\Event\InvariableExecutionEvent', $built);
    }

    public function testBuildUsesSetTopic()
    {
        $built = $this->fixture
            ->withTopic('foo')
            ->withContent('bar')
            ->withPublisher($this->mockPublisher)
            ->build();
        $this->assertSame('foo', $built->getTopic());
    }

    public function testBuildUsesSetContent()
    {
        $built = $this->fixture
            ->withTopic('foo')
            ->withContent('bar')
            ->withPublisher($this->mockPublisher)
            ->build();
        $this->assertSame('bar', $built->getContent());
    }

    public function testBuildUsesSetPublisher()
    {
        $built = $this->fixture
            ->withTopic('foo')
            ->withContent('bar')
            ->withPublisher($this->mockPublisher)
            ->build();
        $this->assertSame($this->mockPublisher, $built->getPublisher());
    }
}
{'fraction_non_alphanumeric': 0.14848573948838578, 'fraction_numerical': 0.0023522493384298734, 'mean_word_length': 3.0760934691431996, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 162, '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': '375298', 'n_tokens_mistral': 1994, 'n_tokens_neox': 1869, 'n_words': 273}