Skip to content

Commit 6ac30ce

Browse files
committed
Add functional tests for attic from Gentoo's CVS
1 parent 7e643f8 commit 6ac30ce

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

tests/FunctionalClientTest.php renamed to tests/FunctionalApacheClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use React\Promise\PromiseInterface;
77
use Clue\React\Block\Blocker;
88

9-
class FunctionalClientTest extends TestCase
9+
class FunctionalApacheClientTest extends TestCase
1010
{
1111
private $loop;
1212
private $viewvc;

tests/FunctionalGentooClientTest.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
use Clue\React\ViewVcApi\Client;
4+
use React\EventLoop\Factory as LoopFactory;
5+
use Clue\React\Buzz\Browser;
6+
use React\Promise\PromiseInterface;
7+
use Clue\React\Block\Blocker;
8+
9+
class FunctionalGentooClientTest extends TestCase
10+
{
11+
private $loop;
12+
private $viewvc;
13+
private $blocker;
14+
15+
public function setUp()
16+
{
17+
$url = 'https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo/';
18+
19+
$this->loop = LoopFactory::create();
20+
$this->blocker = new Blocker($this->loop);
21+
$browser = new Browser($this->loop);
22+
23+
// check connectivity to given URL only once
24+
static $checked = null;
25+
if ($checked === null) {
26+
try {
27+
$this->waitFor($browser->head($url));
28+
$checked = true;
29+
} catch (Exception $e) {
30+
$checked = false;
31+
}
32+
}
33+
34+
if (!$checked) {
35+
$this->markTestSkipped('Unable to reach Gentoo ViewVC');
36+
}
37+
38+
$this->viewvc = new Client($url, $browser);
39+
}
40+
41+
public function testFetchDirectoryAttic()
42+
{
43+
$path = '/';
44+
45+
$promise = $this->viewvc->fetchDirectory($path, null, true);
46+
$files = $this->waitFor($promise);
47+
48+
$this->assertEquals(array('misc/', 'src/', 'users/', 'xml/', '.frozen'), $files);
49+
}
50+
51+
public function testFetchFileDeletedShowsLastState()
52+
{
53+
$file = '.frozen';
54+
55+
$promise = $this->viewvc->fetchFile($file);
56+
$contents = $this->waitFor($promise);
57+
58+
$this->assertEquals("robbat2\n", $contents);
59+
}
60+
61+
private function waitFor(PromiseInterface $promise)
62+
{
63+
return $this->blocker->awaitOne($promise);
64+
}
65+
}

0 commit comments

Comments
 (0)