Remove messages.inc, rebuildLanguage.php, writeMessagesArray.inc
[mediawiki.git] / tests / phpunit / includes / media / JpegTest.php
blobb2611371f80dd43a2d2efd9f39a769216cce1288
1 <?php
2 /**
3 * @covers JpegHandler
4 */
5 class JpegTest extends MediaWikiTestCase {
7 protected $filePath;
9 protected function setUp() {
10 parent::setUp();
11 $this->checkPHPExtension( 'exif' );
13 $this->filePath = __DIR__ . '/../../data/media/';
15 $this->setMwGlobals( 'wgShowEXIF', true );
17 $this->backend = new FSFileBackend( array(
18 'name' => 'localtesting',
19 'wikiId' => wfWikiId(),
20 'containerPaths' => array( 'data' => $this->filePath )
21 ) );
22 $this->repo = new FSRepo( array(
23 'name' => 'temp',
24 'url' => 'http://localhost/thumbtest',
25 'backend' => $this->backend
26 ) );
28 $this->handler = new JpegHandler;
31 public function testInvalidFile() {
32 $file = $this->dataFile( 'README', 'image/jpeg' );
33 $res = $this->handler->getMetadata( $file, $this->filePath . 'README' );
34 $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res );
37 public function testJpegMetadataExtraction() {
38 $file = $this->dataFile( 'test.jpg', 'image/jpeg' );
39 $res = $this->handler->getMetadata( $file, $this->filePath . 'test.jpg' );
40 // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong
41 $expected = 'a:7:{s:16:"ImageDescription";s:9:"Test file";s:11:"XResolution";s:4:"72/1";s:11:"YResolution";s:4:"72/1";s:14:"ResolutionUnit";i:2;s:16:"YCbCrPositioning";i:1;s:15:"JPEGFileComment";a:1:{i:0;s:17:"Created with GIMP";}s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}';
42 // @codingStandardsIgnoreEnd
44 // Unserialize in case serialization format ever changes.
45 $this->assertEquals( unserialize( $expected ), unserialize( $res ) );
48 /**
49 * @covers JpegHandler::getCommonMetaArray
51 public function testGetIndependentMetaArray() {
52 $file = $this->dataFile( 'test.jpg', 'image/jpeg' );
53 $res = $this->handler->getCommonMetaArray( $file );
54 $expected = array(
55 'ImageDescription' => 'Test file',
56 'XResolution' => '72/1',
57 'YResolution' => '72/1',
58 'ResolutionUnit' => 2,
59 'YCbCrPositioning' => 1,
60 'JPEGFileComment' => array(
61 'Created with GIMP',
65 $this->assertEquals( $res, $expected );
68 private function dataFile( $name, $type ) {
69 return new UnregisteredLocalFile( false, $this->repo,
70 "mwstore://localtesting/data/$name", $type );