forked from clue/php-viewvc-api-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionalGentooClientTest.php
More file actions
61 lines (47 loc) · 1.61 KB
/
FunctionalGentooClientTest.php
File metadata and controls
61 lines (47 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
use Clue\React\ViewVcApi\Client;
use React\EventLoop\Factory as LoopFactory;
use Clue\React\Buzz\Browser;
use Clue\React\Block;
class FunctionalGentooClientTest extends TestCase
{
private $loop;
private $viewvc;
public function setUp()
{
if (!function_exists('stream_socket_enable_crypto')) {
$this->markTestSkipped('TLS (HTTPS) not supported by your platform (HHVM?)');
}
$url = 'https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo/';
$this->loop = LoopFactory::create();
$browser = new Browser($this->loop);
// check connectivity to given URL only once
static $checked = null;
if ($checked === null) {
try {
Block\await($browser->head($url), $this->loop);
$checked = true;
} catch (Exception $e) {
$checked = false;
}
}
if (!$checked) {
$this->markTestSkipped('Unable to reach Gentoo ViewVC');
}
$this->viewvc = new Client($browser->withBase($url));
}
public function testFetchDirectoryAttic()
{
$path = '/';
$promise = $this->viewvc->fetchDirectory($path, null, true);
$files = Block\await($promise, $this->loop);
$this->assertEquals(array('misc/', 'src/', 'users/', 'xml/', '.frozen'), $files);
}
public function testFetchFileDeletedShowsLastState()
{
$file = '.frozen';
$promise = $this->viewvc->fetchFile($file);
$contents = Block\await($promise, $this->loop);
$this->assertEquals("robbat2\n", $contents);
}
}