From c099e759ca8311085cc158c58fe84ba5ec04555f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 23 May 2011 20:24:09 +0000 Subject: [PATCH] Follow-up to r88667; finish reverting bogus test cases from r87964. It looks like these cases need to be re-added, but correctly; for instance getLocalUrl() **DOES NOT** return something in $wgArticlePath space when an action is given that's not view. It **MUST** return the matching $wgActionPath or else use $wgScript directly, to ensure that URL structuring rules & security rules are followed. --- tests/phpunit/includes/TitleTest.php | 104 --------------------------- 1 file changed, 104 deletions(-) diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index e322293169..c128fdd8cc 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -15,108 +15,4 @@ class TitleTest extends MediaWikiTestCase { } } - /** - * Helper to test getLocalURL - * - * @cover Title:getLocalURL - */ - function assertGetLocalURL( $expected, $dbkey, $query, $articlepath, $actionpaths = array(), $variant = false ) - { - global $wgArticlePath; - $wgArticlePath = $articlepath; - global $wgActionPaths; - $wgActionPaths = $actionpaths; - - $t = Title::newFromDBKey( $dbkey ); - - $this->assertEquals( $expected, $t->getLocalURL( $query, $variant ) ); - } - - /** - * @dataProvider provider1 - * @cover Title:getLocalURL - */ - function testGetLocalUrl( $expected, $dbkey, $query ) - { - $this->assertGetLocalURL( $expected, $dbkey, $query, '/wiki/$1' ); - } - - function provider1() - { - return array( - array( '/wiki/Recentchanges', 'Recentchanges', '' ), - array( '/wiki/Recentchanges?foo=2', 'Recentchanges', 'foo=2' ), - array( '/wiki/Recentchanges?foo=A&bar=1', 'Recentchanges', 'foo=A&bar=1' ), - ); - } - - - /** - * @dataProvider provider2 - * @cover Title:getLocalURL - */ - function testGetLocalUrlWithArticlePath( $expected, $dbkey, $query, $actions ) - { - $this->assertGetLocalURL( $expected, $dbkey, $query, '/wiki/view/$1', $actions ); - } - - function provider2() - { - return array( - array( '/wiki/view/Recentchanges', 'Recentchanges', '', array( ) ), - array( '/wiki/view/Recentchanges', 'Recentchanges', '', array( 'view' => 'OH MEN' ) ), - array( '/wiki/view/Recentchanges', 'Recentchanges', '', array( 'view' => '/wiki/view/$1' ) ), - array( '/wiki/view/Recentchanges?foo=2', 'Recentchanges', 'foo=2', array( 'view' => '/wiki/view/$1' ) ), - array( '/wiki/view/Recentchanges?foo=A&bar=1', 'Recentchanges', 'foo=A&bar=1', array() ), - ); - } - - - /** - * @dataProvider provider3 - * @cover Title:getLocalURL - */ - function testGetLocalUrlWithActionPaths( $expected, $dbkey, $query ) - { - $actions = array( 'edit' => '/wiki/edit/$1' ); - $this->assertGetLocalURL( $expected, $dbkey, $query, '/wiki/view/$1', $actions ); - } - - function provider3() { - return array( - array( '/wiki/view/Recentchanges', 'Recentchanges', ''), - array( '/wiki/edit/Recentchanges', 'Recentchanges', 'action=edit' ), - array( '/wiki/edit/Recentchanges?foo=2', 'Recentchanges', 'action=edit&foo=2' ), - array( '/wiki/edit/Recentchanges?foo=2', 'Recentchanges', 'foo=2&action=edit' ), - array( '/wiki/view/Recentchanges?foo=A&bar=1', 'Recentchanges', 'foo=A&bar=1' ), - array( '/wiki/edit/Recentchanges?foo=A&bar=1', 'Recentchanges', 'foo=A&bar=1&action=edit' ), - array( '/wiki/edit/Recentchanges?foo=A&bar=1', 'Recentchanges', 'foo=A&action=edit&bar=1' ), - array( '/wiki/edit/Recentchanges?foo=A&bar=1', 'Recentchanges', 'action=edit&foo=A&bar=1' ), - - # @todo FIXME: The next two are equals but need investigation: - array( '/wiki/edit/Recentchanges', 'Recentchanges', 'action=view&action=edit' ), - array( '/wiki/view/Recentchanges?action=edit&action=view', 'Recentchanges', 'action=edit&action=view' ), - ); - } - - /** - * @dataProvider provider4 - * @cover Title:getLocalURL - */ - function testGetLocalUrlWithVariantArticlePaths( $expected, $dbkey, $query ) - { - # @todo FIXME: Find a language with variants! - $this->markTestIncomplete(); - - $actions = array( 'edit' => '/wiki/edit/$1' ); - $this->assertGetLocalURL( $expected, $dbkey, $query, '/wiki/view/$1', array(), '/$2/$1' ); - } - - function provider4() { - return array( - array( '/wiki/view/Recentchanges', 'Recentchanges', '', ), - ); - } - - } -- 2.20.1