forked from clue/reactphp-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionalTest.php
More file actions
130 lines (91 loc) · 2.9 KB
/
FunctionalTest.php
File metadata and controls
130 lines (91 loc) · 2.9 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
use React\EventLoop\Factory;
use Clue\React\Shell\ProcessLauncher;
class FunctionalTest extends TestCase
{
private $loop;
private $launcher;
public function setUp()
{
$this->loop = Factory::create();
$this->launcher = new ProcessLauncher($this->loop);
}
/**
* @doesNotPerformAssertions
*/
public function testEndEmptyClosesImmediately()
{
$shell = $this->launcher->createDeferredShell('cat');
$shell->end();
$this->loop->run();
}
/**
* @doesNotPerformAssertions
*/
public function testCloseEmpty()
{
$shell = $this->launcher->createDeferredShell('cat');
$shell->close();
$this->loop->run();
}
public function testExecuteThenEnd()
{
$shell = $this->launcher->createDeferredShell('bash');
$promise = $shell->execute('echo hallo');
$this->expectPromiseResolveWith("hallo\n", $promise);
$shell->end();
$this->loop->run();
}
public function testExecuteLengthyOutput()
{
$shell = $this->launcher->createDeferredShell('bash');
$promise = $shell->execute('env && env && env && env && env');
$this->expectPromiseResolve($promise);
$shell->end();
$this->loop->run();
}
public function testClosePendingWillBeRejected()
{
$shell = $this->launcher->createDeferredShell('bash');
$promise = $shell->execute('echo hello');
$shell->close();
$this->expectPromiseReject($promise);
$this->loop->run();
}
public function testEndThenExecuteRejectsImmediately()
{
$shell = $this->launcher->createDeferredShell('bash');
$shell->end();
$promise = $shell->execute('echo hello');
$this->expectPromiseReject($promise);
}
public function testExecuteInvalidResolves()
{
$shell = $this->launcher->createDeferredShell('bash');
$promise = $shell->execute('some-random-invalid-command');
$this->expectPromiseResolve($promise);
$shell->end();
$this->loop->run();
}
public function testExitingShellWillRejectAllExecutes()
{
$shell = $this->launcher->createDeferredShell('bash');
$promise = $shell->execute('exit');
$this->expectPromiseReject($promise);
$promise = $shell->execute('echo hello');
$this->expectPromiseReject($promise);
$this->loop->run();
}
public function testPhpShell()
{
$this->markTestSkipped();
$shell = $this->launcher->createDeferredShell('php -a');
$shell->setBounding('echo "{{ bounding }}";');
$shell->execute('$var = "hello";');
$shell->execute('$var .= " world";');
$promise = $shell->execute('echo $var;');
$this->expectPromiseResolveWith('hello world', $promise);
$shell->end();
$this->loop->run();
}
}