-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathFunctionalLauncherTest.php
More file actions
77 lines (56 loc) · 2.18 KB
/
FunctionalLauncherTest.php
File metadata and controls
77 lines (56 loc) · 2.18 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
<?php
namespace Clue\Tests\React\Zenity;
use Clue\React\Block;
use Clue\React\Zenity\Launcher;
use Clue\React\Zenity\Zen\BaseZen;
use React\EventLoop\Factory;
class FunctionalLauncherTest extends TestCase
{
private $loop;
private $dialog;
private $launcher;
/**
* @before
*/
public function setUpLauncher()
{
$this->loop = Factory::create();
$this->dialog = $this->getMockBuilder('Clue\React\Zenity\Dialog\AbstractDialog')->getMock();
$this->dialog->expects($this->once())->method('createZen')->will($this->returnValue(new BaseZen()));
$this->launcher = new Launcher($this->loop);
}
public function testEchoParameters()
{
$this->launcher->setBin('echo');
$this->dialog->expects($this->once())->method('getArgs')->will($this->returnValue(array('--hello', '--world')));
$promise = $this->launcher->launch($this->dialog);
$result = Block\await($promise, $this->loop, 1.0);
$this->assertEquals('--hello --world', $result);
}
public function testDoesPassStdin()
{
$this->launcher->setBin('cat');
$this->dialog->expects($this->once())->method('getArgs')->will($this->returnValue(array()));
$this->dialog->expects($this->once())->method('getInBuffer')->will($this->returnValue('okay'));
$zen = $this->launcher->launchZen($this->dialog);
$this->loop->addTimer(0.1, function () use ($zen) {
$zen->close();
});
$result = Block\await($zen->promise(), $this->loop, 1.0);
$this->assertEquals('okay', $result);
}
public function testWaitForOutput()
{
$this->launcher->setBin('echo');
$this->dialog->expects($this->once())->method('getArgs')->will($this->returnValue(array('test')));
$result = $this->launcher->waitFor($this->dialog);
$this->assertEquals('test', $result);
}
public function testWaitForError()
{
$this->launcher->setBin('false');
$this->dialog->expects($this->once())->method('getArgs')->will($this->returnValue(array()));
$result = $this->launcher->waitFor($this->dialog);
$this->assertEquals(false, $result);
}
}