1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace N98\Magento\Command\System\Setup; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
6
|
|
|
use N98\Magento\Command\PHPUnit\TestCase; |
7
|
|
|
|
8
|
|
|
class ChangeVersionCommandTest extends TestCase |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Ensure that the resource setters are called. |
12
|
|
|
*/ |
13
|
|
|
public function testExecute() |
14
|
|
|
{ |
15
|
|
|
$command = $this->getMockBuilder('N98\Magento\Command\System\Setup\ChangeVersionCommand') |
16
|
|
|
->setMethods(array('getMagentoModuleName', 'getMagentoModuleResource')) |
17
|
|
|
->getMock(); |
18
|
|
|
|
19
|
|
|
$command |
20
|
|
|
->expects($this->once()) |
21
|
|
|
->method('getMagentoModuleName') |
22
|
|
|
->with('magento_customer') |
23
|
|
|
->will($this->returnValue('Magento_Customer')); |
24
|
|
|
|
25
|
|
|
$resourceMock = $this->getMockBuilder('Magento\Framework\Module\ModuleResource') |
26
|
|
|
->setMethods(array('setDbVersion', 'setDataVersion')) |
27
|
|
|
->getMock(); |
28
|
|
|
|
29
|
|
|
$resourceMock |
30
|
|
|
->expects($this->once()) |
31
|
|
|
->method('setDbVersion') |
32
|
|
|
->with('Magento_Customer'); |
33
|
|
|
|
34
|
|
|
$resourceMock |
35
|
|
|
->expects($this->once()) |
36
|
|
|
->method('setDataVersion') |
37
|
|
|
->with('Magento_Customer'); |
38
|
|
|
|
39
|
|
|
$command |
40
|
|
|
->expects($this->exactly(2)) |
41
|
|
|
->method('getMagentoModuleResource') |
42
|
|
|
->will($this->returnValue($resourceMock)); |
43
|
|
|
|
44
|
|
|
$application = $this->getApplication(); |
45
|
|
|
$application->add($command); |
|
|
|
|
46
|
|
|
$command = $this->getApplication()->find('sys:setup:change-version'); |
|
|
|
|
47
|
|
|
|
48
|
|
|
$commandTester = new CommandTester($command); |
49
|
|
|
$commandTester->execute( |
50
|
|
|
array( |
51
|
|
|
'command' => $command->getName(), |
52
|
|
|
'module' => 'magento_customer', |
53
|
|
|
'version' => '1.2.3' |
54
|
|
|
) |
55
|
|
|
); |
56
|
|
|
|
57
|
|
|
$this->assertContains( |
58
|
|
|
'Successfully updated: "Magento_Customer" to version: "1.2.3"', |
59
|
|
|
$commandTester->getDisplay() |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: