assertInstanceOf( 'Linker', $instance ); } /** * @covers ::smwfNormalTitleDBKey * @test smwfNormalTitleDBKey * * @since 1.9 */ public function testSmwfNormalTitleDBKey() { $result = smwfNormalTitleDBKey( ' foo bar ' ); // Globals are ... but it can't be invoke ... well make my day $expected = $GLOBALS['wgCapitalLinks'] ? 'Foo_bar' : 'foo_bar'; $this->assertEquals( $expected, $result ); } /** * @covers ::smwfHTMLtoUTF8 * @test smwfHTMLtoUTF8 * * @since 1.9 */ public function testSmwfHTMLtoUTF8() { $result = smwfHTMLtoUTF8( "\xc4\x88io bonas dans l'\xc3\xa9cole, Ĉio bonas dans l'école!" ); $expected = "Ĉio bonas dans l'école, Ĉio bonas dans l'école!"; $this->assertEquals( $expected, $result ); } /** * @test Test if global functions are accessible * @dataProvider getGlobalFunctionsProvider * * @param $function */ public function testGlobalFunctionsAccessibility( $function ) { $this->assertTrue( function_exists( $function ) ); } /** * @covers ::smwfEncodeMessages * @test smwfEncodeMessages * @dataProvider getEncodeMessagesDataProvider * * @param $message * @param $type * @param $separator * @param $escape */ public function testSmwfEncodeMessages( $message, $type, $separator, $escape ) { $results = smwfEncodeMessages( $message ); $this->assertFalse( $results === null ); $this->assertTrue( is_string( $results ) ); $results = smwfEncodeMessages( $message, $type ); $this->assertFalse( $results === null ); $this->assertTrue( is_string( $results ) ); $results = smwfEncodeMessages( $message, $type, $separator ); $this->assertFalse( $results === null ); $this->assertTrue( is_string( $results ) ); $results = smwfEncodeMessages( $message, $type, $separator, $escape ); $this->assertFalse( $results === null ); $this->assertTrue( is_string( $results ) ); } public function testSmwfCacheKeyOnPrefixedNamespace() { $this->assertEquals( smwfCacheKey( 'foo', 'bar' ), smwfCacheKey( ':foo', 'bar' ) ); } public function testSmwfContLang() { $this->assertInstanceOf( '\SMW\Localizer\LocalLanguage\LocalLanguage', smwfContLang() ); } /** * Provides available global functions * * @return array */ public function getGlobalFunctionsProvider() { return [ [ 'smwfNormalTitleDBKey' ], [ 'smwfXMLContentEncode' ], [ 'smwfHTMLtoUTF8' ], [ 'smwfEncodeMessages' ], [ 'smwfGetStore' ], [ 'smwfGetLinker' ], ]; } /** * Provides messages * * @return array */ public function getEncodeMessagesDataProvider() { return [ [ [ '', '', '' ], '', '', true ], [ [ 'abc', 'ABC', 'Test' ], '', '', true ], [ [ 'abc', 'ABC', 'Test' ], 'warning', '', true ], [ [ 'abc', 'ABC', 'Test' ], 'info', ',', false ], [ [ 'abc', 'ABC', 'Test' ], null, ',', false ], [ [ 'abc', 'ABC', 'Test' ], 'Test', ',', true ], ]; } }