Repository navigation
Expand file tree
/
Copy pathConsoleTest.php
More file actions
81 lines (61 loc) · 2.01 KB
/
Copy pathConsoleTest.php
File metadata and controls
81 lines (61 loc) · 2.01 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
<?php
use PHPUnit\Framework\TestCase;
use Roolith\Generator\Console;
class ConsoleTest extends TestCase
{
public $console;
public function setUp(): void
{
$this->console = new Console();
}
public function testShouldSetArguments()
{
$this->assertIsArray($this->console->getArguments());
}
public function testShouldRemoveFirstItemFromArgument()
{
$array = [1, 2, 3];
$this->console->setArguments($array);
$this->assertCount(2, $this->console->getArguments());
}
public function testShouldReturnBoolForHasArguments()
{
$this->assertFalse($this->console->hasArgument());
$array = [1, 2, 3];
$this->console->setArguments($array);
$this->assertTrue($this->console->hasArgument());
}
public function testShouldOutputMessage()
{
$this->expectOutputString('hello');
$this->console->output('hello');
}
public function testShouldOutputNewLine()
{
$this->expectOutputString(PHP_EOL);
$this->console->outputNewLine();
}
public function testShouldOutputMessageWithNewLine()
{
$this->expectOutputString('Location: /tmp/file.php' . PHP_EOL);
$this->console->outputLine('Location: /tmp/file.php');
}
public function testShouldUseConstructorArguments()
{
$console = new Console(['index.php', 'generate', 'controller', 'Demo']);
$this->assertSame(['generate', 'controller', 'Demo'], $console->getArguments());
$this->assertTrue($console->hasArgument());
}
public function testShouldHaveNoArgumentWhenOnlyScriptName()
{
$console = new Console(['index.php']);
$this->assertSame([], $console->getArguments());
$this->assertFalse($console->hasArgument());
}
public function testShouldReturnEmptyArgumentsWhenNeverSet()
{
$console = new Console(null);
$this->assertSame([], $console->getArguments());
$this->assertFalse($console->hasArgument());
}
}