<commit_before><?php
namespace CodeIgniter\Events;

use CodeIgniter\Config\Config;
use CodeIgniter\Test\Mock\MockEvents;

class EventsTest extends \CodeIgniter\Test\CIUnitTestCase
{

	/**
	 * Accessible event manager instance
	 */
	protected $manager;

	protected function setUp(): void
	{
		parent::setUp();

		$this->manager = new MockEvents();

		Events::removeAllListeners();
	}

	//--------------------------------------------------------------------

	/**
	 * @runInSeparateProcess
	 * @preserveGlobalState  disabled
	 */
	public function testInitialize()
	{
		$config                  = config('Modules');
		$config->activeExplorers = [];
		Config::injectMock('Modules', $config);

		// it should start out empty
		$default = [APPPATH . 'Config/Events.php'];
		$this->manager->setFiles([]);
		$this->assertEmpty($this->manager->getFiles());

		// make sure we have a default events file
		$this->manager->unInitialize();
		$this->manager::initialize();
		$this->assertEquals($default, $this->manager->getFiles());

		// but we should be able to change it through the backdoor<commit_msg>Reinstate Events after test<commit_after><?php
namespace CodeIgniter\Events;

use CodeIgniter\Config\Config;
use CodeIgniter\Test\Mock\MockEvents;

class EventsTest extends \CodeIgniter\Test\CIUnitTestCase
{

	/**
	 * Accessible event manager instance
	 */
	protected $manager;

	protected function setUp(): void
	{
		parent::setUp();

		$this->manager = new MockEvents();

		Events::removeAllListeners();
	}

	protected function tearDown(): void
	{
		Events::simulate(false);
	}

	//--------------------------------------------------------------------

	/**
	 * @runInSeparateProcess
	 * @preserveGlobalState  disabled
	 */
	public function testInitialize()
	{
		$config                  = config('Modules');
		$config->activeExplorers = [];
		Config::injectMock('Modules', $config);

		// it should start out empty
		$default = [APPPATH . 'Config/Events.php'];
		$this->manager->setFiles([]);
		$this->assertEmpty($this->manager->getFiles());

		// make sure we have a default events file
		$this->manager->unInitialize();
		$this->manager::initialize();
		$this->assertEquals($default, $this->manager->getFiles());

		// but we should be able to change it through the backdoor
{'fraction_non_alphanumeric': 0.20061592608886933, 'fraction_numerical': 0.0, 'mean_word_length': 3.039076376554174, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '5431156', 'n_tokens_mistral': 693, 'n_tokens_neox': 634, 'n_words': 147}