mageekguy\atoum\fs\path::getRealParentDirectoryPath PHP Method

getRealParentDirectoryPath() public method

    public function getRealParentDirectoryPath()
    {
        $realParentDirectoryPath = $this->getParentDirectoryPath();
        while ($realParentDirectoryPath->exists() === false && $realParentDirectoryPath->isRoot() === false) {
            $realParentDirectoryPath = $realParentDirectoryPath->getParentDirectoryPath();
        }
        if ($realParentDirectoryPath->exists() === false) {
            throw new exception('Unable to find real parent directory for \'' . $this . '\'');
        }
        return $realParentDirectoryPath;
    }

Usage Example

Example #1
0
 public function testGetRealParentDirectoryPath()
 {
     $this->given($adapter = new atoum\test\adapter())->and($adapter->file_exists = function ($path) {
         switch ($path) {
             case '/a/b/c/d/e':
             case '/a/b/c/d':
             case '/a/b/c':
                 return false;
             default:
                 return true;
         }
     })->then->if($path = new testedClass('/', '/', $adapter))->then->object($path->getRealParentDirectoryPath())->isNotIdenticalTo($path)->toString->isEqualTo('/')->if($path = new testedClass('/a', '/', $adapter))->then->object($path->getRealParentDirectoryPath())->isNotIdenticalTo($path)->toString->isEqualTo('/')->if($path = new testedClass('/a/', '/', $adapter))->then->object($path->getRealParentDirectoryPath())->isNotIdenticalTo($path)->toString->isEqualTo('/')->if($path = new testedClass('/a/b', '/', $adapter))->then->object($path->getRealParentDirectoryPath())->isNotIdenticalTo($path)->toString->isEqualTo('/a')->if($path = new testedClass('/a/b/', '/', $adapter))->then->object($path->getRealParentDirectoryPath())->isNotIdenticalTo($path)->toString->isEqualTo('/a')->if($path = new testedClass('/a/b/c', '/', $adapter))->then->object($path->getRealParentDirectoryPath())->isNotIdenticalTo($path)->toString->isEqualTo('/a/b')->if($path = new testedClass('/a/b/c/d', '/', $adapter))->then->object($path->getRealParentDirectoryPath())->isNotIdenticalTo($path)->toString->isEqualTo('/a/b');
 }