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

SilverStripeLoaderTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetCommandFactory() 0 11 1
A testGetTasksAsCommands() 0 12 2
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