예제 #1
0
파일: Psr0Test.php 프로젝트: flairphp/flair
 /**
  * Checks if removePrefix works as expected.
  * @author Daniel Sherman
  * @test
  * @depends testAddPrefix
  * @depends testGetPrefixes
  * @covers ::removePrefix
  */
 public function testRemovePrefix()
 {
     $prefix = 'Flair\\Autoloader';
     $pathPrefix = '/www/libs/';
     $result = self::$loader->addPrefix($prefix, $pathPrefix);
     $this->assertTrue($result, 'a valid prefix could not be added!');
     $prefixes = [$prefix => $pathPrefix];
     $storedPrefixes = self::$loader->getPrefixes();
     $msg = 'the prefix did not get saved properly!';
     $this->assertEquals($prefixes, $storedPrefixes, $msg);
     $result = self::$loader->removePrefix($prefix);
     $this->assertTrue($result, 'the prefix did not get removed');
     $prefixes = self::$loader->getPrefixes();
     $this->assertEquals([], $prefixes, 'the prefix did not get removed properly!');
 }
예제 #2
0
파일: Psr4Test.php 프로젝트: flairphp/flair
 /**
  * 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');
 }