r94506 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94505‎ | r94506 | r94507 >
Date:12:55, 15 August 2011
Author:hashar
Status:ok (Comments)
Tags:
Comment:
get ride of #c0 in URL
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeRevision.php (modified) (history)
  • /trunk/extensions/CodeReview/tests/CodeReviewTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeRevision.php
@@ -1241,10 +1241,11 @@
12421242 * @param string $commentId
12431243 * @return \type
12441244 */
1245 - public function getFullUrl( $commentId = '' ) {
 1245+ public function getFullUrl( $commentId = 0 ) {
12461246 $title = SpecialPage::getTitleFor( 'Code', $this->repo->getName() . '/' . $this->id );
12471247
1248 - if ( $commentId !== '' ) {
 1248+ # Append comment id if not null, empty string or zero
 1249+ if ( $commentId ) {
12491250 $title->setFragment( "#c{$commentId}" );
12501251 }
12511252
Index: trunk/extensions/CodeReview/tests/CodeReviewTest.php
@@ -40,4 +40,28 @@
4141
4242 // $this->assertEquals( '', $formatter->link( '' ) );
4343 }
44 -}
\ No newline at end of file
 44+
 45+ public function testCommentFullUrl() {
 46+ # Fixture:
 47+ $repo = $this->createRepo();
 48+ $cr = CodeRevision::newFromSvn( $repo, array(
 49+ 'rev' => 305,
 50+ 'author' => 'hashar',
 51+ 'date' => '15 august 2011',
 52+ 'msg' => 'dumb revision message',
 53+ 'paths' => array( '/dev/null' ),
 54+ )
 55+ );
 56+
 57+ # Find out our revision root URL
 58+ $baseUrl = SpecialPage::getTitleFor( 'Code', $repo->getName().'/305' )->getFullUrl();
 59+
 60+ # Test revision URL with various comment id:
 61+ $this->assertEquals( $baseUrl, $cr->getFullUrl( '' ) );
 62+ $this->assertEquals( $baseUrl, $cr->getFullUrl( 0 ) );
 63+ $this->assertEquals( $baseUrl, $cr->getFullUrl( null ) );
 64+ $this->assertEquals( $baseUrl, $cr->getFullUrl( "0" ) );
 65+ $this->assertEquals( $baseUrl . '#c777', $cr->getFullUrl( 777 ) );
 66+ $this->assertEquals( $baseUrl . '#c777', $cr->getFullUrl( "777" ) );
 67+ }
 68+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r94664MFT r94506demon17:30, 16 August 2011
r94665MFT r94506demon17:33, 16 August 2011

Comments

#Comment by Hashar (talk | contribs)   12:59, 15 August 2011

Test plan:

trunk/tests/phpunit$ ./phpunit.php --filter CodeReview --testdox
PHPUnit 3.5.14 by Sebastian Bergmann.
CodeReview
 [x] Comment wiki formatting
 [x] Comment full url
$

Probably need a backport in 1.17 1.17wmf1 and 1.18 :-)

#Comment by 😂 (talk | contribs)   17:33, 16 August 2011

Merged to 1.17wmf1 and deployed, merged to 1.18. No need for 1.17, imho.

#Comment by Hashar (talk | contribs)   17:45, 16 August 2011

Danke!

Status & tagging log