forked from clue/php-viewvc-api-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionalClientTest.php
More file actions
97 lines (75 loc) · 2.49 KB
/
FunctionalClientTest.php
File metadata and controls
97 lines (75 loc) · 2.49 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
use Clue\React\ViewVcApi\Client;
use React\EventLoop\Factory as LoopFactory;
use Clue\React\Buzz\Browser;
use React\Promise\PromiseInterface;
use Clue\React\Block\Blocker;
class FunctionalClientTest extends TestCase
{
private $loop;
private $viewvc;
private $blocker;
public function setUp()
{
$url = 'http://svn.apache.org/viewvc/';
$this->loop = LoopFactory::create();
$this->blocker = new Blocker($this->loop);
$browser = new Browser($this->loop);
$this->viewvc = new Client($url, $browser);
}
public function testFetchDirectory()
{
$path = 'jakarta/ecs/';
$promise = $this->viewvc->fetchDirectory($path);
$files = $this->waitFor($promise);
$this->assertEquals(array('branches/', 'tags/', 'trunk/'), $files);
}
public function testFetchFile()
{
$file = 'jakarta/ecs/tags/V1_0/src/java/org/apache/ecs/AlignType.java';
$revision = '168703';
$promise = $this->viewvc->fetchFile($file, $revision);
$recipe = $this->waitFor($promise);
$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
*/
public function testFetchFileInvalid()
{
$file = 'asdasd';
$revision = '123';
$promise = $this->viewvc->fetchFile($file, $revision);
$this->waitFor($promise);
}
public function testFetchRevisionPrevious()
{
$file = 'jakarta/ecs/tags/V1_0/src/java/org/apache/ecs/AlignType.java';
$revision = '168703';
$promise = $this->viewvc->fetchRevisionPrevious($file, $revision);
$revision = $this->waitFor($promise);
$this->assertEquals('168695', $revision);
}
/**
* @expectedException RuntimeException
*/
public function testFetchRevisionUnknownBase()
{
$file = 'jakarta/ecs/tags/V1_0/src/java/org/apache/ecs/AlignType.java';
$revision = 'xyz';
$promise = $this->viewvc->fetchRevisionPrevious($file, $revision);
$this->waitFor($promise);
}
private function waitFor(PromiseInterface $promise)
{
return $this->blocker->awaitOne($promise);
}
}