-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandTest.php
79 lines (60 loc) · 2.16 KB
/
CommandTest.php
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
<?php
namespace yii1tech\async\cmd\test;
use yii1tech\async\cmd\Command;
use yii1tech\async\cmd\CommandDispatcher;
class CommandTest extends TestCase
{
/**
* Creates test command instance.
*
* @return \yii1tech\async\cmd\Command command instance.
*/
protected function createCommand(): Command
{
$command = new Command();
$command->isDispatched = true;
return $command;
}
public function testSetup(): void
{
$command = $this->createCommand();
$commandClass = 'FooCommand';
$command->setCommandClass($commandClass);
$this->assertSame($commandClass, $command->getCommandClass());
$commandAction = 'foo';
$command->setCommandAction($commandAction);
$this->assertSame($commandAction, $command->getCommandAction());
$binPath = '/user/bin/php';
$command->setBinPath($binPath);
$this->assertSame($binPath, $command->getBinPath());
$params = ['foo', 'bar'];
$command->setParams($params);
$this->assertSame($params, $command->getParams());
$outputLog = '/path/to/file.log';
$command->setOutputLog($outputLog);
$this->assertSame($outputLog, $command->getOutputLog());
$dispatcher = new CommandDispatcher();
$command->setDispatcher($dispatcher);
$this->assertSame($dispatcher, $command->getDispatcher());
}
public function testSetupYiic(): void
{
$command = $this->createCommand();
$class = 'FooCommand';
$action = 'bar';
$params = ['param1', 'param2'];
$command->yiic($class, $action, $params);
$this->assertSame($class, $command->getCommandClass());
$this->assertSame($action, $command->getCommandAction());
$this->assertSame($params, $command->getParams());
}
public function testSetupExternal(): void
{
$command = $this->createCommand();
$binPath = '/user/bin/foo';
$params = ['param1', 'param2'];
$command->external($binPath, $params);
$this->assertSame($binPath, $command->getBinPath());
$this->assertSame($params, $command->getParams());
}
}