MediaWiki  1.29.2
IEUrlExtensionTest.php
Go to the documentation of this file.
1 <?php
2 
8 class IEUrlExtensionTest extends PHPUnit_Framework_TestCase {
12  public function testSimple() {
13  $this->assertEquals(
14  'y',
16  'Simple extension'
17  );
18  }
19 
23  public function testSimpleNoExt() {
24  $this->assertEquals(
25  '',
27  'No extension'
28  );
29  }
30 
34  public function testEmpty() {
35  $this->assertEquals(
36  '',
38  'Empty string'
39  );
40  }
41 
45  public function testQuestionMark() {
46  $this->assertEquals(
47  '',
49  'Question mark only'
50  );
51  }
52 
56  public function testExtQuestionMark() {
57  $this->assertEquals(
58  'x',
60  'Extension then question mark'
61  );
62  }
63 
67  public function testQuestionMarkExt() {
68  $this->assertEquals(
69  'x',
71  'Question mark then extension'
72  );
73  }
74 
78  public function testInvalidChar() {
79  $this->assertEquals(
80  '',
82  'Extension with invalid character'
83  );
84  }
85 
89  public function testInvalidCharThenExtension() {
90  $this->assertEquals(
91  'x',
93  'Invalid character followed by an extension'
94  );
95  }
96 
100  public function testMultipleQuestionMarks() {
101  $this->assertEquals(
102  'c',
103  IEUrlExtension::findIE6Extension( 'a?b?.c?.d?e?f' ),
104  'Multiple question marks'
105  );
106  }
107 
111  public function testExeException() {
112  $this->assertEquals(
113  'd',
114  IEUrlExtension::findIE6Extension( 'a?b?.exe?.d?.e' ),
115  '.exe exception'
116  );
117  }
118 
122  public function testExeException2() {
123  $this->assertEquals(
124  'exe',
125  IEUrlExtension::findIE6Extension( 'a?b?.exe' ),
126  '.exe exception 2'
127  );
128  }
129 
133  public function testHash() {
134  $this->assertEquals(
135  '',
137  'Hash character preceding extension'
138  );
139  }
140 
144  public function testHash2() {
145  $this->assertEquals(
146  '',
148  'Hash character preceding extension 2'
149  );
150  }
151 
155  public function testDotAtEnd() {
156  $this->assertEquals(
157  '',
159  'Dot at end of string'
160  );
161  }
162 
166  public function testTwoDots() {
167  $this->assertEquals(
168  'z',
170  'Two dots'
171  );
172  }
173 
177  public function testScriptQuery() {
178  $this->assertEquals(
179  'php',
180  IEUrlExtension::findIE6Extension( 'example.php?foo=a&bar=b' ),
181  'Script with query'
182  );
183  }
184 
188  public function testEscapedScriptQuery() {
189  $this->assertEquals(
190  '',
191  IEUrlExtension::findIE6Extension( 'example%2Ephp?foo=a&bar=b' ),
192  'Script with urlencoded dot and query'
193  );
194  }
195 
199  public function testEscapedScriptQueryDot() {
200  $this->assertEquals(
201  'y',
202  IEUrlExtension::findIE6Extension( 'example%2Ephp?foo=a.x&bar=b.y' ),
203  'Script with urlencoded dot and query with dot'
204  );
205  }
206 }
IEUrlExtensionTest\testInvalidCharThenExtension
testInvalidCharThenExtension()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:89
IEUrlExtensionTest\testDotAtEnd
testDotAtEnd()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:155
IEUrlExtensionTest\testSimple
testSimple()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:12
IEUrlExtensionTest\testEmpty
testEmpty()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:34
IEUrlExtensionTest\testTwoDots
testTwoDots()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:166
IEUrlExtensionTest\testHash2
testHash2()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:144
IEUrlExtensionTest\testMultipleQuestionMarks
testMultipleQuestionMarks()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:100
IEUrlExtensionTest\testHash
testHash()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:133
IEUrlExtensionTest\testEscapedScriptQuery
testEscapedScriptQuery()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:188
php
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
IEUrlExtensionTest
Tests for IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:8
IEUrlExtensionTest\testQuestionMarkExt
testQuestionMarkExt()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:67
IEUrlExtensionTest\testQuestionMark
testQuestionMark()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:45
IEUrlExtensionTest\testExeException2
testExeException2()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:122
IEUrlExtensionTest\testInvalidChar
testInvalidChar()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:78
IEUrlExtensionTest\testEscapedScriptQueryDot
testEscapedScriptQueryDot()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:199
IEUrlExtensionTest\testExeException
testExeException()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:111
IEUrlExtensionTest\testSimpleNoExt
testSimpleNoExt()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:23
IEUrlExtensionTest\testScriptQuery
testScriptQuery()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:177
IEUrlExtension\findIE6Extension
static findIE6Extension( $url)
Determine what extension IE6 will infer from a certain query string.
Definition: IEUrlExtension.php:192
IEUrlExtensionTest\testExtQuestionMark
testExtQuestionMark()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:56