MediaWiki  1.29.2
TidyTest.php
Go to the documentation of this file.
1 <?php
2 
6 class TidyTest extends MediaWikiTestCase {
7 
8  protected function setUp() {
9  parent::setUp();
10  if ( !MWTidy::isEnabled() ) {
11  $this->markTestSkipped( 'Tidy not found' );
12  }
13  }
14 
18  public function testTidyWrapping( $expected, $text, $msg = '' ) {
19  $text = MWTidy::tidy( $text );
20  // We don't care about where Tidy wants to stick is <p>s
21  $text = trim( preg_replace( '#</?p>#', '', $text ) );
22  // Windows, we love you!
23  $text = str_replace( "\r", '', $text );
24  $this->assertEquals( $expected, $text, $msg );
25  }
26 
27  public static function provideTestWrapping() {
28  $testMathML = <<<'MathML'
29 <math xmlns="http://www.w3.org/1998/Math/MathML">
30  <mrow>
31  <mi>a</mi>
32  <mo>&InvisibleTimes;</mo>
33  <msup>
34  <mi>x</mi>
35  <mn>2</mn>
36  </msup>
37  <mo>+</mo>
38  <mi>b</mi>
39  <mo>&InvisibleTimes; </mo>
40  <mi>x</mi>
41  <mo>+</mo>
42  <mi>c</mi>
43  </mrow>
44  </math>
45 MathML;
46  return [
47  [
48  '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
49  '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
50  '<mw:editsection> should survive tidy'
51  ],
52  [
53  '<editsection page="foo" section="bar">foo</editsection>',
54  '<editsection page="foo" section="bar">foo</editsection>',
55  '<editsection> should survive tidy'
56  ],
57  [ '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ],
58  [ "<link foo=\"bar\" />\nfoo", '<link foo="bar"/>foo', '<link> should survive tidy' ],
59  [ "<meta foo=\"bar\" />\nfoo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ],
60  [ $testMathML, $testMathML, '<math> should survive tidy' ],
61  ];
62  }
63 }
TidyTest\setUp
setUp()
Definition: TidyTest.php:8
MWTidy\isEnabled
static isEnabled()
Definition: MWTidy.php:79
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
a
</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre >< span ></span >< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></pre ></div > ! end ! test Multiline< source/> in lists !input *< source > a b</source > *foo< source > a b</source > ! html< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! html tidy< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! end ! test Custom attributes !input< source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;"> var a
Definition: parserTests.txt:89
TidyTest\testTidyWrapping
testTidyWrapping( $expected, $text, $msg='')
provideTestWrapping
Definition: TidyTest.php:18
MediaWikiTestCase
Definition: MediaWikiTestCase.php:13
TidyTest
Parser.
Definition: TidyTest.php:6
c
type show c for details The hypothetical commands show w and show c should show the appropriate parts of the General Public License Of the commands you use may be called something other than show w and show c
Definition: COPYING.txt:321
TidyTest\provideTestWrapping
static provideTestWrapping()
Definition: TidyTest.php:27
MWTidy\tidy
static tidy( $text)
Interface with html tidy.
Definition: MWTidy.php:46