AbstractSetupCommandTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 12
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace N98\Magento\Command\System\Setup;
4
5
use N98\Magento\Command\PHPUnit\TestCase;
6
7
class AbstractSetupCommandTest extends TestCase
8
{
9
    /**
10
     * Mocked command
11
     * @var Mock_AbstractSetupCommand
12
     */
13
    protected $command;
14
15
    /**
16
     * Set up the mocked command for testing
17
     */
18
    public function setUp()
19
    {
20
        $this->command = $this->getMockBuilder('N98\Magento\Command\System\Setup\AbstractSetupCommand')
21
            ->disableOriginalConstructor()
22
            ->setMethods(array('getMagentoModuleList'))
23
            ->getMockForAbstractClass();
24
25
        $this->command
26
            ->expects($this->once())
27
            ->method('getMagentoModuleList')
28
            ->will($this->returnValue(array('Magento_Catalog' => 'info', 'Magento_Customer' => 'info')));
29
    }
30
31
    /**
32
     * Test the getMagentoModuleName() method returns the actual module name when it exists
33
     * @param string $moduleName
34
     *
35
     * @dataProvider validModuleNameProvider
36
     */
37
    public function testShouldReturnModuleNameForExistingModule($moduleName)
38
    {
39
        $result = $this->command->getMagentoModuleName($moduleName);
40
        $this->assertStringStartsWith('Magento', $result);
41
    }
42
43
    /**
44
     * Provide some inconsistently cased module names
45
     * @return array
46
     */
47
    public function validModuleNameProvider()
48
    {
49
        return array(
50
            array('magento_catalog'),
51
            array('magento_customer'),
52
            array('Magento_Catalog'),
53
            array('MaGeNtO_cUstOmeR')
54
        );
55
    }
56
57
    /**
58
     * Ensure that an exception is thrown when a module doesn't exist
59
     * @expectedException InvalidArgumentException
60
     */
61
    public function testShouldThrowExceptionWhenModuleDoesntExist()
62
    {
63
        $this->command->getMagentoModuleName('Some_Module_That_Will_Never_Exist');
64
    }
65
}
66