1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverLeague\Console\Tests\Dev; |
4
|
|
|
|
5
|
|
|
use SilverLeague\Console\Framework\Scaffold; |
6
|
|
|
use SilverLeague\Console\Tests\Command\AbstractCommandTest; |
7
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @coversDefaultClass \SilverLeague\Console\Command\Dev\BuildCommand |
11
|
|
|
* @package silverstripe-console |
12
|
|
|
* @author Robbie Averill <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class BuildTest extends AbstractCommandTest |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* {@inheritDoc} |
18
|
|
|
*/ |
19
|
|
|
public function getTestCommand() |
20
|
|
|
{ |
21
|
|
|
return 'dev:build'; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Test that the name and description were set correctly |
26
|
|
|
* |
27
|
|
|
* @covers ::configure |
28
|
|
|
*/ |
29
|
|
|
public function testConfigure() |
30
|
|
|
{ |
31
|
|
|
$this->assertSame($this->getTestCommand(), $this->command->getName()); |
32
|
|
|
$this->assertContains('Builds the SilverStripe database', $this->command->getDescription()); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Test that the database is built correctly. This test assumes that the "tests/bootstrap.php" database |
37
|
|
|
* configuration can work in a test environment. If this test fails, you may need to tweak this code and/or allow |
38
|
|
|
* it to work in your environment. |
39
|
|
|
* |
40
|
|
|
* We have to buffer the CommandTester output to check its result because the SilverStripe framework uses "echo" |
41
|
|
|
* which we can't capture in an OutputInterface. |
42
|
|
|
* |
43
|
|
|
* @covers ::execute |
44
|
|
|
*/ |
45
|
|
|
public function testExecute() |
46
|
|
|
{ |
47
|
|
|
$command = (new Scaffold)->getApplication()->find($this->getTestCommand()); |
48
|
|
|
|
49
|
|
|
$tester = new CommandTester($command); |
50
|
|
|
|
51
|
|
|
ob_start(); |
52
|
|
|
$tester->execute(['command' => $command->getName()]); |
53
|
|
|
$buffer = ob_get_clean(); |
54
|
|
|
|
55
|
|
|
$this->assertContains('Database build completed!', $buffer); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|