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

createParentDirectory() public method

    public function createParentDirectory()
    {
        $parentDirectory = $this->getParentDirectoryPath();
        if (file_exists((string) $parentDirectory) === false && @mkdir($parentDirectory, 0777, true) === false) {
            throw new exception('Unable to create directory \'' . $parentDirectory . '\'');
        }
        return $this;
    }

Usage Example

Example #1
0
 public function testCreateParentDirectory()
 {
     $this->if($path = new testedClass('/a/b', '/'))->and($adapter = new atoum\test\adapter())->and($adapter->file_exists = false)->and($adapter->mkdir = true)->and($path->setAdapter($adapter))->then->object($path->createParentDirectory())->isEqualTo($path)->adapter($adapter)->call('mkdir')->withArguments('/a', 0777, true)->once()->if($adapter->mkdir = false)->then->exception(function () use($path) {
         $path->createParentDirectory();
     })->isInstanceOf('mageekguy\\atoum\\fs\\path\\exception')->hasMessage('Unable to create directory \'/a\'')->if($adapter->file_exists = true)->and($this->resetAdapter($adapter))->then->object($path->createParentDirectory())->isEqualTo($path)->adapter($adapter)->call('mkdir')->never();
 }