Index: trunk/extensions/CodeReview/backend/CodeRevision.php |
— | — | @@ -1241,10 +1241,11 @@ |
1242 | 1242 | * @param string $commentId |
1243 | 1243 | * @return \type |
1244 | 1244 | */ |
1245 | | - public function getFullUrl( $commentId = '' ) { |
| 1245 | + public function getFullUrl( $commentId = 0 ) { |
1246 | 1246 | $title = SpecialPage::getTitleFor( 'Code', $this->repo->getName() . '/' . $this->id ); |
1247 | 1247 | |
1248 | | - if ( $commentId !== '' ) { |
| 1248 | + # Append comment id if not null, empty string or zero |
| 1249 | + if ( $commentId ) { |
1249 | 1250 | $title->setFragment( "#c{$commentId}" ); |
1250 | 1251 | } |
1251 | 1252 | |
Index: trunk/extensions/CodeReview/tests/CodeReviewTest.php |
— | — | @@ -40,4 +40,28 @@ |
41 | 41 | |
42 | 42 | // $this->assertEquals( '', $formatter->link( '' ) ); |
43 | 43 | } |
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 | +} |