Created
February 14, 2013 14:50
-
-
Save mageekguy/4953283 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace tests\units; | |
| require __DIR__ . '/../runner.php'; | |
| use | |
| atoum, | |
| path as testedClass | |
| ; | |
| class path extends atoum | |
| { | |
| public function test__construct() | |
| { | |
| $this | |
| ->if($path = new testedClass($aPath = '/')) | |
| ->then | |
| ->castToString($path)->isEqualTo($aPath) | |
| ->if($path = new testedClass($aPath = '/' . uniqid())) | |
| ->then | |
| ->castToString($path)->isEqualTo($aPath) | |
| ->if($path = new testedClass(($aPath = '/' . uniqid()) . '/')) | |
| ->then | |
| ->castToString($path)->isEqualTo($aPath) | |
| ->if($path = new testedClass($aPath = uniqid())) | |
| ->then | |
| ->castToString($path)->isEqualTo(getcwd() . '/' . $aPath) | |
| ->if($path = new testedClass($aPath = uniqid() . '/' . uniqid())) | |
| ->then | |
| ->castToString($path)->isEqualTo(getcwd() . '/' . $aPath) | |
| ; | |
| } | |
| public function testGetRelativePathFrom() | |
| { | |
| $this | |
| ->if($path = new testedClass('/toto/tutu')) | |
| ->then | |
| ->string($path->getRelativePathFrom(clone $path))->isEqualTo('.') | |
| ->string($path->getRelativePathFrom(new testedClass('/toto')))->isEqualTo('./tutu') | |
| ->string($path->getRelativePathFrom(new testedClass('/toto/')))->isEqualTo('./tutu') | |
| ->string($path->getRelativePathFrom(new testedClass('/tata')))->isEqualTo('../toto/tutu') | |
| ->string($path->getRelativePathFrom(new testedClass('/tata/')))->isEqualTo('../toto/tutu') | |
| ->string($path->getRelativePathFrom(new testedClass('/tata/titi')))->isEqualTo('../../toto/tutu') | |
| ->string($path->getRelativePathFrom(new testedClass('/tata/titi/')))->isEqualTo('../../toto/tutu') | |
| ->string($path->getRelativePathFrom(new testedClass('/')))->isEqualTo('/toto/tutu') | |
| ->if($path = new testedClass('/toto/tutu/titi/webloc2.lan/framework/path.class.php')) | |
| ->then | |
| ->string($path->getRelativePathFrom(new testedClass('/toto/tutu/titi/webloc2.lan/private/cache')))->isEqualTo('../../framework/path.class.php') | |
| ; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment