echo '<br/>'; echo 'File is' . ($fileObject->isReadable() ? '' : ' not') . ' readable.'; echo '<br/>'; echo 'File is' . ($fileObject->isWritable() ? '' : ' not') . ' writeable.'; echo '<br/>'; echo '<br/>'; echo 'Filesize: ' . $fileObject->getSize() . ' bytes'; echo '<br/>'; echo 'Access Time: ' . $fileObject->lastAccessed()->format('d.m.Y H:s'); echo '<br/>'; echo 'Change Time: ' . $fileObject->lastChanged()->format('d.m.Y H:s'); echo '<br/>'; echo 'Modification Time: ' . $fileObject->lastModified()->format('d.m.Y H:s'); echo '<br/>'; echo '<br/>'; echo 'File Owner: ' . $fileObject->getOwnerName() . ' (' . $fileObject->getOwner() . ')'; echo '<br/>'; echo 'File Group: ' . $fileObject->getGroupName() . ' (' . $fileObject->getGroup() . ')'; echo '<br/>'; echo 'File permission: ' . $fileObject->getPermission(); echo '<br/>'; echo '<br/>'; echo 'Create new directory'; echo '<br/>'; $newDirectoryPath = __DIR__ . '/tmp/target/move/'; $newDirectoryFileObject = new File($newDirectoryPath); if (!$newDirectoryFileObject->isDir()) { $newDirectoryFileObject->mkdirs(); } echo 'Copy file to target directory'; echo '<br/>';
/** * @depends testExist * @return void */ public function testChown() { $filePath = __DIR__ . '/example.txt'; $fileObject = new File($filePath); $this->assertGreaterThanOrEqual(0, $userId = $fileObject->getOwner()); $this->assertGreaterThanOrEqual(0, strlen($user = $fileObject->getOwnerName())); $this->assertTrue($fileObject->chown($userId)); $this->assertTrue($fileObject->chown($user)); $this->assertEquals($userId, $fileObject->getOwner()); $this->assertEquals($user, $fileObject->getOwnerName()); }