3 class TitleMethodsTest
extends MediaWikiTestCase
{
5 public function dataEquals() {
7 array( 'Main Page', 'Main Page', true ),
8 array( 'Main Page', 'Not The Main Page', false ),
9 array( 'Main Page', 'Project:Main Page', false ),
10 array( 'File:Example.png', 'Image:Example.png', true ),
11 array( 'Special:Version', 'Special:Version', true ),
12 array( 'Special:Version', 'Special:Recentchanges', false ),
13 array( 'Special:Version', 'Main Page', false ),
18 * @dataProvider dataEquals
20 public function testEquals( $titleA, $titleB, $expectedBool ) {
21 $titleA = Title
::newFromText( $titleA );
22 $titleB = Title
::newFromText( $titleB );
24 $this->assertEquals( $titleA->equals( $titleB ), $expectedBool );
25 $this->assertEquals( $titleB->equals( $titleA ), $expectedBool );
28 public function dataInNamespace() {
30 array( 'Main Page', NS_MAIN
, true ),
31 array( 'Main Page', NS_TALK
, false ),
32 array( 'Main Page', NS_USER
, false ),
33 array( 'User:Foo', NS_USER
, true ),
34 array( 'User:Foo', NS_USER_TALK
, false ),
35 array( 'User:Foo', NS_TEMPLATE
, false ),
36 array( 'User_talk:Foo', NS_USER_TALK
, true ),
37 array( 'User_talk:Foo', NS_USER
, false ),
42 * @dataProvider dataInNamespace
44 public function testInNamespace( $title, $ns, $expectedBool ) {
45 $title = Title
::newFromText( $title );
46 $this->assertEquals( $title->inNamespace( $ns ), $expectedBool );
49 public function testInNamespaces() {
50 $mainpage = Title
::newFromText( 'Main Page' );
51 $this->assertTrue( $mainpage->inNamespaces( NS_MAIN
, NS_USER
) );
52 $this->assertTrue( $mainpage->inNamespaces( array( NS_MAIN
, NS_USER
) ) );
53 $this->assertTrue( $mainpage->inNamespaces( array( NS_USER
, NS_MAIN
) ) );
54 $this->assertFalse( $mainpage->inNamespaces( array( NS_PROJECT
, NS_TEMPLATE
) ) );
57 public function dataHasSubjectNamespace() {
59 array( 'Main Page', NS_MAIN
, true ),
60 array( 'Main Page', NS_TALK
, true ),
61 array( 'Main Page', NS_USER
, false ),
62 array( 'User:Foo', NS_USER
, true ),
63 array( 'User:Foo', NS_USER_TALK
, true ),
64 array( 'User:Foo', NS_TEMPLATE
, false ),
65 array( 'User_talk:Foo', NS_USER_TALK
, true ),
66 array( 'User_talk:Foo', NS_USER
, true ),
71 * @dataProvider dataHasSubjectNamespace
73 public function testHasSubjectNamespace( $title, $ns, $expectedBool ) {
74 $title = Title
::newFromText( $title );
75 $this->assertEquals( $title->hasSubjectNamespace( $ns ), $expectedBool );