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
|
|
|
|