given($pathname = 'hoa://Test/Vfs/Foo.bar?type=file') ->when($result = new LUT\SplFileInfo($pathname)) ->then ->boolean($result->isFile()) ->isTrue() ->string($result->getType()) ->isEqualTo('file'); } public function case_directory() { $this ->given($pathname = 'hoa://Test/Vfs/Foo?type=directory') ->when($result = new LUT\SplFileInfo($pathname)) ->then ->boolean($result->isDir()) ->isTrue() ->string($result->getType()) ->isEqualTo('dir'); } public function case_path_informations() { $this ->given( $relativePath = 'hoa://Test/Vfs/A/B/', $relativePathname = 'C/Foo.bar', $pathname = $relativePath . $relativePathname ) ->when($result = new LUT\SplFileInfo($pathname . '?type=file', $relativePath)) ->then ->boolean($result->isFile()) ->isTrue() ->string($result->getBasename()) ->isEqualTo('Foo.bar?type=file') ->string($result->getExtension()) ->isEqualTo('bar?type=file') ->string($result->getRelativePath()) ->isEqualTo($relativePath) ->string($result->getRelativePathname()) ->isEqualTo($relativePathname . '?type=file') ->string($result->getPath()) ->isEqualTo('hoa://Test/Vfs/A/B/C') ->string($result->getPathname()) ->isEqualTo($pathname . '?type=file'); } public function case_times() { $this ->given( $timestamp = $this->realdom->boundinteger( $this->realdom->timestamp('yesterday'), $this->realdom->timestamp('tomorrow') ), $atime = $this->sample($timestamp), $ctime = $this->sample($timestamp), $mtime = $this->sample($timestamp), $pathname = 'hoa://Test/Vfs/Foo.bar?' . http_build_query([ 'type' => 'file', 'atime' => $atime, 'ctime' => $ctime, 'mtime' => $mtime ]) ) ->when($result = new LUT\SplFileInfo($pathname)) ->then ->integer($result->getATime()) ->isEqualTo($atime) ->integer($result->getCTime()) ->isEqualTo($ctime) ->integer($result->getMTime()) ->isEqualTo($mtime); } public function case_permissions() { $this ->given($pathname = 'hoa://Test/Vfs/Fo.bar?type=file&permissions=0744') ->when($result = new LUT\SplFileInfo($pathname)) ->then ->boolean($result->isReadable()) ->isTrue() ->boolean($result->isWritable()) ->isTrue() ->boolean($result->isExecutable()) ->isTrue() ->given($pathname = 'hoa://Test/Vfs/Foo.bar?type=file&permissions=0644') ->when($result = new LUT\SplFileInfo($pathname)) ->then ->boolean($result->isReadable()) ->isTrue() ->boolean($result->isWritable()) ->isTrue() ->boolean($result->isExecutable()) ->isFalse() ->given($pathname = 'hoa://Test/Vfs/Fooo.bar?type=file&permissions=0444') ->when($result = new LUT\SplFileInfo($pathname)) ->then ->boolean($result->isReadable()) ->isTrue() ->boolean($result->isWritable()) ->isFalse() ->boolean($result->isExecutable()) ->isFalse() ->given($pathname = 'hoa://Test/Vfs/Foooo.bar?type=file&permissions=0044') ->when($result = new LUT\SplFileInfo($pathname)) ->then ->boolean($result->isReadable()) ->isFalse() ->boolean($result->isWritable()) ->isFalse() ->boolean($result->isExecutable()) ->isFalse(); } }