MediaWiki  1.29.1
Go to the documentation of this file.
1 <?php
8  protected function setUp() {
9  parent::setUp();
11  $this->checkPHPExtension( 'exif' );
12  $this->setMwGlobals( 'wgShowEXIF', true );
13  }
18  public function testInvalidDate() {
19  $file = $this->dataFile( 'broken_exif_date.jpg', 'image/jpeg' );
21  // Throws an error if bug hit
22  $meta = $file->formatMetadata();
23  $this->assertNotEquals( false, $meta, 'Valid metadata extracted' );
25  // Find date exif entry
26  $this->assertArrayHasKey( 'visible', $meta );
27  $dateIndex = null;
28  foreach ( $meta['visible'] as $i => $data ) {
29  if ( $data['id'] == 'exif-datetimeoriginal' ) {
30  $dateIndex = $i;
31  }
32  }
33  $this->assertNotNull( $dateIndex, 'Date entry exists in metadata' );
34  $this->assertEquals( '0000:01:00 00:02:27',
35  $meta['visible'][$dateIndex]['value'],
36  'File with invalid date metadata (T31471)' );
37  }
46  $formatMetadata = new FormatMetadata();
47  $class = new ReflectionClass( 'FormatMetadata' );
48  $method = $class->getMethod( 'resolveMultivalueValue' );
49  $method->setAccessible( true );
50  $actualInput = $method->invoke( $formatMetadata, $input );
51  $this->assertEquals( $output, $actualInput );
52  }
54  public function provideResolveMultivalueValue() {
55  return [
56  'nonArray' => [
57  'foo',
58  'foo'
59  ],
60  'multiValue' => [
61  [ 'first', 'second', 'third', '_type' => 'ol' ],
62  'first'
63  ],
64  'noType' => [
65  [ 'first', 'second', 'third' ],
66  'first'
67  ],
68  'typeFirst' => [
69  [ '_type' => 'ol', 'first', 'second', 'third' ],
70  'first'
71  ],
72  'multilang' => [
73  [
74  'en' => 'first',
75  'de' => 'Erste',
76  '_type' => 'lang'
77  ],
78  [
79  'en' => 'first',
80  'de' => 'Erste',
81  '_type' => 'lang'
82  ],
83  ],
84  'multilang-multivalue' => [
85  [
86  'en' => [ 'first', 'second' ],
87  'de' => [ 'Erste', 'Zweite' ],
88  '_type' => 'lang'
89  ],
90  [
91  'en' => 'first',
92  'de' => 'Erste',
93  '_type' => 'lang'
94  ],
95  ],
96  ];
97  }
98 }
testResolveMultivalueValue( $input, $output)
Definition: FormatMetadataTest.php:45
Definition: FormatMetadataTest.php:6
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Specificly for testing Media handlers.
Definition: MediaWikiMediaTestCase.php:5
Definition: FormatMetadataTest.php:18
if(is_array( $mode)) switch( $mode) $input
Definition: postprocess-phan.php:141
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:658
dataFile( $name, $type=null)
Utility function: Get a new file object for a file on disk but not actually in db.
Definition: MediaWikiMediaTestCase.php:76
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
Definition: hooks.txt:1049
Format Image metadata values into a human readable form.
Definition: FormatMetadata.php:50
Definition: FormatMetadataTest.php:54
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
checkPHPExtension( $extName)
Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded.
Definition: MediaWikiTestCase.php:1717
Definition: FormatMetadataTest.php:8