r88679 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88678‎ | r88679 | r88680 >
Date:20:24, 23 May 2011
Author:brion
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/TitleTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/TitleTest.php
@@ -15,108 +15,4 @@
1616 }
1717 }
1818
19 - /**
20 - * Helper to test getLocalURL
21 - *
22 - * @cover Title:getLocalURL
23 - */
24 - function assertGetLocalURL( $expected, $dbkey, $query, $articlepath, $actionpaths = array(), $variant = false )
25 - {
26 - global $wgArticlePath;
27 - $wgArticlePath = $articlepath;
28 - global $wgActionPaths;
29 - $wgActionPaths = $actionpaths;
30 -
31 - $t = Title::newFromDBKey( $dbkey );
32 -
33 - $this->assertEquals( $expected, $t->getLocalURL( $query, $variant ) );
34 - }
35 -
36 - /**
37 - * @dataProvider provider1
38 - * @cover Title:getLocalURL
39 - */
40 - function testGetLocalUrl( $expected, $dbkey, $query )
41 - {
42 - $this->assertGetLocalURL( $expected, $dbkey, $query, '/wiki/$1' );
43 - }
44 -
45 - function provider1()
46 - {
47 - return array(
48 - array( '/wiki/Recentchanges', 'Recentchanges', '' ),
49 - array( '/wiki/Recentchanges?foo=2', 'Recentchanges', 'foo=2' ),
50 - array( '/wiki/Recentchanges?foo=A&bar=1', 'Recentchanges', 'foo=A&bar=1' ),
51 - );
52 - }
53 -
54 -
55 - /**
56 - * @dataProvider provider2
57 - * @cover Title:getLocalURL
58 - */
59 - function testGetLocalUrlWithArticlePath( $expected, $dbkey, $query, $actions )
60 - {
61 - $this->assertGetLocalURL( $expected, $dbkey, $query, '/wiki/view/$1', $actions );
62 - }
63 -
64 - function provider2()
65 - {
66 - return array(
67 - array( '/wiki/view/Recentchanges', 'Recentchanges', '', array( ) ),
68 - array( '/wiki/view/Recentchanges', 'Recentchanges', '', array( 'view' => 'OH MEN' ) ),
69 - array( '/wiki/view/Recentchanges', 'Recentchanges', '', array( 'view' => '/wiki/view/$1' ) ),
70 - array( '/wiki/view/Recentchanges?foo=2', 'Recentchanges', 'foo=2', array( 'view' => '/wiki/view/$1' ) ),
71 - array( '/wiki/view/Recentchanges?foo=A&bar=1', 'Recentchanges', 'foo=A&bar=1', array() ),
72 - );
73 - }
74 -
75 -
76 - /**
77 - * @dataProvider provider3
78 - * @cover Title:getLocalURL
79 - */
80 - function testGetLocalUrlWithActionPaths( $expected, $dbkey, $query )
81 - {
82 - $actions = array( 'edit' => '/wiki/edit/$1' );
83 - $this->assertGetLocalURL( $expected, $dbkey, $query, '/wiki/view/$1', $actions );
84 - }
85 -
86 - function provider3() {
87 - return array(
88 - array( '/wiki/view/Recentchanges', 'Recentchanges', ''),
89 - array( '/wiki/edit/Recentchanges', 'Recentchanges', 'action=edit' ),
90 - array( '/wiki/edit/Recentchanges?foo=2', 'Recentchanges', 'action=edit&foo=2' ),
91 - array( '/wiki/edit/Recentchanges?foo=2', 'Recentchanges', 'foo=2&action=edit' ),
92 - array( '/wiki/view/Recentchanges?foo=A&bar=1', 'Recentchanges', 'foo=A&bar=1' ),
93 - array( '/wiki/edit/Recentchanges?foo=A&bar=1', 'Recentchanges', 'foo=A&bar=1&action=edit' ),
94 - array( '/wiki/edit/Recentchanges?foo=A&bar=1', 'Recentchanges', 'foo=A&action=edit&bar=1' ),
95 - array( '/wiki/edit/Recentchanges?foo=A&bar=1', 'Recentchanges', 'action=edit&foo=A&bar=1' ),
96 -
97 - # @todo FIXME: The next two are equals but need investigation:
98 - array( '/wiki/edit/Recentchanges', 'Recentchanges', 'action=view&action=edit' ),
99 - array( '/wiki/view/Recentchanges?action=edit&action=view', 'Recentchanges', 'action=edit&action=view' ),
100 - );
101 - }
102 -
103 - /**
104 - * @dataProvider provider4
105 - * @cover Title:getLocalURL
106 - */
107 - function testGetLocalUrlWithVariantArticlePaths( $expected, $dbkey, $query )
108 - {
109 - # @todo FIXME: Find a language with variants!
110 - $this->markTestIncomplete();
111 -
112 - $actions = array( 'edit' => '/wiki/edit/$1' );
113 - $this->assertGetLocalURL( $expected, $dbkey, $query, '/wiki/view/$1', array(), '/$2/$1' );
114 - }
115 -
116 - function provider4() {
117 - return array(
118 - array( '/wiki/view/Recentchanges', 'Recentchanges', '', ),
119 - );
120 - }
121 -
122 -
12319 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r87964merge in prettyURL patch...hashar11:41, 13 May 2011
r88667Revert r87964: destroyed standard segregation of non-view action links outsid...brion19:03, 23 May 2011

Status & tagging log