helpers = $factory->helpers; } public function testGetHelpersClass() { $this->assertInstanceOf('FuzeWorks\Helpers', $this->helpers); } 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('test', 'tests'.DS.'helpers'.DS.'testLoadHelper'.DS)); // Test if the function exists now $this->assertTrue(function_exists('testHelperFunction')); } /** * @expectedException FuzeWorks\Exception\HelperException */ public function testAddHelperPathFail() { // First test if the function is not loaded yet $this->assertFalse(function_exists('testAddHelperPathFunction')); // Now test if the helper can be loaded (hint: it can not) $this->helpers->load('testAddHelperPath'); } /** * @depends testAddHelperPathFail */ public function testAddHelperPath() { // Add the helperPath $this->helpers->addHelperPath('tests'.DS.'helpers'.DS.'testAddHelperPath'); // And try to load it again $this->assertTrue($this->helpers->load('testAddHelperPath')); // And test if the function is loaded $this->assertTrue(function_exists('testAddHelperPathFunction')); } public function testRemoveHelperPath() { // Test if the path does NOT exist $this->assertFalse(in_array('tests'.DS.'helpers'.DS.'testRemoveHelperPath', $this->helpers->getHelperPaths())); // Add it $this->helpers->addHelperPath('tests'.DS.'helpers'.DS.'testRemoveHelperPath'); // Assert if it's there $this->assertTrue(in_array('tests'.DS.'helpers'.DS.'testRemoveHelperPath', $this->helpers->getHelperPaths())); // Remove it $this->helpers->removeHelperPath('tests'.DS.'helpers'.DS.'testRemoveHelperPath'); // And test if it's gone again $this->assertFalse(in_array('tests'.DS.'helpers'.DS.'testRemoveHelperPath', $this->helpers->getHelperPaths())); } public function testSetDirectories() { // Add the directory $directory = 'tests' . DS . 'helpers'; $this->helpers->setDirectories([$directory]); $this->assertEquals([$directory], $this->helpers->getHelperPaths()); } }