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