private function doTestGetFileStat($path, $content, $alreadyExists) { $backendName = $this->backendClass(); if ($alreadyExists) { $this->prepare(array('dir' => dirname($path))); $status = $this->create(array('dst' => $path, 'content' => $content)); $this->assertGoodStatus($status, "Creation of file at {$path} succeeded ({$backendName})."); $size = $this->backend->getFileSize(array('src' => $path)); $time = $this->backend->getFileTimestamp(array('src' => $path)); $stat = $this->backend->getFileStat(array('src' => $path)); $this->assertEquals(strlen($content), $size, "Correct file size of '{$path}'"); $this->assertTrue(abs(time() - wfTimestamp(TS_UNIX, $time)) < 10, "Correct file timestamp of '{$path}'"); $size = $stat['size']; $time = $stat['mtime']; $this->assertEquals(strlen($content), $size, "Correct file size of '{$path}'"); $this->assertTrue(abs(time() - wfTimestamp(TS_UNIX, $time)) < 10, "Correct file timestamp of '{$path}'"); $this->backend->clearCache(array($path)); $size = $this->backend->getFileSize(array('src' => $path)); $this->assertEquals(strlen($content), $size, "Correct file size of '{$path}'"); $this->backend->preloadCache(array($path)); $size = $this->backend->getFileSize(array('src' => $path)); $this->assertEquals(strlen($content), $size, "Correct file size of '{$path}'"); } else { $size = $this->backend->getFileSize(array('src' => $path)); $time = $this->backend->getFileTimestamp(array('src' => $path)); $stat = $this->backend->getFileStat(array('src' => $path)); $this->assertFalse($size, "Correct file size of '{$path}'"); $this->assertFalse($time, "Correct file timestamp of '{$path}'"); $this->assertFalse($stat, "Correct file stat of '{$path}'"); } }
/** * Get the timestamp of a file with a given virtual URL/storage path * * @param $virtualUrl string * @return string|false */ public function getFileTimestamp($virtualUrl) { $path = $this->resolveToStoragePath($virtualUrl); return $this->backend->getFileTimestamp(array('src' => $path)); }