Completed
Push — master ( 01b890...8110dc )
by Robbie
01:11
created

SilverStripeLoaderTest::testGetCommandFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
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