Example #1
0
 /**
  * Checks if load works as expected using the default path prefix
  * @author Daniel Sherman
  * @test
  * @depends testConstruct
  * @depends testAddPrefix
  * @covers ::load
  */
 public function testLoadPassedPathPrefix()
 {
     $prefix = 'Simple';
     $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR;
     //configure the object
     $result = self::$loader->addPrefix($prefix, $path);
     $this->assertTrue($result, 'adding a prefix failed');
     // the actual assertions/tests
     $result = self::$loader->load('SimpleClassThree');
     $this->assertTrue($result, 'the class file did not get load');
     $result = class_exists('SimpleClassThree', false);
     $this->assertTrue($result, 'the class is not in scope');
     $result = self::$loader->load('SimpleNonexistentClassThree');
     $this->assertFalse($result, 'the class/file does not exist');
     $result = self::$loader->load('ComplexClassThree');
     $this->assertFalse($result, 'The prefix was not configured');
 }
Example #2
0
 /**
  * Checks if load works as expected
  * @author Daniel Sherman
  * @test
  * @depends testConstruct
  * @depends testAddPrefix
  * @depends testRemovePrefix
  * @covers ::load
  */
 public function testLoad()
 {
     $prefix = 'Vendor\\Simple';
     $baseDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fixtures';
     $baseDir .= DIRECTORY_SEPARATOR . 'Psr4' . DIRECTORY_SEPARATOR;
     $baseDir .= 'Vendor' . DIRECTORY_SEPARATOR . 'Simple' . DIRECTORY_SEPARATOR;
     //configure the object
     $result = self::$loader->addPrefix($prefix, $baseDir);
     $this->assertTrue($result, 'adding a prefix failed');
     // the actual assertions/tests
     $result = self::$loader->load('Vendor\\Simple\\ClassTwo');
     $this->assertTrue($result, 'the class file did not get load');
     $result = class_exists('Vendor\\Simple\\ClassTwo', false);
     $this->assertTrue($result, 'the class is not in scope');
     $result = self::$loader->load('Vendor\\Simple\\NonexistentClassTwo');
     $this->assertFalse($result, 'the class/file does not exist');
     $result = self::$loader->load('Vendor\\Complex\\ClassTwo');
     $this->assertFalse($result, 'The prefix was not configured');
     // reconfigure the object
     $result = self::$loader->removePrefix($prefix);
     $this->assertTrue($result, 'removing a prefix failed');
 }