예제 #1
0
 public function getFreshURL($name, $definedName)
 {
     $title = Title::newFromText($definedName, NS_FILE);
     if ($definedName != $name) {
         $file = OldLocalFile::newFromArchiveName($title, RepoGroup::singleton()->getLocalRepo(), $name);
         return wfReplaceImageServer($file->getUrl());
     } else {
         $file = new LocalFile($title, RepoGroup::singleton()->getLocalRepo());
         return wfReplaceImageServer($file->getUrl());
     }
 }
예제 #2
0
 private function checkImage(LocalFile $image, $fileHash)
 {
     $hash = md5($image->getName());
     $url = $image->getUrl();
     $this->assertStringEndsWith(sprintf('/%s/images/%s/%s/%s', $this->app->wg->DBname, $hash[0], $hash[0] . $hash[1], urlencode($image->getName())), $url, 'Path should contain a valid hash');
     // verify that it's accessible via HTTP
     $req = MWHttpRequest::factory($url, ['noProxy' => true]);
     $req->execute();
     $this->assertEquals(200, $req->getStatus(), 'Uploaded image should return HTTP 200 - ' . $url);
     $this->assertEquals($fileHash, md5($req->getContent()), 'Uploaded image hash should match - ' . $url);
     $this->assertEquals('image/jpeg', $req->getResponseHeader('Content-Type'), 'Uploaded image should be JPEG');
 }