<commit_before><?php
/**
 * Copyright 2017 The WildPHP Team
 *
 * You should have received a copy of the MIT license with the project.
 * See the LICENSE file for more information.
 */

use WildPHP\Core\EventEmitter;

class EventEmitterTest extends \PHPUnit\Framework\TestCase
{
	public function testFirst()
	{
		$eventEmitter = new EventEmitter();

		$eventEmitter->on('test', [$this, 'ing']);
		$eventEmitter->on('test', [$this, 'foo']);
		$eventEmitter->first('test', [$this, 'bar']);

		$listeners = $eventEmitter->listeners('test');
		self::assertEquals([[$this, 'bar'], [$this, 'ing'], [$this, 'foo']], $listeners);
		self::assertEquals([$this, 'bar'], array_shift($listeners));
	}
<commit_msg>Test with empty listener list to be sure.<commit_after><?php
/**
 * Copyright 2017 The WildPHP Team
 *
 * You should have received a copy of the MIT license with the project.
 * See the LICENSE file for more information.
 */

use WildPHP\Core\EventEmitter;

class EventEmitterTest extends \PHPUnit\Framework\TestCase
{
	public function testFirst()
	{
		$eventEmitter = new EventEmitter();

		$eventEmitter->on('test', [$this, 'ing']);
		$eventEmitter->on('test', [$this, 'foo']);
		$eventEmitter->first('test', [$this, 'bar']);

		$listeners = $eventEmitter->listeners('test');
		self::assertEquals([[$this, 'bar'], [$this, 'ing'], [$this, 'foo']], $listeners);
		self::assertEquals([$this, 'bar'], array_shift($listeners));

		$eventEmitter->on('ing', [$this, 'foo']);
		$listeners = $eventEmitter->listeners('ing');
		self::assertEquals([[$this, 'foo']], $listeners);
		self::assertEquals([$this, 'foo'], array_shift($listeners));
	}

{'fraction_non_alphanumeric': 0.19437652811735942, 'fraction_numerical': 0.004889975550122249, 'mean_word_length': 5.548, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '4862508', 'n_tokens_mistral': 539, 'n_tokens_neox': 516, 'n_words': 136}