MediaWiki REL1_32
IPTCTest.php
Go to the documentation of this file.
1<?php
2
7
11 public function testRecognizeUtf8() {
12 // utf-8 is the only one used in practise.
13 $res = IPTC::getCharset( "\x1b%G" );
14 $this->assertEquals( 'UTF-8', $res );
15 }
16
20 public function testIPTCParseNoCharset88591() {
21 // basically IPTC for keyword with value of 0xBC which is 1/4 in iso-8859-1
22 // This data doesn't specify a charset. We're supposed to guess
23 // (which basically means utf-8 if valid, windows 1252 (iso 8859-1) if not)
24 $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x06\x1c\x02\x19\x00\x01\xBC";
25 $res = IPTC::parse( $iptcData );
26 $this->assertEquals( [ '¼' ], $res['Keywords'] );
27 }
28
32 public function testIPTCParseNoCharset88591b() {
33 /* This one contains a sequence that's valid iso 8859-1 but not valid utf8 */
34 /* \xC3 = Ã, \xB8 = ¸ */
35 $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x09\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8";
36 $res = IPTC::parse( $iptcData );
37 $this->assertEquals( [ 'ÃÃø' ], $res['Keywords'] );
38 }
39
47 $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x11\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8"
48 . "\x1c\x01\x5A\x00\x03\x1B\x25\x47";
49 $res = IPTC::parse( $iptcData );
50 $this->assertEquals( [ 'ø' ], $res['Keywords'] );
51 }
52
56 public function testIPTCParseNoCharsetUTF8() {
57 $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x07\x1c\x02\x19\x00\x02¼";
58 $res = IPTC::parse( $iptcData );
59 $this->assertEquals( [ '¼' ], $res['Keywords'] );
60 }
61
66 public function testIPTCParseMulti() {
67 $iptcData = /* identifier */ "Photoshop 3.0\08BIM\4\4"
68 /* length */ . "\0\0\0\0\0\x0D"
69 . "\x1c\x02\x19" . "\x00\x01" . "\xBC"
70 . "\x1c\x02\x19" . "\x00\x02" . "\xBC\xBD";
71 $res = IPTC::parse( $iptcData );
72 $this->assertEquals( [ '¼', '¼½' ], $res['Keywords'] );
73 }
74
78 public function testIPTCParseUTF8() {
79 // This has the magic "\x1c\x01\x5A\x00\x03\x1B\x25\x47" which marks content as UTF8.
80 $iptcData =
81 "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x0F\x1c\x02\x19\x00\x02¼\x1c\x01\x5A\x00\x03\x1B\x25\x47";
82 $res = IPTC::parse( $iptcData );
83 $this->assertEquals( [ '¼' ], $res['Keywords'] );
84 }
85}
Media.
Definition IPTCTest.php:6
testIPTCParseNoCharset88591()
IPTC::parse.
Definition IPTCTest.php:20
testIPTCParseNoCharsetUTF8()
IPTC::parse.
Definition IPTCTest.php:56
testRecognizeUtf8()
IPTC::getCharset.
Definition IPTCTest.php:11
testIPTCParseNoCharset88591b()
IPTC::parse.
Definition IPTCTest.php:32
testIPTCParseMulti()
Testing something that has 2 values for keyword IPTC::parse.
Definition IPTCTest.php:66
testIPTCParseUTF8()
IPTC::parse.
Definition IPTCTest.php:78
testIPTCParseForcedUTFButInvalid()
Same as testIPTCParseNoCharset88591b, but forcing the charset to utf-8.
Definition IPTCTest.php:46
static parse( $rawData)
This takes the results of iptcparse() and puts it into a form that can be handled by mediawiki.
Definition IPTC.php:40
static getCharset( $tag)
take the value of 1:90 tag and returns a charset
Definition IPTC.php:478
$res
Definition database.txt:21
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:37