From ac1c75fc6e87ad0b8758e60c3f3a0f8282856755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Tue, 7 Apr 2015 17:36:50 +0200 Subject: [PATCH] Fix accessing deleted files in older revisions --- src/Client.php | 2 +- tests/ClientTest.php | 9 +++++++++ tests/FunctionalClientTest.php | 11 +++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index 8be5ac4..5ceaf49 100644 --- a/src/Client.php +++ b/src/Client.php @@ -45,7 +45,7 @@ public function fetchFile($path, $revision = null) $url = $path . '?view=co'; if ($revision !== null) { - $url .= '&revision=' . $revision; + $url .= '&pathrev=' . $revision; } // TODO: fetching a directory redirects to path with trailing slash diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 0434d0c..8332c83 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -48,4 +48,13 @@ public function testFetchFileExcessiveSlashesAreIgnored() $this->expectPromiseReject($promise); } + + public function testFetchFileRevision() + { + $this->browser->expects($this->once())->method('get')->with($this->equalTo('http://viewvc.example.org/README.md?view=co&pathrev=1.0'))->will($this->returnValue($this->createPromiseRejected())); + + $promise = $this->client->fetchFile('/README.md', '1.0'); + + $this->expectPromiseReject($promise); + } } diff --git a/tests/FunctionalClientTest.php b/tests/FunctionalClientTest.php index f483538..ba4c582 100644 --- a/tests/FunctionalClientTest.php +++ b/tests/FunctionalClientTest.php @@ -44,6 +44,17 @@ public function testFetchFile() $this->assertStringStartsWith('/*', $recipe); } + public function testFetchFileOldFileNowDeletedButRevisionAvailable() + { + $file = 'commons/STATUS'; + $revision = '1'; + + $promise = $this->viewvc->fetchFile($file, $revision); + $contents = $this->waitFor($promise); + + $this->assertStringStartsWith('APACHE COMMONS', $contents); + } + /** * @expectedException RuntimeException */