MediaWiki  1.23.2
JpegTest.php
Go to the documentation of this file.
1 <?php
5 class JpegTest extends MediaWikiTestCase {
6 
7  protected $filePath;
8 
9  protected function setUp() {
10  parent::setUp();
11  $this->checkPHPExtension( 'exif' );
12 
13  $this->filePath = __DIR__ . '/../../data/media/';
14 
15  $this->setMwGlobals( 'wgShowEXIF', true );
16 
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  ) );
27 
28  $this->handler = new JpegHandler;
29  }
30 
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 );
35  }
36 
37  public function testJpegMetadataExtraction() {
38  $file = $this->dataFile( 'test.jpg', 'image/jpeg' );
39  $res = $this->handler->getMetadata( $file, $this->filePath . 'test.jpg' );
40  $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;}';
41 
42  // Unserialize in case serialization format ever changes.
43  $this->assertEquals( unserialize( $expected ), unserialize( $res ) );
44  }
45 
49  public function testGetIndependentMetaArray() {
50  $file = $this->dataFile( 'test.jpg', 'image/jpeg' );
51  $res = $this->handler->getCommonMetaArray( $file );
52  $expected = array(
53  'ImageDescription' => 'Test file',
54  'XResolution' => '72/1',
55  'YResolution' => '72/1',
56  'ResolutionUnit' => 2,
57  'YCbCrPositioning' => 1,
58  'JPEGFileComment' => array(
59  'Created with GIMP',
60  ),
61  );
62 
63  $this->assertEquals( $res, $expected );
64  }
65 
66  private function dataFile( $name, $type ) {
67  return new UnregisteredLocalFile( false, $this->repo,
68  "mwstore://localtesting/data/$name", $type );
69  }
70 }
JpegTest\testJpegMetadataExtraction
testJpegMetadataExtraction()
Definition: JpegTest.php:37
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
FSRepo
A repository for files accessible via the local filesystem.
Definition: FSRepo.php:33
UnregisteredLocalFile
A file object referring to either a standalone local file, or a file in a local repository with no da...
Definition: UnregisteredLocalFile.php:36
JpegTest\testGetIndependentMetaArray
testGetIndependentMetaArray()
@covers JpegHandler::getCommonMetaArray
Definition: JpegTest.php:49
JpegTest\testInvalidFile
testInvalidFile()
Definition: JpegTest.php:31
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
JpegTest\$filePath
$filePath
Definition: JpegTest.php:7
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
JpegTest\dataFile
dataFile( $name, $type)
Definition: JpegTest.php:66
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
JpegTest
@covers JpegHandler
Definition: JpegTest.php:5
JpegHandler
JPEG specific handler.
Definition: Jpeg.php:33
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
FSFileBackend
Class for a file system (FS) based file backend.
Definition: FSFileBackend.php:41
MediaWikiTestCase\checkPHPExtension
checkPHPExtension( $extName)
Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded.
Definition: MediaWikiTestCase.php:1005
JpegTest\setUp
setUp()
Definition: JpegTest.php:9
ExifBitmapHandler\BROKEN_FILE
const BROKEN_FILE
Definition: ExifBitmap.php:31
$res
$res
Definition: database.txt:21
$type
$type
Definition: testCompression.php:46