Merge "rdbms: avoid LoadBalancer::getConnection waste when using $groups"
[lhc/web/wiklou.git] / tests / phpunit / includes / title / TitleValueTest.php
index 4dbda74..bbeb068 100644 (file)
@@ -28,6 +28,7 @@ class TitleValueTest extends MediaWikiTestCase {
 
        public function goodConstructorProvider() {
                return [
+                       [ NS_MAIN, '', 'fragment', '', true, false ],
                        [ NS_USER, 'TestThis', 'stuff', '', true, false ],
                        [ NS_USER, 'TestThis', '', 'baz', false, true ],
                ];
@@ -58,7 +59,7 @@ class TitleValueTest extends MediaWikiTestCase {
 
                        [ NS_MAIN, 5, 'fragment', '' ],
                        [ NS_MAIN, null, 'fragment', '' ],
-                       [ NS_MAIN, '', 'fragment', '' ],
+                       [ NS_USER, '', 'fragment', '' ],
                        [ NS_MAIN, 'foo bar', '', '' ],
                        [ NS_MAIN, 'bar_', '', '' ],
                        [ NS_MAIN, '_foo', '', '' ],
@@ -78,7 +79,7 @@ class TitleValueTest extends MediaWikiTestCase {
         * @dataProvider badConstructorProvider
         */
        public function testConstructionErrors( $ns, $text, $fragment, $interwiki ) {
-               $this->setExpectedException( 'InvalidArgumentException' );
+               $this->setExpectedException( InvalidArgumentException::class );
                new TitleValue( $ns, $text, $fragment, $interwiki );
        }
 
@@ -116,4 +117,33 @@ class TitleValueTest extends MediaWikiTestCase {
 
                $this->assertEquals( $text, $title->getText() );
        }
+
+       public function provideTestToString() {
+               yield [
+                       new TitleValue( 0, 'Foo' ),
+                       '0:Foo'
+               ];
+               yield [
+                       new TitleValue( 1, 'Bar_Baz' ),
+                       '1:Bar_Baz'
+               ];
+               yield [
+                       new TitleValue( 9, 'JoJo', 'Frag' ),
+                       '9:JoJo#Frag'
+               ];
+               yield [
+                       new TitleValue( 200, 'tea', 'Fragment', 'wikicode' ),
+                       'wikicode:200:tea#Fragment'
+               ];
+       }
+
+       /**
+        * @dataProvider provideTestToString
+        */
+       public function testToString( TitleValue $value, $expected ) {
+               $this->assertSame(
+                       $expected,
+                       $value->__toString()
+               );
+       }
 }