<commit_before><?php
/**
 * test Event Dispatcher class
 *
 * @package     ClassEvent
 * @subpackage  Test
 * @author      <NAME>    <<EMAIL>>
 * @copyright   chajr/bluetree
 */
namespace Test;

use ClassEvent\Event\EventDispatcher;
use ClassEvent\Event\Base\Interfaces\EventManagerInterface;
use ClassEvent\Event\Base\EventManager;

class EventDispatcherTest extends \PHPUnit_Framework_TestCase
{
    /**
     * test event initialize
     */
    public function testEventInstanceCreation()
    {
        EventDispatcher::init('');

        $this->assertNotNull(EventDispatcher::getInstance());
        $this->assertTrue(EventDispatcher::getInstance() instanceof EventManagerInterface);
    }

    /**
     * test read configuration
     *
     * @todo check other data types
     */
    public function testSetEventManagerConfiguration()
    {
        $eventManager = new EventManager;
        $eventManager->setEventConfiguration($this->getEventConfig());

        $this->assertEquals($this->getEventConfig(), $eventManager->getEventConfiguration());
    }

    /**
     * config data for test
     *
     * @return array
     */
    public function getEventConfig()
    {
        return [
            'test_event_code' => [
                'object'    => 'ClassEvent\Event\BaseEvent',
                'listeners' => [
                    'ClassOne::method',
                    'ClassSecond::method',
                    'someFunction',
                ]
            ]
        ];
    }
}<commit_msg>Create tests for TDD (issue #1)<commit_after><?php
/**
 * test Event Dispatcher class
 *
 * @package     ClassEvent
 * @subpackage  Test
 * @author      <NAME>    <<EMAIL>>
 * @copyright   chajr/bluetree
 */
namespace Test;

use ClassEvent\Event\EventDispatcher;
use ClassEvent\Event\Base\EventManager;

class EventDispatcherTest extends \PHPUnit_Framework_TestCase
{
    /**
     * store information that even was triggered
     *
     * @var bool
     */
    public static $eventTriggered = false;

    /**
     * test event initialize
     */
    public function testEventInstanceCreation()
    {
        EventDispatcher::init();
        $this->assertNotFalse(EventDispatcher::isInitialized());

        EventDispatcher::init('', null, 'new_instance');
        $this->assertNotFalse(EventDispatcher::isInitialized('new_instance'));
    }

    /**
     * test read configuration
     *
     * @todo check other data types
     */
    public function testSetEventManagerConfiguration()
    {
        $eventManager = new EventManager;
        $eventManager->setEventConfiguration($this->getEventConfig());

        $this->assertEquals($this->getEventConfig(), $eventManager->getEventConfiguration());
    }

    /**
     * test that event is called correctly
     */
    public function testTriggerEvent()
    {
        EventDispatcher::init();
        EventDispatcher::setEventConfiguration([
            'test_event' => [
                'object'    => 'ClassEvent\Event\BaseEvent',
                'listeners' => [
                    'Test\EventDispatcherTest::trigger',
                ]
            ]
        ], 'array');
        EventDispatcher::triggerEvent('test_event');

        $this->assertTrue(self::$eventTriggered);
    }

    /**
     * config data for test
     *
     * @return array
     */
    public function getEventConfig()
    {
        return [
            'test_event_code' => [
                'object'    => 'ClassEvent\Event\BaseEvent',
                'listeners' => [
                    'ClassOne::method',
                    'ClassSecond::method',
                    'someFunction',
                ]
            ]
        ];
    }

    /**
     * method to test event triggering
     */
    public static function trigger()
    {
        self::$eventTriggered = true;
    }
}
{'fraction_non_alphanumeric': 0.11851074986890404, 'fraction_numerical': 0.00026219192448872575, 'mean_word_length': 2.084074373484236, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 33, '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': '4018816', 'n_tokens_mistral': 1020, 'n_tokens_neox': 979, 'n_words': 188}