MediaWiki  REL1_31
IEUrlExtensionTest.php
Go to the documentation of this file.
1 <?php
2 
8 class IEUrlExtensionTest extends PHPUnit\Framework\TestCase {
9 
10  use MediaWikiCoversValidator;
11 
15  public function testSimple() {
16  $this->assertEquals(
17  'y',
19  'Simple extension'
20  );
21  }
22 
26  public function testSimpleNoExt() {
27  $this->assertEquals(
28  '',
30  'No extension'
31  );
32  }
33 
37  public function testEmpty() {
38  $this->assertEquals(
39  '',
41  'Empty string'
42  );
43  }
44 
48  public function testQuestionMark() {
49  $this->assertEquals(
50  '',
52  'Question mark only'
53  );
54  }
55 
59  public function testExtQuestionMark() {
60  $this->assertEquals(
61  'x',
63  'Extension then question mark'
64  );
65  }
66 
70  public function testQuestionMarkExt() {
71  $this->assertEquals(
72  'x',
74  'Question mark then extension'
75  );
76  }
77 
81  public function testInvalidChar() {
82  $this->assertEquals(
83  '',
85  'Extension with invalid character'
86  );
87  }
88 
92  public function testInvalidCharThenExtension() {
93  $this->assertEquals(
94  'x',
96  'Invalid character followed by an extension'
97  );
98  }
99 
103  public function testMultipleQuestionMarks() {
104  $this->assertEquals(
105  'c',
106  IEUrlExtension::findIE6Extension( 'a?b?.c?.d?e?f' ),
107  'Multiple question marks'
108  );
109  }
110 
114  public function testExeException() {
115  $this->assertEquals(
116  'd',
117  IEUrlExtension::findIE6Extension( 'a?b?.exe?.d?.e' ),
118  '.exe exception'
119  );
120  }
121 
125  public function testExeException2() {
126  $this->assertEquals(
127  'exe',
128  IEUrlExtension::findIE6Extension( 'a?b?.exe' ),
129  '.exe exception 2'
130  );
131  }
132 
136  public function testHash() {
137  $this->assertEquals(
138  '',
140  'Hash character preceding extension'
141  );
142  }
143 
147  public function testHash2() {
148  $this->assertEquals(
149  '',
151  'Hash character preceding extension 2'
152  );
153  }
154 
158  public function testDotAtEnd() {
159  $this->assertEquals(
160  '',
162  'Dot at end of string'
163  );
164  }
165 
169  public function testTwoDots() {
170  $this->assertEquals(
171  'z',
173  'Two dots'
174  );
175  }
176 
180  public function testScriptQuery() {
181  $this->assertEquals(
182  'php',
183  IEUrlExtension::findIE6Extension( 'example.php?foo=a&bar=b' ),
184  'Script with query'
185  );
186  }
187 
191  public function testEscapedScriptQuery() {
192  $this->assertEquals(
193  '',
194  IEUrlExtension::findIE6Extension( 'example%2Ephp?foo=a&bar=b' ),
195  'Script with urlencoded dot and query'
196  );
197  }
198 
202  public function testEscapedScriptQueryDot() {
203  $this->assertEquals(
204  'y',
205  IEUrlExtension::findIE6Extension( 'example%2Ephp?foo=a.x&bar=b.y' ),
206  'Script with urlencoded dot and query with dot'
207  );
208  }
209 }
IEUrlExtensionTest\testInvalidCharThenExtension
testInvalidCharThenExtension()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:92
IEUrlExtensionTest\testDotAtEnd
testDotAtEnd()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:158
IEUrlExtensionTest\testSimple
testSimple()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:15
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
IEUrlExtensionTest\testEmpty
testEmpty()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:37
IEUrlExtensionTest\testTwoDots
testTwoDots()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:169
IEUrlExtensionTest\testHash2
testHash2()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:147
IEUrlExtensionTest\testMultipleQuestionMarks
testMultipleQuestionMarks()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:103
IEUrlExtensionTest\testHash
testHash()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:136
IEUrlExtensionTest\testEscapedScriptQuery
testEscapedScriptQuery()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:191
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:37
IEUrlExtensionTest
Tests for IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:8
IEUrlExtensionTest\testQuestionMarkExt
testQuestionMarkExt()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:70
IEUrlExtensionTest\testQuestionMark
testQuestionMark()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:48
IEUrlExtensionTest\testExeException2
testExeException2()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:125
IEUrlExtensionTest\testInvalidChar
testInvalidChar()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:81
IEUrlExtensionTest\testEscapedScriptQueryDot
testEscapedScriptQueryDot()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:202
IEUrlExtensionTest\testExeException
testExeException()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:114
IEUrlExtensionTest\testSimpleNoExt
testSimpleNoExt()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:26
IEUrlExtensionTest\testScriptQuery
testScriptQuery()
IEUrlExtension::findIE6Extension.
Definition: IEUrlExtensionTest.php:180
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:59