From 2e44b49a2db3026050b136de9b00f749dd3ff939 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 25 Apr 2014 06:26:49 +0200 Subject: Update to MediaWiki 1.22.6 --- tests/phpunit/includes/site/SiteTest.php | 296 ------------------------------- 1 file changed, 296 deletions(-) delete mode 100644 tests/phpunit/includes/site/SiteTest.php (limited to 'tests/phpunit/includes/site/SiteTest.php') diff --git a/tests/phpunit/includes/site/SiteTest.php b/tests/phpunit/includes/site/SiteTest.php deleted file mode 100644 index 29c1ff33..00000000 --- a/tests/phpunit/includes/site/SiteTest.php +++ /dev/null @@ -1,296 +0,0 @@ - - */ -class SiteTest extends MediaWikiTestCase { - - public function instanceProvider() { - return $this->arrayWrap( TestSites::getSites() ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::getInterwikiIds - */ - public function testGetInterwikiIds( Site $site ) { - $this->assertInternalType( 'array', $site->getInterwikiIds() ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::getNavigationIds - */ - public function testGetNavigationIds( Site $site ) { - $this->assertInternalType( 'array', $site->getNavigationIds() ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::addNavigationId - */ - public function testAddNavigationId( Site $site ) { - $site->addNavigationId( 'foobar' ); - $this->assertTrue( in_array( 'foobar', $site->getNavigationIds(), true ) ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::addInterwikiId - */ - public function testAddInterwikiId( Site $site ) { - $site->addInterwikiId( 'foobar' ); - $this->assertTrue( in_array( 'foobar', $site->getInterwikiIds(), true ) ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::getLanguageCode - */ - public function testGetLanguageCode( Site $site ) { - $this->assertTypeOrValue( 'string', $site->getLanguageCode(), null ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::setLanguageCode - */ - public function testSetLanguageCode( Site $site ) { - $site->setLanguageCode( 'en' ); - $this->assertEquals( 'en', $site->getLanguageCode() ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::normalizePageName - */ - public function testNormalizePageName( Site $site ) { - $this->assertInternalType( 'string', $site->normalizePageName( 'Foobar' ) ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::getGlobalId - */ - public function testGetGlobalId( Site $site ) { - $this->assertTypeOrValue( 'string', $site->getGlobalId(), null ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::setGlobalId - */ - public function testSetGlobalId( Site $site ) { - $site->setGlobalId( 'foobar' ); - $this->assertEquals( 'foobar', $site->getGlobalId() ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::getType - */ - public function testGetType( Site $site ) { - $this->assertInternalType( 'string', $site->getType() ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::getPath - */ - public function testGetPath( Site $site ) { - $this->assertTypeOrValue( 'string', $site->getPath( 'page_path' ), null ); - $this->assertTypeOrValue( 'string', $site->getPath( 'file_path' ), null ); - $this->assertTypeOrValue( 'string', $site->getPath( 'foobar' ), null ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::getAllPaths - */ - public function testGetAllPaths( Site $site ) { - $this->assertInternalType( 'array', $site->getAllPaths() ); - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::setPath - * @covers Site::removePath - */ - public function testSetAndRemovePath( Site $site ) { - $count = count( $site->getAllPaths() ); - - $site->setPath( 'spam', 'http://www.wikidata.org/$1' ); - $site->setPath( 'spam', 'http://www.wikidata.org/foo/$1' ); - $site->setPath( 'foobar', 'http://www.wikidata.org/bar/$1' ); - - $this->assertEquals( $count + 2, count( $site->getAllPaths() ) ); - - $this->assertInternalType( 'string', $site->getPath( 'foobar' ) ); - $this->assertEquals( 'http://www.wikidata.org/foo/$1', $site->getPath( 'spam' ) ); - - $site->removePath( 'spam' ); - $site->removePath( 'foobar' ); - - $this->assertEquals( $count, count( $site->getAllPaths() ) ); - - $this->assertNull( $site->getPath( 'foobar' ) ); - $this->assertNull( $site->getPath( 'spam' ) ); - } - - /** - * @covers Site::setLinkPath - */ - public function testSetLinkPath() { - $site = new Site(); - $path = "TestPath/$1"; - - $site->setLinkPath( $path ); - $this->assertEquals( $path, $site->getLinkPath() ); - } - - /** - * @covers Site::getLinkPathType - */ - public function testGetLinkPathType() { - $site = new Site(); - - $path = 'TestPath/$1'; - $site->setLinkPath( $path ); - $this->assertEquals( $path, $site->getPath( $site->getLinkPathType() ) ); - - $path = 'AnotherPath/$1'; - $site->setPath( $site->getLinkPathType(), $path ); - $this->assertEquals( $path, $site->getLinkPath() ); - } - - /** - * @covers Site::setPath - */ - public function testSetPath() { - $site = new Site(); - - $path = 'TestPath/$1'; - $site->setPath( 'foo', $path ); - - $this->assertEquals( $path, $site->getPath( 'foo' ) ); - } - - /** - * @covers Site::setPath - * @covers Site::getProtocol - */ - public function testProtocolRelativePath() { - $site = new Site(); - - $type = $site->getLinkPathType(); - $path = '//acme.com/'; // protocol-relative URL - $site->setPath( $type, $path ); - - $this->assertEquals( '', $site->getProtocol() ); - } - - public static function provideGetPageUrl() { - //NOTE: the assumption that the URL is built by replacing $1 - // with the urlencoded version of $page - // is true for Site but not guaranteed for subclasses. - // Subclasses need to override this provider appropriately. - - return array( - array( #0 - 'http://acme.test/TestPath/$1', - 'Foo', - '/TestPath/Foo', - ), - array( #1 - 'http://acme.test/TestScript?x=$1&y=bla', - 'Foo', - 'TestScript?x=Foo&y=bla', - ), - array( #2 - 'http://acme.test/TestPath/$1', - 'foo & bar/xyzzy (quux-shmoox?)', - '/TestPath/foo%20%26%20bar%2Fxyzzy%20%28quux-shmoox%3F%29', - ), - ); - } - - /** - * @dataProvider provideGetPageUrl - * @covers Site::getPageUrl - */ - public function testGetPageUrl( $path, $page, $expected ) { - $site = new Site(); - - //NOTE: the assumption that getPageUrl is based on getLinkPath - // is true for Site but not guaranteed for subclasses. - // Subclasses need to override this test case appropriately. - $site->setLinkPath( $path ); - $this->assertContains( $path, $site->getPageUrl() ); - - $this->assertContains( $expected, $site->getPageUrl( $page ) ); - } - - protected function assertTypeOrFalse( $type, $value ) { - if ( $value === false ) { - $this->assertTrue( true ); - } else { - $this->assertInternalType( $type, $value ); - } - } - - /** - * @dataProvider instanceProvider - * @param Site $site - * @covers Site::serialize - * @covers Site::unserialize - */ - public function testSerialization( Site $site ) { - $this->assertInstanceOf( 'Serializable', $site ); - - $serialization = serialize( $site ); - $newInstance = unserialize( $serialization ); - - $this->assertInstanceOf( 'Site', $newInstance ); - - $this->assertEquals( $serialization, serialize( $newInstance ) ); - } -} -- cgit v1.2.2