MediaWiki  1.28.0
ParserOutputTest.php
Go to the documentation of this file.
1 <?php
2 
8 
9  public static function provideIsLinkInternal() {
10  return [
11  // Different domains
12  [ false, 'http://example.org', 'http://mediawiki.org' ],
13  // Same domains
14  [ true, 'http://example.org', 'http://example.org' ],
15  [ true, 'https://example.org', 'https://example.org' ],
16  [ true, '//example.org', '//example.org' ],
17  // Same domain different cases
18  [ true, 'http://example.org', 'http://EXAMPLE.ORG' ],
19  // Paths, queries, and fragments are not relevant
20  [ true, 'http://example.org', 'http://example.org/wiki/Main_Page' ],
21  [ true, 'http://example.org', 'http://example.org?my=query' ],
22  [ true, 'http://example.org', 'http://example.org#its-a-fragment' ],
23  // Different protocols
24  [ false, 'http://example.org', 'https://example.org' ],
25  [ false, 'https://example.org', 'http://example.org' ],
26  // Protocol relative servers always match http and https links
27  [ true, '//example.org', 'http://example.org' ],
28  [ true, '//example.org', 'https://example.org' ],
29  // But they don't match strange things like this
30  [ false, '//example.org', 'irc://example.org' ],
31  ];
32  }
33 
39  public function testIsLinkInternal( $shouldMatch, $server, $url ) {
40  $this->assertEquals( $shouldMatch, ParserOutput::isLinkInternal( $server, $url ) );
41  }
42 
47  public function testExtensionData() {
48  $po = new ParserOutput();
49 
50  $po->setExtensionData( "one", "Foo" );
51 
52  $this->assertEquals( "Foo", $po->getExtensionData( "one" ) );
53  $this->assertNull( $po->getExtensionData( "spam" ) );
54 
55  $po->setExtensionData( "two", "Bar" );
56  $this->assertEquals( "Foo", $po->getExtensionData( "one" ) );
57  $this->assertEquals( "Bar", $po->getExtensionData( "two" ) );
58 
59  $po->setExtensionData( "one", null );
60  $this->assertNull( $po->getExtensionData( "one" ) );
61  $this->assertEquals( "Bar", $po->getExtensionData( "two" ) );
62  }
63 
70  public function testProperties() {
71  $po = new ParserOutput();
72 
73  $po->setProperty( 'foo', 'val' );
74 
75  $properties = $po->getProperties();
76  $this->assertEquals( $po->getProperty( 'foo' ), 'val' );
77  $this->assertEquals( $properties['foo'], 'val' );
78 
79  $po->setProperty( 'foo', 'second val' );
80 
81  $properties = $po->getProperties();
82  $this->assertEquals( $po->getProperty( 'foo' ), 'second val' );
83  $this->assertEquals( $properties['foo'], 'second val' );
84 
85  $po->unsetProperty( 'foo' );
86 
87  $properties = $po->getProperties();
88  $this->assertEquals( $po->getProperty( 'foo' ), false );
89  $this->assertArrayNotHasKey( 'foo', $properties );
90  }
91 
92 }
testExtensionData()
ParserOutput::setExtensionData ParserOutput::getExtensionData.
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
Database ^— trigger DB shadowing because we are using Title magic.
static isLinkInternal($internal, $url)
Checks, if a url is pointing to the own server.
testIsLinkInternal($shouldMatch, $server, $url)
Test to make sure ParserOutput::isLinkInternal behaves properly provideIsLinkInternal ParserOutput::i...
static provideIsLinkInternal()
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
testProperties()
ParserOutput::setProperty ParserOutput::getProperty ParserOutput::unsetProperty ParserOutput::getProp...