15 use PHPUnit_Framework_MockObject_MockObject as Mock;
16 use Symfony\Component\Console\Tester\CommandTester;
26 private $dbVersionInfo;
31 private $deploymentConfig;
46 protected function setUp()
48 $this->dbVersionInfo = $this->getMockBuilder(DbVersionInfo::class)
49 ->disableOriginalConstructor()
52 $objectManagerProvider = $this->getMockBuilder(ObjectManagerProvider::class)
53 ->disableOriginalConstructor()
56 $objectManager = $this->getMockForAbstractClass(ObjectManagerInterface::class);
57 $this->deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
58 ->disableOriginalConstructor()
61 'declarative_schema' => $this->getMockBuilder(UpToDateValidatorInterface::class)->getMock(),
62 'up_to_date_schema' => $this->getMockBuilder(UpToDateValidatorInterface::class)->getMock(),
63 'up_to_date_data' => $this->getMockBuilder(UpToDateValidatorInterface::class)->getMock(),
64 'old_validator' => $this->getMockBuilder(UpToDateValidatorInterface::class)->getMock(),
67 $objectManagerProvider->expects($this->any())
72 ->willReturnOnConsecutiveCalls(
73 $this->validators[
'declarative_schema'],
74 $this->validators[
'up_to_date_schema'],
75 $this->validators[
'up_to_date_data'],
76 $this->validators[
'old_validator']
78 $this->command =
new DbStatusCommand($objectManagerProvider, $this->deploymentConfig);
83 $this->validators[
'old_validator']->expects(self::once())
84 ->method(
'isUpToDate')
86 $this->validators[
'up_to_date_schema']->expects(self::once())
87 ->method(
'isUpToDate')
89 $this->validators[
'up_to_date_data']->expects(self::once())
90 ->method(
'isUpToDate')
92 $this->validators[
'declarative_schema']->expects(self::once())
93 ->method(
'isUpToDate')
95 $this->deploymentConfig->expects($this->once())
96 ->method(
'isAvailable')
97 ->will($this->returnValue(
true));
98 $tester =
new CommandTester($this->command);
100 $this->assertStringMatchesFormat(
'All modules are up to date.', $tester->getDisplay());
101 $this->assertSame(0, $tester->getStatusCode());
106 $this->deploymentConfig->expects($this->once())
107 ->method(
'isAvailable')
108 ->will($this->returnValue(
false));
109 $tester =
new CommandTester($this->command);
110 $tester->execute([]);
112 $this->assertStringMatchesFormat(
113 'No information is available: the Magento application is not installed.%w',
114 $tester->getDisplay()
testExecuteNotInstalled()