MediaWiki  1.29.1
InstallDocFormatterTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  * To change this template, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 
12  public function testFormat( $expected, $unformattedText, $message = '' ) {
13  $this->assertEquals(
14  $expected,
15  InstallDocFormatter::format( $unformattedText ),
16  $message
17  );
18  }
19 
23  public static function provideDocFormattingTests() {
24  # Format: (expected string, unformattedText string, optional message)
25  return [
26  # Escape some wikitext
27  [ 'Install &lt;tag>', 'Install <tag>', 'Escaping <' ],
28  [ 'Install &#123;&#123;template}}', 'Install {{template}}', 'Escaping [[' ],
29  [ 'Install &#91;&#91;page]]', 'Install [[page]]', 'Escaping {{' ],
30  [ 'Install &#95;&#95;TOC&#95;&#95;', 'Install __TOC__', 'Escaping __' ],
31  [ 'Install ', "Install \r", 'Removing \r' ],
32 
33  # Transform \t{1,2} into :{1,2}
34  [ ':One indentation', "\tOne indentation", 'Replacing a single \t' ],
35  [ '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ],
36 
37  # Transform 'T123' links
38  [
39  '<span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>',
40  'T123', 'Testing T123 links' ],
41  [
42  'bug <span class="config-plainlink">[https://phabricator.wikimedia.org/T123 T123]</span>',
43  'bug T123', 'Testing bug T123 links' ],
44  [
45  '(<span class="config-plainlink">[https://phabricator.wikimedia.org/T987654 T987654]</span>)',
46  '(T987654)', 'Testing (T987654) links' ],
47 
48  # "Tabc" shouldn't work
49  [ 'Tfoobar', 'Tfoobar', "Don't match T followed by non-digits" ],
50  [ 'T!!fakefake!!', 'T!!fakefake!!', "Don't match T followed by non-digits" ],
51 
52  # Transform 'bug 123' links
53  [
54  '<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>',
55  'bug 123', 'Testing bug 123 links' ],
56  [
57  '(<span class="config-plainlink">[https://bugzilla.wikimedia.org/987654 bug 987654]</span>)',
58  '(bug 987654)', 'Testing (bug 987654) links' ],
59 
60  # "bug abc" shouldn't work
61  [ 'bug foobar', 'bug foobar', "Don't match bug followed by non-digits" ],
62  [ 'bug !!fakefake!!', 'bug !!fakefake!!', "Don't match bug followed by non-digits" ],
63 
64  # Transform '$wgFooBar' links
65  [
66  '<span class="config-plainlink">'
67  . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar $wgFooBar]</span>',
68  '$wgFooBar', 'Testing basic $wgFooBar' ],
69  [
70  '<span class="config-plainlink">'
71  . '[https://www.mediawiki.org/wiki/Manual:$wgFooBar45 $wgFooBar45]</span>',
72  '$wgFooBar45', 'Testing $wgFooBar45 (with numbers)' ],
73  [
74  '<span class="config-plainlink">'
75  . '[https://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>',
76  '$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ],
77 
78  # Icky variables that shouldn't link
79  [
80  '$myAwesomeVariable',
81  '$myAwesomeVariable',
82  'Testing $myAwesomeVariable (not starting with $wg)'
83  ],
84  [ '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ],
85  ];
86  }
87 }
InstallDocFormatterTest
Definition: InstallDocFormatterTest.php:7
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
MediaWikiTestCase
Definition: MediaWikiTestCase.php:13
InstallDocFormatterTest\provideDocFormattingTests
static provideDocFormattingTests()
Provider for testFormat()
Definition: InstallDocFormatterTest.php:23
InstallDocFormatterTest\testFormat
testFormat( $expected, $unformattedText, $message='')
InstallDocFormatter::format provideDocFormattingTests.
Definition: InstallDocFormatterTest.php:12
InstallDocFormatter\format
static format( $text)
Definition: InstallDocFormatter.php:24