Debian Codegraph @

tests/phpunit/includes/media/MediaHandlerIntegrationTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\MainConfigNames;
4
5 /**
6 * @group Media
7 */
8 class MediaHandlerIntegrationTest extends MediaWikiMediaTestCase {
9
10 /**
11 * @covers \MediaHandler::formatTag
12 * @covers \MediaHandler::formatMetadataHelper
13 */
14 public function testFormatMetadataHelper() {
15 $this->overrideConfigValue( MainConfigNames::LanguageCode, 'en' );
16 $testHandler = new class extends MediaHandler {
17 public function formatMetadata( $image, $context = false ) {
18 return $this->formatMetadataHelper( [
19 'UnitTestOverride' => 'abc',
20 'UnitTestDelete' => 'def',
21 'UnitTestOther' => '1234.5678',
22 ], $context );
23 }
24
25 protected function formatTag( $key, $vals, $context = false ) {
26 if ( $key === 'UnitTestOverride' ) {
27 return 'Override';
28 } elseif ( $key === 'UnitTestDelete' ) {
29 return null;
30 } else {
31 return false;
32 }
33 }
34
35 public function getParamMap() {
36 throw new LogicException( 'should never get here' );
37 }
38
39 public function validateParam( $name, $value ) {
40 throw new LogicException( 'should never get here' );
41 }
42
43 public function makeParamString( $params ) {
44 throw new LogicException( 'should never get here' );
45 }
46
47 public function parseParamString( $str ) {
48 throw new LogicException( 'should never get here' );
49 }
50
51 public function normaliseParams( $image, &$params ) {
52 throw new LogicException( 'should never get here' );
53 }
54
55 public function getImageSize( $image, $path ) {
56 throw new LogicException( 'should never get here' );
57 }
58
59 public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
60 throw new LogicException( 'should never get here' );
61 }
62 };
63 $file = $this->dataFile( 'Tux.svg', 'image/svg+xml' );
64 $result = $testHandler->formatMetadata( $file );
65 $this->assertEqualsCanonicalizing( [
66 'visible' => [
67 ],
68 'collapsed' => [
69 [
70 'id' => 'exif-unittestoverride',
71 'name' => 'unittestoverride',
72 // Note that formatTag overrode the formatted result here
73 'value' => 'Override'
74 ],
75 [
76 'id' => 'exif-unittestother',
77 'name' => 'unittestother',
78 // Note that this value went through Language::formatNum()
79 'value' => '1,234.5678'
80 ],
81 // Note that unittestdelete is missing as expected
82 ],
83 ], $result );
84 }
85 }