MediaWiki  1.23.1
IPTCTest.php
Go to the documentation of this file.
1 <?php
2 
3 class IPTCTest extends MediaWikiTestCase {
4 
8  public function testRecognizeUtf8() {
9  // utf-8 is the only one used in practise.
10  $res = IPTC::getCharset( "\x1b%G" );
11  $this->assertEquals( 'UTF-8', $res );
12  }
13 
17  public function testIPTCParseNoCharset88591() {
18  // basically IPTC for keyword with value of 0xBC which is 1/4 in iso-8859-1
19  // This data doesn't specify a charset. We're supposed to guess
20  // (which basically means utf-8 if valid, windows 1252 (iso 8859-1) if not)
21  $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x06\x1c\x02\x19\x00\x01\xBC";
22  $res = IPTC::Parse( $iptcData );
23  $this->assertEquals( array( '¼' ), $res['Keywords'] );
24  }
25 
29  public function testIPTCParseNoCharset88591b() {
30  /* This one contains a sequence that's valid iso 8859-1 but not valid utf8 */
31  /* \xC3 = Ã, \xB8 = ¸ */
32  $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x09\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8";
33  $res = IPTC::Parse( $iptcData );
34  $this->assertEquals( array( 'ÃÃø' ), $res['Keywords'] );
35  }
36 
44  $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x11\x1c\x02\x19\x00\x04\xC3\xC3\xC3\xB8"
45  . "\x1c\x01\x5A\x00\x03\x1B\x25\x47";
46  $res = IPTC::Parse( $iptcData );
47  $this->assertEquals( array( 'ø' ), $res['Keywords'] );
48  }
49 
53  public function testIPTCParseNoCharsetUTF8() {
54  $iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x07\x1c\x02\x19\x00\x02¼";
55  $res = IPTC::Parse( $iptcData );
56  $this->assertEquals( array( '¼' ), $res['Keywords'] );
57  }
58 
63  public function testIPTCParseMulti() {
64  $iptcData = /* identifier */ "Photoshop 3.0\08BIM\4\4"
65  /* length */ . "\0\0\0\0\0\x0D"
66  . "\x1c\x02\x19" . "\x00\x01" . "\xBC"
67  . "\x1c\x02\x19" . "\x00\x02" . "\xBC\xBD";
68  $res = IPTC::Parse( $iptcData );
69  $this->assertEquals( array( '¼', '¼½' ), $res['Keywords'] );
70  }
71 
75  public function testIPTCParseUTF8() {
76  // This has the magic "\x1c\x01\x5A\x00\x03\x1B\x25\x47" which marks content as UTF8.
77  $iptcData = "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";
78  $res = IPTC::Parse( $iptcData );
79  $this->assertEquals( array( '¼' ), $res['Keywords'] );
80  }
81 }
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
IPTCTest\testIPTCParseNoCharset88591b
testIPTCParseNoCharset88591b()
@covers IPTC::Parse
Definition: IPTCTest.php:29
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
IPTC\getCharset
static getCharset( $tag)
take the value of 1:90 tag and returns a charset
Definition: IPTC.php:478
IPTCTest\testIPTCParseUTF8
testIPTCParseUTF8()
@covers IPTC::Parse
Definition: IPTCTest.php:75
IPTCTest\testIPTCParseNoCharset88591
testIPTCParseNoCharset88591()
@covers IPTC::Parse
Definition: IPTCTest.php:17
IPTCTest
Definition: IPTCTest.php:3
IPTCTest\testIPTCParseForcedUTFButInvalid
testIPTCParseForcedUTFButInvalid()
Same as testIPTCParseNoCharset88591b, but forcing the charset to utf-8.
Definition: IPTCTest.php:43
IPTCTest\testIPTCParseNoCharsetUTF8
testIPTCParseNoCharsetUTF8()
@covers IPTC::Parse
Definition: IPTCTest.php:53
IPTCTest\testIPTCParseMulti
testIPTCParseMulti()
Testing something that has 2 values for keyword @covers IPTC::Parse.
Definition: IPTCTest.php:63
$res
$res
Definition: database.txt:21
IPTCTest\testRecognizeUtf8
testRecognizeUtf8()
@covers IPTC::getCharset
Definition: IPTCTest.php:8