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