Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DbDataUpgradeCommandTest.php
Go to the documentation of this file.
1 <?php
8 
11 use Symfony\Component\Console\Tester\CommandTester;
12 
13 class DbDataUpgradeCommandTest extends \PHPUnit\Framework\TestCase
14 {
18  protected $installerFactory;
19 
23  protected $deploymentConfig;
24 
25  protected function setup()
26  {
27  $this->installerFactory = $this->createMock(\Magento\Setup\Model\InstallerFactory::class);
28  $this->deploymentConfig = $this->createMock(\Magento\Framework\App\DeploymentConfig::class);
29  }
30 
31  public function testExecute()
32  {
33  $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(true));
34  $installer = $this->createMock(\Magento\Setup\Model\Installer::class);
35  $this->installerFactory->expects($this->once())->method('create')->will($this->returnValue($installer));
36  $installer->expects($this->once())->method('installDataFixtures');
37 
38  $commandTester = new CommandTester(
39  new DbDataUpgradeCommand($this->installerFactory, $this->deploymentConfig)
40  );
41  $commandTester->execute([]);
42  }
43 
44  public function testExecuteNoConfig()
45  {
46  $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
47  $this->installerFactory->expects($this->never())->method('create');
48 
49  $commandTester = new CommandTester(
50  new DbDataUpgradeCommand($this->installerFactory, $this->deploymentConfig)
51  );
52  $commandTester->execute([]);
53  $this->assertStringMatchesFormat(
54  'No information is available: the Magento application is not installed.%w',
55  $commandTester->getDisplay()
56  );
57  }
58 }