1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverLeague\Console\Tests\Framework\Loader; |
4
|
|
|
|
5
|
|
|
use SilverLeague\Console\Command\Factory; |
6
|
|
|
use SilverLeague\Console\Framework\Scaffold; |
7
|
|
|
use Symfony\Component\Console\Command\Command; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @coversDefaultClass \SilverLeague\Console\Framework\Loader\SilverStripeLoader |
11
|
|
|
* @package silverstripe-console |
12
|
|
|
* @author Robbie Averill <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class SilverStripeLoaderTest extends \PHPUnit_Framework_TestCase |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Test that the Command Factory is returned, and that it is correctly Application aware |
18
|
|
|
* |
19
|
|
|
* @covers ::getCommandFactory |
20
|
|
|
* @covers \SilverLeague\Console\Framework\ConsoleBase |
21
|
|
|
*/ |
22
|
|
|
public function testGetCommandFactory() |
23
|
|
|
{ |
24
|
|
|
$scaffold = new Scaffold; |
25
|
|
|
|
26
|
|
|
$factory = $scaffold |
27
|
|
|
->getSilverStripeLoader() |
28
|
|
|
->getCommandFactory(); |
29
|
|
|
|
30
|
|
|
$this->assertInstanceOf(Factory::class, $factory); |
31
|
|
|
$this->assertSame($factory->getApplication(), $scaffold->getApplication()); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Test that SilverStripe BuildTasks can be retrieved as bootstrapped Commands |
36
|
|
|
* |
37
|
|
|
* @covers ::getTasks |
38
|
|
|
* @covers ::getCommandFactory |
39
|
|
|
*/ |
40
|
|
|
public function testGetTasksAsCommands() |
41
|
|
|
{ |
42
|
|
|
$application = new Scaffold; |
43
|
|
|
$loader = $application->getSilverStripeLoader(); |
44
|
|
|
|
45
|
|
|
$commands = $loader->getTasks(); |
46
|
|
|
$this->assertInternalType('array', $commands); |
47
|
|
|
$this->assertNotEmpty($commands); // Framework ships with a couple |
48
|
|
|
foreach ($commands as $command) { |
49
|
|
|
$this->assertInstanceOf(Command::class, $command); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|