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

Public Member Functions

 setUp ()
 
 testOldDiff ()
 
 testOldSchemaUpgrade (string $dbPrefix)
 
 oldSchemaUpgradeDataProvider ()
 
- Public Member Functions inherited from SetupTestCase
 setData (array $data)
 
 flushData ()
 
 getData ()
 

Detailed Description

The purpose of this test is verifying initial InstallSchema, InstallData scripts.

Definition at line 20 of file DiffOldSchemaTest.php.

Member Function Documentation

◆ oldSchemaUpgradeDataProvider()

oldSchemaUpgradeDataProvider ( )
Returns
array

Definition at line 139 of file DiffOldSchemaTest.php.

139  : array
140  {
141  return [
142  'Without db prefix' => [
143  'dbPrefix' => '',
144  ],
145  'With db prefix' => [
146  'dbPrefix' => 'spec_',
147  ],
148  ];
149  }

◆ setUp()

setUp ( )

Definition at line 47 of file DiffOldSchemaTest.php.

48  {
50  $this->moduleManager = $objectManager->get(TestModuleManager::class);
51  $this->cliCommad = $objectManager->get(CliCommand::class);
52  $this->schemaConfig = $objectManager->get(SchemaConfigInterface::class);
53  $this->schemaDiff = $objectManager->get(SchemaDiff::class);
54  $this->changeRegistryFactory = $objectManager->get(DiffFactory::class);
55  }
$objectManager
Definition: bootstrap.php:17

◆ testOldDiff()

testOldDiff ( )

@moduleName Magento_TestSetupDeclarationModule1

Definition at line 60 of file DiffOldSchemaTest.php.

61  {
62  //Move db_schema.xml
63  $this->moduleManager->updateRevision(
64  'Magento_TestSetupDeclarationModule1',
65  'old_diff_before',
66  'db_schema.xml',
67  'etc'
68  );
69  //Move InstallSchema file and tried to install
70  $this->moduleManager->updateRevision(
71  'Magento_TestSetupDeclarationModule1',
72  'old_diff',
73  'InstallSchema.php',
74  'Setup'
75  );
76  $this->cliCommad->install(['Magento_TestSetupDeclarationModule1']);
77  //Move db_schema.xml
78  $this->moduleManager->updateRevision(
79  'Magento_TestSetupDeclarationModule1',
80  'old_diff',
81  'db_schema.xml',
82  'etc'
83  );
84  $declarativeSchema = $this->schemaConfig->getDeclarationConfig();
85  $generatedSchema = $this->schemaConfig->getDbConfig();
86  $diff = $this->schemaDiff->diff($declarativeSchema, $generatedSchema);
87  $allChanges = $diff->getAll();
88  self::assertCount(1, $allChanges);
89  self::assertEquals(
90  $this->getBigIntKeyXmlSensitiveData(),
91  reset($allChanges)['modify_column'][0]->getNew()->getDiffSensitiveParams()
92  );
93  self::assertEquals(
94  $this->getBigIntKeyDbSensitiveData(),
95  reset($allChanges)['modify_column'][0]->getOld()->getDiffSensitiveParams()
96  );
97  }

◆ testOldSchemaUpgrade()

testOldSchemaUpgrade ( string  $dbPrefix)

@moduleName Magento_TestSetupDeclarationModule1

Parameters
string$dbPrefix
Exceptions

Definition at line 105 of file DiffOldSchemaTest.php.

106  {
107  $this->moduleManager->updateRevision(
108  'Magento_TestSetupDeclarationModule1',
109  'old_diff_before',
110  'db_schema.xml',
111  'etc'
112  );
113  $this->moduleManager->updateRevision(
114  'Magento_TestSetupDeclarationModule1',
115  'base_update',
116  'InstallSchema.php',
117  'Setup'
118  );
119  $this->cliCommad->install(
120  ['Magento_TestSetupDeclarationModule1'],
121  ['db-prefix' => $dbPrefix]
122  );
123  //Move db_schema.xml
124  $this->moduleManager->updateRevision(
125  'Magento_TestSetupDeclarationModule1',
126  'base_update',
127  'db_schema.xml',
128  'etc'
129  );
130  $declarativeSchema = $this->schemaConfig->getDeclarationConfig();
131  $generatedSchema = $this->schemaConfig->getDbConfig();
132  $diff = $this->schemaDiff->diff($declarativeSchema, $generatedSchema);
133  self::assertEmpty($diff->getAll());
134  }

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