Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
BCMultiModuleTest Class Reference
Inheritance diagram for BCMultiModuleTest:
SetupTestCase MutableDataInterface

Public Member Functions

 setUp ()
 
 testFirstCleanInstall ()
 
 testDSFirstRelease ()
 
 testFirstCleanInstallOneModule (string $dbPrefix, string $tableName, string $indexName, string $constraintName, string $foreignKeyName)
 
 firstCleanInstallOneModuleDataProvider ()
 
- Public Member Functions inherited from SetupTestCase
 setData (array $data)
 
 flushData ()
 
 getData ()
 

Detailed Description

The purpose of this test is to check whether whole declarative installation is work in mixed mode

Definition at line 22 of file BCMultiModuleTest.php.

Member Function Documentation

◆ firstCleanInstallOneModuleDataProvider()

firstCleanInstallOneModuleDataProvider ( )
Returns
array

Definition at line 246 of file BCMultiModuleTest.php.

247  {
248  return [
249  'Installation without db prefix' => [
250  'dbPrefix' => '',
251  'tableName' => 'test_table',
252  'indexName' => 'TEST_TABLE_TINYINT_BIGINT',
253  'constraintName' => 'TEST_TABLE_SMALLINT_BIGINT',
254  'foreignKeyName' => 'TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF',
255  ],
256  'Installation with db prefix' => [
257  'dbPrefix' => 'spec_',
258  'tableName' => 'spec_test_table',
259  'indexName' => 'SPEC_TEST_TABLE_TINYINT_BIGINT',
260  'constraintName' => 'SPEC_TEST_TABLE_SMALLINT_BIGINT',
261  'foreignKeyName' => 'SPEC_TEST_TABLE_TINYINT_SPEC_REFERENCE_TABLE_TINYINT_REF',
262  ]
263  ];
264  }

◆ setUp()

setUp ( )

Definition at line 54 of file BCMultiModuleTest.php.

55  {
57  $this->moduleManager = $objectManager->get(TestModuleManager::class);
58  $this->cliCommand = $objectManager->get(CliCommand::class);
59  $this->dbVersionInfo = $objectManager->get(DbVersionInfo::class);
60  $this->tableData = $objectManager->get(TableData::class);
61  $this->moduleResource = $objectManager->get(ModuleResource::class);
62  $this->dbSchemaReader = $objectManager->get(DbSchemaReaderInterface::class);
63  }
$objectManager
Definition: bootstrap.php:17

◆ testDSFirstRelease()

testDSFirstRelease ( )

@moduleName Magento_TestSetupDeclarationModule6 @moduleName Magento_TestSetupDeclarationModule7

Definition at line 170 of file BCMultiModuleTest.php.

171  {
172  $this->cliCommand->install([
173  'Magento_TestSetupDeclarationModule6',
174  'Magento_TestSetupDeclarationModule7'
175  ]);
176  //Check no change upgrade with US
177  $this->cliCommand->upgrade();
178 
179  $this->doUsToUsRevision();
180  //Check US to US upgrade
181  $this->cliCommand->upgrade();
182  $this->assertUsToUsUpgrade();
183 
184  $this->doUsToDsRevision();
185  //Check US to declarative schema upgrade
186  $this->cliCommand->upgrade();
187  $this->assertUsToDsUpgrade();
188 
189  $this->moduleManager->updateRevision(
190  'Magento_TestSetupDeclarationModule7',
191  'wl_remove_table',
192  'db_schema_whitelist.json',
193  'etc'
194  );
195  //Check removal case, when we need to remove table with declaration and table was created in old scripts
196  $this->cliCommand->upgrade();
197  $tables = $this->dbSchemaReader->readTables('default');
198  self::assertNotContains('custom_table', $tables);
199  }

◆ testFirstCleanInstall()

testFirstCleanInstall ( )

@moduleName Magento_TestSetupDeclarationModule6 @moduleName Magento_TestSetupDeclarationModule7

Definition at line 69 of file BCMultiModuleTest.php.

70  {
71  $this->cliCommand->install([
72  'Magento_TestSetupDeclarationModule6',
73  'Magento_TestSetupDeclarationModule7'
74  ]);
75  //Check if declaration is applied
76  $indexes = $this->dbSchemaReader->readIndexes('test_table', 'default');
77  self::assertCount(1, $indexes);
78  self::assertArrayHasKey('TEST_TABLE_TINYINT_BIGINT', $indexes);
79  //Check UpgradeSchema old format, that modify declaration
80  $columns = $this->dbSchemaReader->readColumns('test_table', 'default');
81  $floatColumn = $columns['float'];
82  self::assertEquals(29, $floatColumn['default']);
83  }
$columns
Definition: default.phtml:15

◆ testFirstCleanInstallOneModule()

testFirstCleanInstallOneModule ( string  $dbPrefix,
string  $tableName,
string  $indexName,
string  $constraintName,
string  $foreignKeyName 
)

@moduleName Magento_TestSetupDeclarationModule1 @dataProvider firstCleanInstallOneModuleDataProvider

Parameters
string$dbPrefix
string$tableName
string$indexName
string$constraintName
string$foreignKeyName
Exceptions

Definition at line 211 of file BCMultiModuleTest.php.

217  {
218  $this->cliCommand->install(
219  [
220  'Magento_TestSetupDeclarationModule1'
221  ],
222  [
223  'db-prefix' => $dbPrefix,
224  ]
225  );
226 
227  $indexes = $this->dbSchemaReader
228  ->readIndexes($tableName, 'default');
229  self::assertCount(1, $indexes);
230  self::assertArrayHasKey($indexName, $indexes);
231 
232  $constraints = $this->dbSchemaReader
233  ->readConstraints($tableName, 'default');
234  self::assertCount(1, $constraints);
235  self::assertArrayHasKey($constraintName, $constraints);
236 
237  $foreignKeys = $this->dbSchemaReader
238  ->readReferences($tableName, 'default');
239  self::assertCount(1, $foreignKeys);
240  self::assertArrayHasKey($foreignKeyName, $foreignKeys);
241  }
$tableName
Definition: trigger.php:13

The documentation for this class was generated from the following file: