ImagePage404Test.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * For doing Image Page tests that rely on 404 thumb handling
  4. */
  5. class ImagePage404Test extends MediaWikiMediaTestCase {
  6. protected function getRepoOptions() {
  7. return parent::getRepoOptions() + [ 'transformVia404' => true ];
  8. }
  9. function setUp() {
  10. $this->setMwGlobals( 'wgImageLimits', [
  11. [ 320, 240 ],
  12. [ 640, 480 ],
  13. [ 800, 600 ],
  14. [ 1024, 768 ],
  15. [ 1280, 1024 ]
  16. ] );
  17. parent::setUp();
  18. }
  19. function getImagePage( $filename ) {
  20. $title = Title::makeTitleSafe( NS_FILE, $filename );
  21. $file = $this->dataFile( $filename );
  22. $iPage = new ImagePage( $title );
  23. $iPage->setFile( $file );
  24. return $iPage;
  25. }
  26. /**
  27. * @covers ImagePage::getThumbSizes
  28. * @dataProvider providerGetThumbSizes
  29. * @param string $filename
  30. * @param int $expectedNumberThumbs How many thumbnails to show
  31. */
  32. function testGetThumbSizes( $filename, $expectedNumberThumbs ) {
  33. $iPage = $this->getImagePage( $filename );
  34. $reflection = new ReflectionClass( $iPage );
  35. $reflMethod = $reflection->getMethod( 'getThumbSizes' );
  36. $reflMethod->setAccessible( true );
  37. $actual = $reflMethod->invoke( $iPage, 545, 700 );
  38. $this->assertEquals( count( $actual ), $expectedNumberThumbs );
  39. }
  40. function providerGetThumbSizes() {
  41. return [
  42. [ 'animated.gif', 6 ],
  43. [ 'Toll_Texas_1.svg', 6 ],
  44. [ '80x60-Greyscale.xcf', 6 ],
  45. [ 'jpeg-comment-binary.jpg', 6 ],
  46. ];
  47. }
  48. }