Ejemplo n.º 1
0
 /**
  * @return    void
  */
 public function testAbsolute()
 {
     // require to that phpunit is executed in vendor/naucon directory
     $fileObject = new File('File/tests/example.txt');
     $this->assertFalse($fileObject->isAbsolute());
     $this->assertEquals(strtolower(__DIR__) . '/example.txt', strtolower($fileObject->getAbsolutePath()));
     $fileObject = new File(__DIR__ . '/example.txt');
     $this->assertTrue($fileObject->isAbsolute());
     $this->assertEquals(strtolower(__DIR__) . '/example.txt', strtolower($fileObject->getAbsolutePath()));
     $fileObject = new File('File/../File/tests/example.txt');
     $this->assertFalse($fileObject->isAbsolute());
     $this->assertEquals(strtolower(__DIR__) . '/example.txt', strtolower($fileObject->getAbsolutePath()));
     $fileObject = new File('File/../File/tests/');
     $this->assertFalse($fileObject->isAbsolute());
     $this->assertEquals(strtolower(__DIR__), strtolower($fileObject->getAbsolutePath()));
     $fileObject = new \SplFileInfo('File/tests/example.txt');
     $this->assertEquals(strtolower(__DIR__) . '/example.txt', strtolower($fileObject->getRealPath()));
     $fileObject = new \SplFileInfo(__DIR__ . '/example.txt');
     $this->assertEquals(strtolower(__DIR__) . '/example.txt', strtolower($fileObject->getRealPath()));
     $fileObject = new \SplFileInfo('File/../File/tests/example.txt');
     $this->assertEquals(strtolower(__DIR__) . '/example.txt', strtolower($fileObject->getRealPath()));
     $fileObject = new \SplFileInfo('File/../File/tests/');
     $this->assertEquals(strtolower(__DIR__), strtolower($fileObject->getRealPath()));
 }