| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
use MediaWiki\MainConfigNames; |
| 9 |
use MediaWiki\MediaWikiServices; |
| 10 |
use MediaWiki\Permissions\Authority; |
| 11 |
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait; |
| 12 |
use MediaWiki\Title\Title; |
| 13 |
use MediaWiki\User\UserIdentity; |
| 14 |
use MediaWiki\WikiMap\WikiMap; |
| 15 |
use Wikimedia\FileBackend\FSFileBackend; |
| 16 |
use Wikimedia\ObjectCache\HashBagOStuff; |
| 17 |
use Wikimedia\ObjectCache\WANObjectCache; |
| 18 |
use Wikimedia\TestingAccessWrapper; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
class LocalFileTest extends MediaWikiIntegrationTestCase { |
| 24 |
use MockAuthorityTrait; |
| 25 |
|
| 26 |
private static function getDefaultInfo() { |
| 27 |
return [ |
| 28 |
'name' => 'test', |
| 29 |
'directory' => '/testdir', |
| 30 |
'url' => '/testurl', |
| 31 |
'hashLevels' => 2, |
| 32 |
'transformVia404' => false, |
| 33 |
'backend' => new FSFileBackend( [ |
| 34 |
'name' => 'local-backend', |
| 35 |
'wikiId' => WikiMap::getCurrentWikiId(), |
| 36 |
'containerPaths' => [ |
| 37 |
'cont1' => "/testdir/local-backend/tempimages/cont1", |
| 38 |
'cont2' => "/testdir/local-backend/tempimages/cont2" |
| 39 |
] |
| 40 |
] ) |
| 41 |
]; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public function testGetHashPath( $expected, $capitalLinks, array $info ) { |
| 52 |
$this->overrideConfigValue( MainConfigNames::CapitalLinks, $capitalLinks ); |
| 53 |
$this->assertSame( $expected, ( new LocalRepo( $info + self::getDefaultInfo() ) ) |
| 54 |
->newFile( 'test!' )->getHashPath() ); |
| 55 |
} |
| 56 |
|
| 57 |
public static function provideGetHashPath() { |
| 58 |
return [ |
| 59 |
[ '', true, [ 'hashLevels' => 0 ] ], |
| 60 |
[ 'a/a2/', true, [ 'hashLevels' => 2 ] ], |
| 61 |
[ 'c/c4/', false, [ 'initialCapital' => false ] ], |
| 62 |
]; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
public function testGetRel( $expected, $capitalLinks, array $info ) { |
| 73 |
$this->overrideConfigValue( MainConfigNames::CapitalLinks, $capitalLinks ); |
| 74 |
|
| 75 |
$this->assertSame( $expected, ( new LocalRepo( $info + self::getDefaultInfo() ) ) |
| 76 |
->newFile( 'test!' )->getRel() ); |
| 77 |
} |
| 78 |
|
| 79 |
public static function provideGetRel() { |
| 80 |
return [ |
| 81 |
[ 'Test!', true, [ 'hashLevels' => 0 ] ], |
| 82 |
[ 'a/a2/Test!', true, [ 'hashLevels' => 2 ] ], |
| 83 |
[ 'c/c4/test!', false, [ 'initialCapital' => false ] ], |
| 84 |
]; |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
public function testGetUrlRel( $expected, $capitalLinks, array $info ) { |
| 95 |
$this->overrideConfigValue( MainConfigNames::CapitalLinks, $capitalLinks ); |
| 96 |
|
| 97 |
$this->assertSame( $expected, ( new LocalRepo( $info + self::getDefaultInfo() ) ) |
| 98 |
->newFile( 'test!' )->getUrlRel() ); |
| 99 |
} |
| 100 |
|
| 101 |
public static function provideGetUrlRel() { |
| 102 |
return [ |
| 103 |
[ 'Test%21', true, [ 'hashLevels' => 0 ] ], |
| 104 |
[ 'a/a2/Test%21', true, [ 'hashLevels' => 2 ] ], |
| 105 |
[ 'c/c4/test%21', false, [ 'initialCapital' => false ] ], |
| 106 |
]; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
public function testGetArchivePath( $expected, $capitalLinks, array $info, array $args ) { |
| 118 |
$this->overrideConfigValue( MainConfigNames::CapitalLinks, $capitalLinks ); |
| 119 |
|
| 120 |
$this->assertSame( $expected, ( new LocalRepo( $info + self::getDefaultInfo() ) ) |
| 121 |
->newFile( 'test!' )->getArchivePath( ...$args ) ); |
| 122 |
} |
| 123 |
|
| 124 |
public static function provideGetArchivePath() { |
| 125 |
return [ |
| 126 |
[ 'mwstore://local-backend/test-public/archive', true, [ 'hashLevels' => 0 ], [] ], |
| 127 |
[ 'mwstore://local-backend/test-public/archive/a/a2', true, [ 'hashLevels' => 2 ], [] ], |
| 128 |
[ |
| 129 |
'mwstore://local-backend/test-public/archive/!', |
| 130 |
true, [ 'hashLevels' => 0 ], [ '!' ] |
| 131 |
], [ |
| 132 |
'mwstore://local-backend/test-public/archive/a/a2/!', |
| 133 |
true, [ 'hashLevels' => 2 ], [ '!' ] |
| 134 |
], |
| 135 |
]; |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
public function testGetThumbPath( $expected, $capitalLinks, array $info, array $args ) { |
| 147 |
$this->overrideConfigValue( MainConfigNames::CapitalLinks, $capitalLinks ); |
| 148 |
|
| 149 |
$this->assertSame( $expected, ( new LocalRepo( $info + self::getDefaultInfo() ) ) |
| 150 |
->newFile( 'test!' )->getThumbPath( ...$args ) ); |
| 151 |
} |
| 152 |
|
| 153 |
public static function provideGetThumbPath() { |
| 154 |
return [ |
| 155 |
[ 'mwstore://local-backend/test-thumb/Test!', true, [ 'hashLevels' => 0 ], [] ], |
| 156 |
[ 'mwstore://local-backend/test-thumb/a/a2/Test!', true, [ 'hashLevels' => 2 ], [] ], |
| 157 |
[ |
| 158 |
'mwstore://local-backend/test-thumb/Test!/x', |
| 159 |
true, [ 'hashLevels' => 0 ], [ 'x' ] |
| 160 |
], [ |
| 161 |
'mwstore://local-backend/test-thumb/a/a2/Test!/x', |
| 162 |
true, [ 'hashLevels' => 2 ], [ 'x' ] |
| 163 |
], |
| 164 |
]; |
| 165 |
} |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
public function testGetArchiveUrl( $expected, $capitalLinks, array $info, array $args ) { |
| 176 |
$this->overrideConfigValue( MainConfigNames::CapitalLinks, $capitalLinks ); |
| 177 |
|
| 178 |
$this->assertSame( $expected, ( new LocalRepo( $info + self::getDefaultInfo() ) ) |
| 179 |
->newFile( 'test!' )->getArchiveUrl( ...$args ) ); |
| 180 |
} |
| 181 |
|
| 182 |
public static function provideGetArchiveUrl() { |
| 183 |
return [ |
| 184 |
[ '/testurl/archive', true, [ 'hashLevels' => 0 ], [] ], |
| 185 |
[ '/testurl/archive/a/a2', true, [ 'hashLevels' => 2 ], [] ], |
| 186 |
[ '/testurl/archive/%21', true, [ 'hashLevels' => 0 ], [ '!' ] ], |
| 187 |
[ '/testurl/archive/a/a2/%21', true, [ 'hashLevels' => 2 ], [ '!' ] ], |
| 188 |
]; |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
public function testGetThumbUrl( $expected, $capitalLinks, array $info, array $args ) { |
| 200 |
$this->overrideConfigValue( MainConfigNames::CapitalLinks, $capitalLinks ); |
| 201 |
|
| 202 |
$this->assertSame( $expected, ( new LocalRepo( $info + self::getDefaultInfo() ) ) |
| 203 |
->newFile( 'test!' )->getThumbUrl( ...$args ) ); |
| 204 |
} |
| 205 |
|
| 206 |
public static function provideGetThumbUrl() { |
| 207 |
return [ |
| 208 |
[ '/testurl/thumb/Test%21', true, [ 'hashLevels' => 0 ], [] ], |
| 209 |
[ '/testurl/thumb/a/a2/Test%21', true, [ 'hashLevels' => 2 ], [] ], |
| 210 |
[ '/testurl/thumb/Test%21/x', true, [ 'hashLevels' => 0 ], [ 'x' ] ], |
| 211 |
[ '/testurl/thumb/a/a2/Test%21/x', true, [ 'hashLevels' => 2 ], [ 'x' ] ], |
| 212 |
]; |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
public function testGetArchiveVirtualUrl( |
| 224 |
$expected, $capitalLinks, array $info, array $args |
| 225 |
) { |
| 226 |
$this->overrideConfigValue( MainConfigNames::CapitalLinks, $capitalLinks ); |
| 227 |
|
| 228 |
$this->assertSame( $expected, ( new LocalRepo( $info + self::getDefaultInfo() ) ) |
| 229 |
->newFile( 'test!' )->getArchiveVirtualUrl( ...$args ) ); |
| 230 |
} |
| 231 |
|
| 232 |
public static function provideGetArchiveVirtualUrl() { |
| 233 |
return [ |
| 234 |
[ 'mwrepo://test/public/archive', true, [ 'hashLevels' => 0 ], [] ], |
| 235 |
[ 'mwrepo://test/public/archive/a/a2', true, [ 'hashLevels' => 2 ], [] ], |
| 236 |
[ 'mwrepo://test/public/archive/%21', true, [ 'hashLevels' => 0 ], [ '!' ] ], |
| 237 |
[ 'mwrepo://test/public/archive/a/a2/%21', true, [ 'hashLevels' => 2 ], [ '!' ] ], |
| 238 |
]; |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
public function testGetThumbVirtualUrl( $expected, $capitalLinks, array $info, array $args ) { |
| 250 |
$this->overrideConfigValue( MainConfigNames::CapitalLinks, $capitalLinks ); |
| 251 |
|
| 252 |
$this->assertSame( $expected, ( new LocalRepo( $info + self::getDefaultInfo() ) ) |
| 253 |
->newFile( 'test!' )->getThumbVirtualUrl( ...$args ) ); |
| 254 |
} |
| 255 |
|
| 256 |
public static function provideGetThumbVirtualUrl() { |
| 257 |
return [ |
| 258 |
[ 'mwrepo://test/thumb/Test%21', true, [ 'hashLevels' => 0 ], [] ], |
| 259 |
[ 'mwrepo://test/thumb/a/a2/Test%21', true, [ 'hashLevels' => 2 ], [] ], |
| 260 |
[ 'mwrepo://test/thumb/Test%21/%21', true, [ 'hashLevels' => 0 ], [ '!' ] ], |
| 261 |
[ 'mwrepo://test/thumb/a/a2/Test%21/%21', true, [ 'hashLevels' => 2 ], [ '!' ] ], |
| 262 |
]; |
| 263 |
} |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
public function testGetUrl( $expected, $capitalLinks, array $info ) { |
| 273 |
$this->overrideConfigValue( MainConfigNames::CapitalLinks, $capitalLinks ); |
| 274 |
|
| 275 |
$this->assertSame( $expected, ( new LocalRepo( $info + self::getDefaultInfo() ) ) |
| 276 |
->newFile( 'test!' )->getUrl() ); |
| 277 |
} |
| 278 |
|
| 279 |
public static function provideGetUrl() { |
| 280 |
return [ |
| 281 |
[ '/testurl/Test%21', true, [ 'hashLevels' => 0 ] ], |
| 282 |
[ '/testurl/a/a2/Test%21', true, [ 'hashLevels' => 2 ] ], |
| 283 |
]; |
| 284 |
} |
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
public function testGetUploaderForNonExistingFile() { |
| 290 |
$file = ( new LocalRepo( self::getDefaultInfo() ) )->newFile( 'test!' ); |
| 291 |
$this->assertNull( $file->getUploader() ); |
| 292 |
} |
| 293 |
|
| 294 |
public function providePermissionChecks() { |
| 295 |
$capablePerformer = $this->mockRegisteredAuthorityWithPermissions( [ 'deletedhistory', 'deletedtext' ] ); |
| 296 |
$incapablePerformer = $this->mockRegisteredAuthorityWithoutPermissions( [ 'deletedhistory', 'deletedtext' ] ); |
| 297 |
yield 'Deleted, RAW' => [ |
| 298 |
'performer' => $incapablePerformer, |
| 299 |
'audience' => File::RAW, |
| 300 |
'deleted' => File::DELETED_USER | File::DELETED_COMMENT, |
| 301 |
'expected' => true, |
| 302 |
]; |
| 303 |
yield 'No permission, not deleted' => [ |
| 304 |
'performer' => $incapablePerformer, |
| 305 |
'audience' => File::FOR_THIS_USER, |
| 306 |
'deleted' => 0, |
| 307 |
'expected' => true, |
| 308 |
]; |
| 309 |
yield 'No permission, deleted' => [ |
| 310 |
'performer' => $incapablePerformer, |
| 311 |
'audience' => File::FOR_THIS_USER, |
| 312 |
'deleted' => File::DELETED_USER | File::DELETED_COMMENT, |
| 313 |
'expected' => false, |
| 314 |
]; |
| 315 |
yield 'Not deleted, public' => [ |
| 316 |
'performer' => $capablePerformer, |
| 317 |
'audience' => File::FOR_PUBLIC, |
| 318 |
'deleted' => 0, |
| 319 |
'expected' => true, |
| 320 |
]; |
| 321 |
yield 'Deleted, public' => [ |
| 322 |
'performer' => $capablePerformer, |
| 323 |
'audience' => File::FOR_PUBLIC, |
| 324 |
'deleted' => File::DELETED_USER | File::DELETED_COMMENT, |
| 325 |
'expected' => false, |
| 326 |
]; |
| 327 |
yield 'With permission, deleted' => [ |
| 328 |
'performer' => $capablePerformer, |
| 329 |
'audience' => File::FOR_THIS_USER, |
| 330 |
'deleted' => File::DELETED_USER | File::DELETED_COMMENT, |
| 331 |
'expected' => true, |
| 332 |
]; |
| 333 |
} |
| 334 |
|
| 335 |
private function getOldLocalFileWithDeletion( |
| 336 |
UserIdentity $uploader, |
| 337 |
int $deletedFlags |
| 338 |
): OldLocalFile { |
| 339 |
$this->getDb()->newInsertQueryBuilder() |
| 340 |
->insertInto( 'oldimage' ) |
| 341 |
->row( [ |
| 342 |
'oi_name' => 'Random-11m.png', |
| 343 |
'oi_archive_name' => 'Random-11m.png', |
| 344 |
'oi_size' => 10816824, |
| 345 |
'oi_width' => 1000, |
| 346 |
'oi_height' => 1800, |
| 347 |
'oi_metadata' => '', |
| 348 |
'oi_bits' => 16, |
| 349 |
'oi_media_type' => 'BITMAP', |
| 350 |
'oi_major_mime' => 'image', |
| 351 |
'oi_minor_mime' => 'png', |
| 352 |
'oi_description_id' => $this->getServiceContainer() |
| 353 |
->getCommentStore() |
| 354 |
->createComment( $this->getDb(), 'comment' )->id, |
| 355 |
'oi_actor' => $this->getServiceContainer() |
| 356 |
->getActorStore() |
| 357 |
->acquireActorId( $uploader, $this->getDb() ), |
| 358 |
'oi_timestamp' => $this->getDb()->timestamp( '20201105235242' ), |
| 359 |
'oi_sha1' => 'sy02psim0bgdh0jt4vdltuzoh7j80ru', |
| 360 |
'oi_deleted' => $deletedFlags, |
| 361 |
] ) |
| 362 |
->caller( __METHOD__ ) |
| 363 |
->execute(); |
| 364 |
$file = OldLocalFile::newFromTitle( |
| 365 |
Title::makeTitle( NS_FILE, 'Random-11m.png' ), |
| 366 |
$this->getServiceContainer()->getRepoGroup()->getLocalRepo(), |
| 367 |
'20201105235242' |
| 368 |
); |
| 369 |
$this->assertInstanceOf( File::class, $file, 'Created a test file' ); |
| 370 |
return $file; |
| 371 |
} |
| 372 |
|
| 373 |
private function getArchivedFileWithDeletion( |
| 374 |
UserIdentity $uploader, |
| 375 |
int $deletedFlags |
| 376 |
): ArchivedFile { |
| 377 |
return ArchivedFile::newFromRow( (object)[ |
| 378 |
'fa_id' => 1, |
| 379 |
'fa_storage_group' => 'test', |
| 380 |
'fa_storage_key' => 'bla', |
| 381 |
'fa_name' => 'Random-11m.png', |
| 382 |
'fa_archive_name' => 'Random-11m.png', |
| 383 |
'fa_size' => 10816824, |
| 384 |
'fa_width' => 1000, |
| 385 |
'fa_height' => 1800, |
| 386 |
'fa_metadata' => '', |
| 387 |
'fa_bits' => 16, |
| 388 |
'fa_media_type' => 'BITMAP', |
| 389 |
'fa_major_mime' => 'image', |
| 390 |
'fa_minor_mime' => 'png', |
| 391 |
'fa_description_id' => $this->getServiceContainer() |
| 392 |
->getCommentStore() |
| 393 |
->createComment( $this->getDb(), 'comment' )->id, |
| 394 |
'fa_actor' => $this->getServiceContainer() |
| 395 |
->getActorStore() |
| 396 |
->acquireActorId( $uploader, $this->getDb() ), |
| 397 |
'fa_user' => $uploader->getId(), |
| 398 |
'fa_user_text' => $uploader->getName(), |
| 399 |
'fa_timestamp' => $this->getDb()->timestamp( '20201105235242' ), |
| 400 |
'fa_sha1' => 'sy02psim0bgdh0jt4vdltuzoh7j80ru', |
| 401 |
'fa_deleted' => $deletedFlags, |
| 402 |
] |
| 403 |
); |
| 404 |
} |
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
public function testGetUploader( |
| 411 |
Authority $performer, |
| 412 |
int $audience, |
| 413 |
int $deleted, |
| 414 |
bool $expected |
| 415 |
) { |
| 416 |
$file = $this->getOldLocalFileWithDeletion( $performer->getUser(), $deleted ); |
| 417 |
if ( $expected ) { |
| 418 |
$this->assertTrue( $performer->getUser()->equals( $file->getUploader( $audience, $performer ) ) ); |
| 419 |
} else { |
| 420 |
$this->assertNull( $file->getUploader( $audience, $performer ) ); |
| 421 |
} |
| 422 |
} |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
public function testGetDescription( |
| 429 |
Authority $performer, |
| 430 |
int $audience, |
| 431 |
int $deleted, |
| 432 |
bool $expected |
| 433 |
) { |
| 434 |
$file = $this->getArchivedFileWithDeletion( $performer->getUser(), $deleted ); |
| 435 |
if ( $expected ) { |
| 436 |
$this->assertSame( 'comment', $file->getDescription( $audience, $performer ) ); |
| 437 |
} else { |
| 438 |
$this->assertSame( '', $file->getDescription( $audience, $performer ) ); |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
public function testArchivedGetUploader( |
| 447 |
Authority $performer, |
| 448 |
int $audience, |
| 449 |
int $deleted, |
| 450 |
bool $expected |
| 451 |
) { |
| 452 |
$file = $this->getArchivedFileWithDeletion( $performer->getUser(), $deleted ); |
| 453 |
if ( $expected ) { |
| 454 |
$this->assertTrue( $performer->getUser()->equals( $file->getUploader( $audience, $performer ) ) ); |
| 455 |
} else { |
| 456 |
$this->assertNull( $file->getUploader( $audience, $performer ) ); |
| 457 |
} |
| 458 |
} |
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
public function testArchivedGetDescription( |
| 465 |
Authority $performer, |
| 466 |
int $audience, |
| 467 |
int $deleted, |
| 468 |
bool $expected |
| 469 |
) { |
| 470 |
$file = $this->getOldLocalFileWithDeletion( $performer->getUser(), $deleted ); |
| 471 |
if ( $expected ) { |
| 472 |
$this->assertSame( 'comment', $file->getDescription( $audience, $performer ) ); |
| 473 |
} else { |
| 474 |
$this->assertSame( '', $file->getDescription( $audience, $performer ) ); |
| 475 |
} |
| 476 |
} |
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
public function testDescriptionShortUrlForNonExistingFile() { |
| 482 |
$file = ( new LocalRepo( self::getDefaultInfo() ) )->newFile( 'test!' ); |
| 483 |
$this->assertNull( $file->getDescriptionShortUrl() ); |
| 484 |
} |
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
public function testDescriptionText_NonExisting() { |
| 490 |
$file = ( new LocalRepo( self::getDefaultInfo() ) )->newFile( 'test!' ); |
| 491 |
$this->assertFalse( $file->getDescriptionText() ); |
| 492 |
} |
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
public function testDescriptionText_Existing() { |
| 498 |
$this->assertTrue( $this->editPage( |
| 499 |
__METHOD__, |
| 500 |
'TEST CONTENT', |
| 501 |
'', |
| 502 |
NS_FILE |
| 503 |
)->isOK() ); |
| 504 |
$file = ( new LocalRepo( self::getDefaultInfo() ) )->newFile( __METHOD__ ); |
| 505 |
$this->assertStringContainsString( 'TEST CONTENT', $file->getDescriptionText() ); |
| 506 |
} |
| 507 |
|
| 508 |
public static function provideLoadFromDBAndCache() { |
| 509 |
return [ |
| 510 |
'legacy' => [ |
| 511 |
'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:16;s:9:"colorType";s:10:"truecolour";s:8:"metadata";a:2:{s:8:"DateTime";s:19:"2019:07:30 13:52:32";s:15:"_MW_PNG_VERSION";i:1;}}', |
| 512 |
[], |
| 513 |
false, |
| 514 |
], |
| 515 |
'json' => [ |
| 516 |
'{"data":{"frameCount":0,"loopCount":1,"duration":0,"bitDepth":16,"colorType":"truecolour","metadata":{"DateTime":"2019:07:30 13:52:32","_MW_PNG_VERSION":1}}}', |
| 517 |
[], |
| 518 |
false, |
| 519 |
], |
| 520 |
'json with blobs' => [ |
| 521 |
'{"blobs":{"colorType":"__BLOB0__"},"data":{"frameCount":0,"loopCount":1,"duration":0,"bitDepth":16,"metadata":{"DateTime":"2019:07:30 13:52:32","_MW_PNG_VERSION":1}}}', |
| 522 |
[ '"truecolour"' ], |
| 523 |
false, |
| 524 |
], |
| 525 |
'large (>100KB triggers uncached case)' => [ |
| 526 |
'{"data":{"large":"' . str_repeat( 'x', 102401 ) . '","frameCount":0,"loopCount":1,"duration":0,"bitDepth":16,"colorType":"truecolour","metadata":{"DateTime":"2019:07:30 13:52:32","_MW_PNG_VERSION":1}}}', |
| 527 |
[], |
| 528 |
102401, |
| 529 |
], |
| 530 |
'large json blob' => [ |
| 531 |
'{"blobs":{"large":"__BLOB0__"},"data":{"frameCount":0,"loopCount":1,"duration":0,"bitDepth":16,"colorType":"truecolour","metadata":{"DateTime":"2019:07:30 13:52:32","_MW_PNG_VERSION":1}}}', |
| 532 |
[ '"' . str_repeat( 'x', 102401 ) . '"' ], |
| 533 |
102401, |
| 534 |
], |
| 535 |
]; |
| 536 |
} |
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
public function testLoadFromDBAndCache( $meta, $blobs, $largeItemSize ) { |
| 550 |
$services = $this->getServiceContainer(); |
| 551 |
|
| 552 |
$cache = new HashBagOStuff; |
| 553 |
$this->setService( |
| 554 |
'MainWANObjectCache', |
| 555 |
new WANObjectCache( [ |
| 556 |
'cache' => $cache |
| 557 |
] ) |
| 558 |
); |
| 559 |
|
| 560 |
$dbw = $this->getDb(); |
| 561 |
$norm = $services->getActorNormalization(); |
| 562 |
$user = $this->getTestSysop()->getUserIdentity(); |
| 563 |
$actorId = $norm->acquireActorId( $user, $dbw ); |
| 564 |
$comment = $services->getCommentStore()->createComment( $dbw, 'comment' ); |
| 565 |
$title = Title::makeTitle( NS_FILE, 'Random-11m.png' ); |
| 566 |
|
| 567 |
if ( $blobs ) { |
| 568 |
$blobStore = $services->getBlobStore(); |
| 569 |
foreach ( $blobs as $i => $value ) { |
| 570 |
$address = $blobStore->storeBlob( $value ); |
| 571 |
$meta = str_replace( "__BLOB{$i}__", $address, $meta ); |
| 572 |
} |
| 573 |
} |
| 574 |
|
| 575 |
|
| 576 |
$expectedMetaArray = [ |
| 577 |
'frameCount' => 0, |
| 578 |
'loopCount' => 1, |
| 579 |
'duration' => 0.0, |
| 580 |
'bitDepth' => 16, |
| 581 |
'colorType' => 'truecolour', |
| 582 |
'metadata' => [ |
| 583 |
'DateTime' => '2019:07:30 13:52:32', |
| 584 |
'_MW_PNG_VERSION' => 1, |
| 585 |
], |
| 586 |
]; |
| 587 |
if ( $largeItemSize ) { |
| 588 |
$expectedMetaArray['large'] = str_repeat( 'x', $largeItemSize ); |
| 589 |
} |
| 590 |
$expectedProps = [ |
| 591 |
'name' => 'Random-11m.png', |
| 592 |
'size' => 10816824, |
| 593 |
'width' => 1000, |
| 594 |
'height' => 1800, |
| 595 |
'metadata' => $expectedMetaArray, |
| 596 |
'bits' => 16, |
| 597 |
'media_type' => 'BITMAP', |
| 598 |
'mime' => 'image/png', |
| 599 |
'timestamp' => '20201105235242', |
| 600 |
'sha1' => 'sy02psim0bgdh0jt4vdltuzoh7j80ru' |
| 601 |
]; |
| 602 |
|
| 603 |
$dbw->newInsertQueryBuilder() |
| 604 |
->insertInto( 'image' ) |
| 605 |
->row( [ |
| 606 |
'img_name' => 'Random-11m.png', |
| 607 |
'img_size' => 10816824, |
| 608 |
'img_width' => 1000, |
| 609 |
'img_height' => 1800, |
| 610 |
'img_metadata' => $dbw->encodeBlob( $meta ), |
| 611 |
'img_bits' => 16, |
| 612 |
'img_media_type' => 'BITMAP', |
| 613 |
'img_major_mime' => 'image', |
| 614 |
'img_minor_mime' => 'png', |
| 615 |
'img_description_id' => $comment->id, |
| 616 |
'img_actor' => $actorId, |
| 617 |
'img_timestamp' => $dbw->timestamp( '20201105235242' ), |
| 618 |
'img_sha1' => 'sy02psim0bgdh0jt4vdltuzoh7j80ru', |
| 619 |
] ) |
| 620 |
->caller( __METHOD__ ) |
| 621 |
->execute(); |
| 622 |
$repo = $services->getRepoGroup()->getLocalRepo(); |
| 623 |
$file = $repo->findFile( $title ); |
| 624 |
|
| 625 |
$this->assertFileProperties( $expectedProps, $file ); |
| 626 |
$this->assertSame( 'truecolour', $file->getMetadataItem( 'colorType' ) ); |
| 627 |
$this->assertSame( |
| 628 |
[ 'loopCount' => 1, 'bitDepth' => 16 ], |
| 629 |
$file->getMetadataItems( [ 'loopCount', 'bitDepth', 'nonexistent' ] ) |
| 630 |
); |
| 631 |
$this->assertSame( 'comment', $file->getDescription() ); |
| 632 |
$this->assertTrue( $user->equals( $file->getUploader() ) ); |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
$dbw->newUpdateQueryBuilder() |
| 637 |
->update( 'image' ) |
| 638 |
->set( [ 'img_size' => 0 ] ) |
| 639 |
->where( [ 'img_name' => 'Random-11m.png' ] ) |
| 640 |
->caller( __METHOD__ )->execute(); |
| 641 |
$file = LocalFile::newFromTitle( $title, $repo ); |
| 642 |
|
| 643 |
$this->assertFileProperties( $expectedProps, $file ); |
| 644 |
$this->assertSame( 'truecolour', $file->getMetadataItem( 'colorType' ) ); |
| 645 |
$this->assertSame( |
| 646 |
[ 'loopCount' => 1, 'bitDepth' => 16 ], |
| 647 |
$file->getMetadataItems( [ 'loopCount', 'bitDepth', 'nonexistent' ] ) |
| 648 |
); |
| 649 |
$this->assertSame( 'comment', $file->getDescription() ); |
| 650 |
$this->assertTrue( $user->equals( $file->getUploader() ) ); |
| 651 |
|
| 652 |
|
| 653 |
$dbw->newDeleteQueryBuilder() |
| 654 |
->deleteFrom( 'image' ) |
| 655 |
->where( [ 'img_name' => 'Random-11m.png' ] ) |
| 656 |
->caller( __METHOD__ )->execute(); |
| 657 |
$file->invalidateCache(); |
| 658 |
$file = LocalFile::newFromTitle( $title, $repo ); |
| 659 |
$this->assertSame( false, $file->exists() ); |
| 660 |
} |
| 661 |
|
| 662 |
private function assertFileProperties( $expectedProps, $file ) { |
| 663 |
|
| 664 |
if ( isset( $expectedProps['metadata'] ) ) { |
| 665 |
$this->assertArrayEquals( $expectedProps['metadata'], $file->getMetadataArray() ); |
| 666 |
} |
| 667 |
|
| 668 |
|
| 669 |
$expectedProps = array_intersect_key( |
| 670 |
$expectedProps, |
| 671 |
array_fill_keys( [ |
| 672 |
'name', 'size', 'width', 'height', |
| 673 |
'bits', 'media_type', 'mime', 'timestamp', 'sha1' |
| 674 |
], true ) |
| 675 |
); |
| 676 |
|
| 677 |
|
| 678 |
$actualProps = [ |
| 679 |
'name' => $file->getName(), |
| 680 |
'size' => $file->getSize(), |
| 681 |
'width' => $file->getWidth(), |
| 682 |
'height' => $file->getHeight(), |
| 683 |
'bits' => $file->getBitDepth(), |
| 684 |
'media_type' => $file->getMediaType(), |
| 685 |
'mime' => $file->getMimeType(), |
| 686 |
'timestamp' => $file->getTimestamp(), |
| 687 |
'sha1' => $file->getSha1() |
| 688 |
]; |
| 689 |
$actualProps = array_intersect_key( $actualProps, $expectedProps ); |
| 690 |
$this->assertArrayEquals( $expectedProps, $actualProps, false, true ); |
| 691 |
} |
| 692 |
|
| 693 |
public static function provideLegacyMetadataRoundTrip() { |
| 694 |
return [ |
| 695 |
[ '0' ], |
| 696 |
[ '-1' ], |
| 697 |
[ '' ] |
| 698 |
]; |
| 699 |
} |
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
public function testLegacyMetadataRoundTrip( $meta ) { |
| 707 |
$file = new class( $meta ) extends LocalFile { |
| 708 |
public function __construct( $meta ) { |
| 709 |
$repo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo(); |
| 710 |
parent::__construct( |
| 711 |
Title::makeTitle( NS_FILE, 'TestLegacyMetadataRoundTrip' ), |
| 712 |
$repo ); |
| 713 |
$this->loadMetadataFromString( $meta ); |
| 714 |
$this->dataLoaded = true; |
| 715 |
} |
| 716 |
}; |
| 717 |
$this->assertSame( $meta, $file->getMetadata() ); |
| 718 |
} |
| 719 |
|
| 720 |
public static function provideRecordUpload3() { |
| 721 |
$files = [ |
| 722 |
'test.jpg' => [ |
| 723 |
'width' => 20, |
| 724 |
'height' => 20, |
| 725 |
'bits' => 8, |
| 726 |
'metadata' => [ |
| 727 |
'ImageDescription' => 'Test file', |
| 728 |
'XResolution' => '72/1', |
| 729 |
'YResolution' => '72/1', |
| 730 |
'ResolutionUnit' => 2, |
| 731 |
'YCbCrPositioning' => 1, |
| 732 |
'JPEGFileComment' => [ |
| 733 |
'Created with GIMP', |
| 734 |
], |
| 735 |
'MEDIAWIKI_EXIF_VERSION' => 2, |
| 736 |
], |
| 737 |
'fileExists' => true, |
| 738 |
'size' => 437, |
| 739 |
'file-mime' => 'image/jpeg', |
| 740 |
'major_mime' => 'image', |
| 741 |
'minor_mime' => 'jpeg', |
| 742 |
'mime' => 'image/jpeg', |
| 743 |
'sha1' => '620ezvucfyia1mltnavzpqg9gmai2gf', |
| 744 |
'media_type' => 'BITMAP', |
| 745 |
], |
| 746 |
'large-text.pdf' => [ |
| 747 |
'width' => 1275, |
| 748 |
'height' => 1650, |
| 749 |
'fileExists' => true, |
| 750 |
'size' => 10598657, |
| 751 |
'file-mime' => 'application/pdf', |
| 752 |
'major_mime' => 'application', |
| 753 |
'minor_mime' => 'pdf', |
| 754 |
'mime' => 'application/pdf', |
| 755 |
'sha1' => '1o3l1yqjue2diq07grnnyq9kyapfpor', |
| 756 |
'bits' => 0, |
| 757 |
'media_type' => 'OFFICE', |
| 758 |
'metadata' => [ |
| 759 |
'Pages' => '6', |
| 760 |
'text' => [ |
| 761 |
'Page 1 text .................................', |
| 762 |
'Page 2 text .................................', |
| 763 |
'Page 3 text .................................', |
| 764 |
'Page 4 text .................................', |
| 765 |
'Page 5 text .................................', |
| 766 |
'Page 6 text .................................', |
| 767 |
] |
| 768 |
] |
| 769 |
], |
| 770 |
'no-text.pdf' => [ |
| 771 |
'width' => 1275, |
| 772 |
'height' => 1650, |
| 773 |
'fileExists' => true, |
| 774 |
'size' => 10598657, |
| 775 |
'file-mime' => 'application/pdf', |
| 776 |
'major_mime' => 'application', |
| 777 |
'minor_mime' => 'pdf', |
| 778 |
'mime' => 'application/pdf', |
| 779 |
'sha1' => '1o3l1yqjue2diq07grnnyq9kyapfpor', |
| 780 |
'bits' => 0, |
| 781 |
'media_type' => 'OFFICE', |
| 782 |
'metadata' => [ |
| 783 |
'Pages' => '6', |
| 784 |
] |
| 785 |
] |
| 786 |
]; |
| 787 |
$configurations = [ |
| 788 |
[], |
| 789 |
[ 'useJsonMetadata' => true ], |
| 790 |
[ |
| 791 |
'useJsonMetadata' => true, |
| 792 |
'useSplitMetadata' => true, |
| 793 |
'splitMetadataThreshold' => 50 |
| 794 |
] |
| 795 |
]; |
| 796 |
return ArrayUtils::cartesianProduct( $files, $configurations ); |
| 797 |
} |
| 798 |
|
| 799 |
private function getMockPdfHandler() { |
| 800 |
return new class extends ImageHandler { |
| 801 |
public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { |
| 802 |
} |
| 803 |
|
| 804 |
public function useSplitMetadata() { |
| 805 |
return true; |
| 806 |
} |
| 807 |
}; |
| 808 |
} |
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
public function testRecordUpload3( $props, $conf ) { |
| 820 |
$repo = new LocalRepo( |
| 821 |
[ |
| 822 |
'class' => LocalRepo::class, |
| 823 |
'name' => 'test', |
| 824 |
'backend' => new FSFileBackend( [ |
| 825 |
'name' => 'test-backend', |
| 826 |
'wikiId' => WikiMap::getCurrentWikiId(), |
| 827 |
'basePath' => '/nonexistent' |
| 828 |
] ) |
| 829 |
] + $conf |
| 830 |
); |
| 831 |
$title = Title::makeTitle( NS_FILE, 'Test.jpg' ); |
| 832 |
$file = new LocalFile( $title, $repo ); |
| 833 |
|
| 834 |
if ( $props['mime'] === 'application/pdf' ) { |
| 835 |
TestingAccessWrapper::newFromObject( $file )->handler = $this->getMockPdfHandler(); |
| 836 |
} |
| 837 |
|
| 838 |
$status = $file->recordUpload3( |
| 839 |
'oldver', |
| 840 |
'comment', |
| 841 |
'page text', |
| 842 |
$this->getTestSysop()->getUser(), |
| 843 |
$props |
| 844 |
); |
| 845 |
$this->assertStatusGood( $status ); |
| 846 |
|
| 847 |
$this->assertFileProperties( $props, $file ); |
| 848 |
|
| 849 |
$file = new LocalFile( $title, $repo ); |
| 850 |
$this->assertFileProperties( $props, $file ); |
| 851 |
} |
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
public function testUpload() { |
| 857 |
$repo = new LocalRepo( |
| 858 |
[ |
| 859 |
'class' => LocalRepo::class, |
| 860 |
'name' => 'test', |
| 861 |
'backend' => new FSFileBackend( [ |
| 862 |
'name' => 'test-backend', |
| 863 |
'wikiId' => WikiMap::getCurrentWikiId(), |
| 864 |
'basePath' => $this->getNewTempDirectory() |
| 865 |
] ) |
| 866 |
] |
| 867 |
); |
| 868 |
$title = Title::makeTitle( NS_FILE, 'Test.jpg' ); |
| 869 |
$file = new LocalFile( $title, $repo ); |
| 870 |
$path = __DIR__ . '/../../../data/media/test.jpg'; |
| 871 |
$status = $file->upload( |
| 872 |
$path, |
| 873 |
'comment', |
| 874 |
'page text', |
| 875 |
0, |
| 876 |
false, |
| 877 |
false, |
| 878 |
$this->getTestUser()->getUser() |
| 879 |
); |
| 880 |
$this->assertStatusGood( $status ); |
| 881 |
|
| 882 |
|
| 883 |
$file = new LocalFile( $title, $repo ); |
| 884 |
$path = __DIR__ . '/../../../data/media/jpeg-xmp-nullchar.jpg'; |
| 885 |
$status = $file->upload( |
| 886 |
$path, |
| 887 |
'comment', |
| 888 |
'page text', |
| 889 |
0, |
| 890 |
false, |
| 891 |
false, |
| 892 |
$this->getTestUser()->getUser() |
| 893 |
); |
| 894 |
$this->assertStatusGood( $status ); |
| 895 |
} |
| 896 |
|
| 897 |
public static function provideReserializeMetadata() { |
| 898 |
return [ |
| 899 |
[ |
| 900 |
'', |
| 901 |
'' |
| 902 |
], |
| 903 |
[ |
| 904 |
'a:1:{s:4:"test";i:1;}', |
| 905 |
'{"data":{"test":1}}' |
| 906 |
], |
| 907 |
[ |
| 908 |
serialize( [ 'test' => str_repeat( 'x', 100 ) ] ), |
| 909 |
'{"data":[],"blobs":{"test":"tt:%d"}}' |
| 910 |
] |
| 911 |
]; |
| 912 |
} |
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
public function testReserializeMetadata( $input, $expected ) { |
| 922 |
$dbw = $this->getDb(); |
| 923 |
$services = $this->getServiceContainer(); |
| 924 |
$norm = $services->getActorNormalization(); |
| 925 |
$user = $this->getTestSysop()->getUserIdentity(); |
| 926 |
$actorId = $norm->acquireActorId( $user, $dbw ); |
| 927 |
$comment = $services->getCommentStore()->createComment( $dbw, 'comment' ); |
| 928 |
|
| 929 |
$dbw->newInsertQueryBuilder() |
| 930 |
->insertInto( 'image' ) |
| 931 |
->row( [ |
| 932 |
'img_name' => 'Test.pdf', |
| 933 |
'img_size' => 1, |
| 934 |
'img_width' => 1, |
| 935 |
'img_height' => 1, |
| 936 |
'img_metadata' => $dbw->encodeBlob( $input ), |
| 937 |
'img_bits' => 0, |
| 938 |
'img_media_type' => 'OFFICE', |
| 939 |
'img_major_mime' => 'application', |
| 940 |
'img_minor_mime' => 'pdf', |
| 941 |
'img_description_id' => $comment->id, |
| 942 |
'img_actor' => $actorId, |
| 943 |
'img_timestamp' => $dbw->timestamp( '20201105235242' ), |
| 944 |
'img_sha1' => 'hhhh', |
| 945 |
] ) |
| 946 |
->caller( __METHOD__ ) |
| 947 |
->execute(); |
| 948 |
|
| 949 |
$repo = new LocalRepo( [ |
| 950 |
'class' => LocalRepo::class, |
| 951 |
'name' => 'test', |
| 952 |
'useJsonMetadata' => true, |
| 953 |
'useSplitMetadata' => true, |
| 954 |
'splitMetadataThreshold' => 50, |
| 955 |
'updateCompatibleMetadata' => true, |
| 956 |
'reserializeMetadata' => true, |
| 957 |
'backend' => new FSFileBackend( [ |
| 958 |
'name' => 'test-backend', |
| 959 |
'wikiId' => WikiMap::getCurrentWikiId(), |
| 960 |
'basePath' => '/nonexistent' |
| 961 |
] ) |
| 962 |
] ); |
| 963 |
$title = Title::makeTitle( NS_FILE, 'Test.pdf' ); |
| 964 |
$file = new LocalFile( $title, $repo ); |
| 965 |
TestingAccessWrapper::newFromObject( $file )->handler = $this->getMockPdfHandler(); |
| 966 |
$file->load(); |
| 967 |
$file->maybeUpgradeRow(); |
| 968 |
|
| 969 |
$metadata = $dbw->decodeBlob( $dbw->newSelectQueryBuilder() |
| 970 |
->select( 'img_metadata' ) |
| 971 |
->from( 'image' ) |
| 972 |
->where( [ 'img_name' => 'Test.pdf' ] ) |
| 973 |
->caller( __METHOD__ )->fetchField() |
| 974 |
); |
| 975 |
$this->assertStringMatchesFormat( $expected, $metadata ); |
| 976 |
} |
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
public function testUpgradeRow() { |
| 985 |
$repo = new LocalRepo( [ |
| 986 |
'class' => LocalRepo::class, |
| 987 |
'name' => 'test', |
| 988 |
'updateCompatibleMetadata' => true, |
| 989 |
'useJsonMetadata' => true, |
| 990 |
'hashLevels' => 0, |
| 991 |
'backend' => new FSFileBackend( [ |
| 992 |
'name' => 'test-backend', |
| 993 |
'wikiId' => WikiMap::getCurrentWikiId(), |
| 994 |
'containerPaths' => [ 'test-public' => __DIR__ . '/../../../data/media' ] |
| 995 |
] ) |
| 996 |
] ); |
| 997 |
$dbw = $this->getDb(); |
| 998 |
$services = $this->getServiceContainer(); |
| 999 |
$norm = $services->getActorNormalization(); |
| 1000 |
$user = $this->getTestSysop()->getUserIdentity(); |
| 1001 |
$actorId = $norm->acquireActorId( $user, $dbw ); |
| 1002 |
$comment = $services->getCommentStore()->createComment( $dbw, 'comment' ); |
| 1003 |
|
| 1004 |
$dbw->newInsertQueryBuilder() |
| 1005 |
->insertInto( 'image' ) |
| 1006 |
->row( [ |
| 1007 |
'img_name' => 'Png-native-test.png', |
| 1008 |
'img_size' => 1, |
| 1009 |
'img_width' => 1, |
| 1010 |
'img_height' => 1, |
| 1011 |
'img_metadata' => $dbw->encodeBlob( 'a:1:{s:8:"metadata";a:1:{s:15:"_MW_PNG_VERSION";i:0;}}' ), |
| 1012 |
'img_bits' => 0, |
| 1013 |
'img_media_type' => 'OFFICE', |
| 1014 |
'img_major_mime' => 'image', |
| 1015 |
'img_minor_mime' => 'png', |
| 1016 |
'img_description_id' => $comment->id, |
| 1017 |
'img_actor' => $actorId, |
| 1018 |
'img_timestamp' => $dbw->timestamp( '20201105235242' ), |
| 1019 |
'img_sha1' => 'hhhh', |
| 1020 |
] ) |
| 1021 |
->caller( __METHOD__ ) |
| 1022 |
->execute(); |
| 1023 |
|
| 1024 |
$title = Title::makeTitle( NS_FILE, 'Png-native-test.png' ); |
| 1025 |
$file = new LocalFile( $title, $repo ); |
| 1026 |
$file->load(); |
| 1027 |
$file->maybeUpgradeRow(); |
| 1028 |
$metadata = $dbw->decodeBlob( $dbw->newSelectQueryBuilder() |
| 1029 |
->select( 'img_metadata' ) |
| 1030 |
->from( 'image' ) |
| 1031 |
->where( [ 'img_name' => 'Png-native-test.png' ] ) |
| 1032 |
->fetchField() |
| 1033 |
); |
| 1034 |
|
| 1035 |
$this->assertStringStartsWith( '{"data":{"frameCount":0,', $metadata ); |
| 1036 |
|
| 1037 |
$file = new LocalFile( $title, $repo ); |
| 1038 |
$this->assertFileProperties( |
| 1039 |
[ |
| 1040 |
'size' => 4665, |
| 1041 |
'width' => 420, |
| 1042 |
'height' => 300, |
| 1043 |
'sha1' => '3n69qtiaif1swp3kyfueqjtmw2u4c2b', |
| 1044 |
'bits' => 8, |
| 1045 |
'media_type' => 'BITMAP', |
| 1046 |
], |
| 1047 |
$file ); |
| 1048 |
} |
| 1049 |
} |