public function goodConstructorProvider() {
return [
+ [ NS_MAIN, '', 'fragment', '', true, false ],
[ NS_USER, 'TestThis', 'stuff', '', true, false ],
[ NS_USER, 'TestThis', '', 'baz', false, true ],
];
[ NS_MAIN, 5, 'fragment', '' ],
[ NS_MAIN, null, 'fragment', '' ],
- [ NS_MAIN, '', 'fragment', '' ],
+ [ NS_USER, '', 'fragment', '' ],
[ NS_MAIN, 'foo bar', '', '' ],
[ NS_MAIN, 'bar_', '', '' ],
[ NS_MAIN, '_foo', '', '' ],
* @dataProvider badConstructorProvider
*/
public function testConstructionErrors( $ns, $text, $fragment, $interwiki ) {
- $this->setExpectedException( 'InvalidArgumentException' );
+ $this->setExpectedException( InvalidArgumentException::class );
new TitleValue( $ns, $text, $fragment, $interwiki );
}
$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()
+ );
+ }
}