27 private $moduleManager;
37 private $dbVersionInfo;
47 private $moduleResource;
52 private $dbSchemaReader;
57 $this->moduleManager =
$objectManager->get(TestModuleManager::class);
61 $this->moduleResource =
$objectManager->get(ModuleResource::class);
62 $this->dbSchemaReader =
$objectManager->get(DbSchemaReaderInterface::class);
71 $this->cliCommand->install([
72 'Magento_TestSetupDeclarationModule6',
73 'Magento_TestSetupDeclarationModule7' 76 $indexes = $this->dbSchemaReader->readIndexes(
'test_table',
'default');
77 self::assertCount(1, $indexes);
78 self::assertArrayHasKey(
'TEST_TABLE_TINYINT_BIGINT', $indexes);
80 $columns = $this->dbSchemaReader->readColumns(
'test_table',
'default');
82 self::assertEquals(29, $floatColumn[
'default']);
85 private function doUsToUsRevision()
87 $this->moduleManager->updateRevision(
88 'Magento_TestSetupDeclarationModule7',
93 $this->moduleManager->updateRevision(
94 'Magento_TestSetupDeclarationModule7',
99 $this->moduleManager->updateRevision(
100 'Magento_TestSetupDeclarationModule7',
107 private function doUsToDsRevision()
109 $this->moduleManager->updateRevision(
110 'Magento_TestSetupDeclarationModule7',
111 'swap_with_declaration',
115 $this->moduleManager->updateRevision(
116 'Magento_TestSetupDeclarationModule7',
117 'swap_with_declaration',
121 $this->moduleManager->updateRevision(
122 'Magento_TestSetupDeclarationModule7',
123 'swap_with_declaration',
124 'SomeSkippedPatch.php',
132 private function assertUsToUsUpgrade()
134 $usToUsTables = $this->dbSchemaReader->readTables(
'default');
135 self::assertContains(
'custom_table', $usToUsTables);
136 self::assertTrue($this->dbVersionInfo->isDataUpToDate(
'Magento_TestSetupDeclarationModule7'));
137 self::assertTrue($this->dbVersionInfo->isSchemaUpToDate(
'Magento_TestSetupDeclarationModule7'));
140 $this->tableData->describeTableData(
'reference_table',
'bigint_without_padding')
147 private function assertUsToDsUpgrade()
150 $columns = $this->dbSchemaReader->readColumns(
'test_table',
'default');
153 self::assertEquals(35, $floatColumn[
'default']);
154 self::assertTrue($this->dbVersionInfo->isDataUpToDate(
'Magento_TestSetupDeclarationModule7'));
155 self::assertTrue($this->dbVersionInfo->isSchemaUpToDate(
'Magento_TestSetupDeclarationModule7'));
158 $this->tableData->describeTableData(
'reference_table',
'bigint_without_padding')
162 $this->tableData->describeTableData(
'test_table',
'varchar')
172 $this->cliCommand->install([
173 'Magento_TestSetupDeclarationModule6',
174 'Magento_TestSetupDeclarationModule7' 177 $this->cliCommand->upgrade();
179 $this->doUsToUsRevision();
181 $this->cliCommand->upgrade();
182 $this->assertUsToUsUpgrade();
184 $this->doUsToDsRevision();
186 $this->cliCommand->upgrade();
187 $this->assertUsToDsUpgrade();
189 $this->moduleManager->updateRevision(
190 'Magento_TestSetupDeclarationModule7',
192 'db_schema_whitelist.json',
196 $this->cliCommand->upgrade();
197 $tables = $this->dbSchemaReader->readTables(
'default');
198 self::assertNotContains(
'custom_table', $tables);
215 string $constraintName,
216 string $foreignKeyName
218 $this->cliCommand->install(
220 'Magento_TestSetupDeclarationModule1' 223 'db-prefix' => $dbPrefix,
227 $indexes = $this->dbSchemaReader
229 self::assertCount(1, $indexes);
230 self::assertArrayHasKey($indexName, $indexes);
232 $constraints = $this->dbSchemaReader
234 self::assertCount(1, $constraints);
235 self::assertArrayHasKey($constraintName, $constraints);
237 $foreignKeys = $this->dbSchemaReader
239 self::assertCount(1, $foreignKeys);
240 self::assertArrayHasKey($foreignKeyName, $foreignKeys);
249 'Installation without db prefix' => [
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',
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',
testFirstCleanInstallOneModule(string $dbPrefix, string $tableName, string $indexName, string $constraintName, string $foreignKeyName)
firstCleanInstallOneModuleDataProvider()
static getObjectManager()