MediaWiki  1.23.6
TitleValueTest.php
Go to the documentation of this file.
1 <?php
29 
30  public function testConstruction() {
31  $title = new TitleValue( NS_USER, 'TestThis', 'stuff' );
32 
33  $this->assertEquals( NS_USER, $title->getNamespace() );
34  $this->assertEquals( 'TestThis', $title->getText() );
35  $this->assertEquals( 'stuff', $title->getFragment() );
36  }
37 
38  public function badConstructorProvider() {
39  return array(
40  array( 'foo', 'title', 'fragment' ),
41  array( null, 'title', 'fragment' ),
42  array( 2.3, 'title', 'fragment' ),
43 
44  array( NS_MAIN, 5, 'fragment' ),
45  array( NS_MAIN, null, 'fragment' ),
46  array( NS_MAIN, '', 'fragment' ),
47  array( NS_MAIN, 'foo bar', '' ),
48  array( NS_MAIN, 'bar_', '' ),
49  array( NS_MAIN, '_foo', '' ),
50  array( NS_MAIN, ' eek ', '' ),
51 
52  array( NS_MAIN, 'title', 5 ),
53  array( NS_MAIN, 'title', null ),
54  array( NS_MAIN, 'title', array() ),
55  );
56  }
57 
61  public function testConstructionErrors( $ns, $text, $fragment ) {
62  $this->setExpectedException( 'InvalidArgumentException' );
63  new TitleValue( $ns, $text, $fragment );
64  }
65 
66  public function fragmentTitleProvider() {
67  return array(
68  array( new TitleValue( NS_MAIN, 'Test' ), 'foo' ),
69  array( new TitleValue( NS_TALK, 'Test', 'foo' ), '' ),
70  array( new TitleValue( NS_CATEGORY, 'Test', 'foo' ), 'bar' ),
71  );
72  }
73 
77  public function testCreateFragmentTitle( TitleValue $title, $fragment ) {
78  $fragmentTitle = $title->createFragmentTitle( $fragment );
79 
80  $this->assertEquals( $title->getNamespace(), $fragmentTitle->getNamespace() );
81  $this->assertEquals( $title->getText(), $fragmentTitle->getText() );
82  $this->assertEquals( $fragment, $fragmentTitle->getFragment() );
83  }
84 
85  public function getTextProvider() {
86  return array(
87  array( 'Foo', 'Foo' ),
88  array( 'Foo_Bar', 'Foo Bar' ),
89  );
90  }
91 
95  public function testGetText( $dbkey, $text ) {
96  $title = new TitleValue( NS_MAIN, $dbkey );
97 
98  $this->assertEquals( $text, $title->getText() );
99  }
100 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
TitleValueTest\testConstruction
testConstruction()
Definition: TitleValueTest.php:30
TitleValueTest\badConstructorProvider
badConstructorProvider()
Definition: TitleValueTest.php:38
TitleValueTest\testCreateFragmentTitle
testCreateFragmentTitle(TitleValue $title, $fragment)
@dataProvider fragmentTitleProvider
Definition: TitleValueTest.php:77
TitleValueTest\getTextProvider
getTextProvider()
Definition: TitleValueTest.php:85
NS_MAIN
const NS_MAIN
Definition: Defines.php:79
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
TitleValueTest\testConstructionErrors
testConstructionErrors( $ns, $text, $fragment)
@dataProvider badConstructorProvider
Definition: TitleValueTest.php:61
TitleValueTest\testGetText
testGetText( $dbkey, $text)
@dataProvider getTextProvider
Definition: TitleValueTest.php:95
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:93
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
TitleValueTest
@covers TitleValue
Definition: TitleValueTest.php:28
NS_USER
const NS_USER
Definition: Defines.php:81
NS_TALK
const NS_TALK
Definition: Defines.php:80
TitleValueTest\fragmentTitleProvider
fragmentTitleProvider()
Definition: TitleValueTest.php:66
TitleValue
Represents a page (or page fragment) title within MediaWiki.
Definition: TitleValue.php:36