Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SafeInstallerTest.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Setup;
8 
18 
23 {
27  private $moduleManager;
28 
32  private $cliCommad;
33 
37  private $resourceConnection;
38 
39  public function setUp()
40  {
42  $this->moduleManager = $objectManager->get(TestModuleManager::class);
43  $this->cliCommad = $objectManager->get(CliCommand::class);
44  $this->resourceConnection = $objectManager->get(ResourceConnection::class);
45  }
46 
51  public function testInstallation()
52  {
53  $testTableData = $this->getData();
54  $row = reset($testTableData);
55  $this->cliCommad->install(['Magento_TestSetupDeclarationModule4']);
56  $adapter = $this->resourceConnection->getConnection();
57  $testTableName = $this->resourceConnection->getTableName('test_table');
58  $adapter->insertArray(
59  $this->resourceConnection->getTableName('test_table'),
60  array_keys($row),
61  $this->getData()
62  );
63  //Move new db_schema.xml
64  $this->moduleManager->updateRevision(
65  'Magento_TestSetupDeclarationModule4',
66  'remove_title_column',
67  'db_schema.xml',
68  'etc'
69  );
70  $this->cliCommad->upgrade(
71  [
72  'safe-mode' => true,
73  ]
74  );
75  //Move new db_schema.xml with restored title field
76  $this->moduleManager->updateRevision(
77  'Magento_TestSetupDeclarationModule4',
78  'restore_title_column',
79  'db_schema.xml',
80  'etc'
81  );
82  $this->cliCommad->upgrade(
83  [
84  'data-restore' => true,
85  ]
86  );
87  $testTableSelect = $adapter->select()->from($testTableName);
88  self::assertEquals($testTableData, $adapter->fetchAll($testTableSelect));
89  }
90 }
$objectManager
Definition: bootstrap.php:17
$adapter
Definition: webapi_user.php:16