helpers = new Helpers(); $this->helpers->setDirectories([3 => ['test' . DS . 'helpers']]); } /** * @coversNothing */ public function testGetHelpersClass() { $this->assertInstanceOf('FuzeWorks\Helpers', $this->helpers); } /** * @covers ::load */ public function testLoadHelper() { // First test if the function/helper is not loaded yet $this->assertFalse(function_exists('testHelperFunction')); // Test if the helper is properly loaded $this->assertTrue($this->helpers->load('TestLoadHelper')); // Test if the function exists now $this->assertTrue(function_exists('testHelperFunction')); } /** * @depends testLoadHelper * @covers ::load */ public function testLoadHelperWithoutSubdirectory() { // First test if the function/helper is not loaded yet $this->assertFalse(function_exists('testLoadHelperWithoutSubdirectory')); // Try and load the helper $this->assertTrue($this->helpers->load('TestLoadHelperWithoutSubdirectory')); // Then test if the function/helper is loaded $this->assertTrue(function_exists('testLoadHelperWithoutSubdirectory')); } /** * @depends testLoadHelper * @covers ::load */ public function testLoadHelperWithAltDirectory() { $this->assertFalse(function_exists('testLoadHelperWithAltDirectory')); $this->assertTrue($this->helpers->load( 'TestLoadHelperWithAltDirectory', ['test' . DS . 'helpers' . DS . 'TestLoadHelperWithAltDirectory' . DS . 'SubDirectory'] )); $this->assertTrue(function_exists('testLoadHelperWithAltDirectory')); } /** * @depends testLoadHelper * @covers ::load */ public function testReloadHelper() { // First test if the function/helper is not loaded yet $this->assertFalse(function_exists('testReloadHelper')); // Try and load the helper $this->assertTrue($this->helpers->load('TestReloadHelper')); // Then test if the function/helper is loaded $this->assertTrue(function_exists('testReloadHelper')); // Try and reload the helper $this->assertFalse($this->helpers->load('TestReloadHelper')); // Test that the function still exists $this->assertTrue(function_exists('testReloadHelper')); } /** * @depends testLoadHelper * @covers ::load */ public function testCancelLoadHelper() { // First test if the function/helper is not loaded yet $this->assertFalse(function_exists('testCancelLoadHelper')); // Prepare listener Events::addListener(function($event) { $event->setCancelled(true); }, 'helperLoadEvent', Priority::NORMAL); $this->assertFalse($this->helpers->load('TestCancelLoadHelper')); } /** * @depends testLoadHelper * @covers ::get */ public function testGetHelper() { // First test if the function/helper is not loaded yet $this->assertFalse(function_exists('testGetHelper')); // Test if the helper is properly loaded $this->assertTrue($this->helpers->get('TestGetHelper')); // Test if the function exists now $this->assertTrue(function_exists('testGetHelper')); } }