Skip to content

Commit 83cfcfd

Browse files
author
Sergii Kovalenko
committed
MAGETWO-88047: Create integration test for Mixed Mode
1 parent 10ed821 commit 83cfcfd

File tree

19 files changed

+774
-4
lines changed

19 files changed

+774
-4
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/schema.xsd">
10+
<table name="reference_table" resource="sales">
11+
<column xsi:type="tinyint" name="tinyint_ref" padding="7" nullable="false" identity="true" unsigned="false"/>
12+
<column xsi:type="tinyint" name="tinyint_without_padding" default="0" nullable="false" unsigned="false"/>
13+
<column xsi:type="bigint" name="bigint_without_padding" default="0" nullable="false" unsigned="false"/>
14+
<column xsi:type="smallint" name="smallint_without_padding" default="0" nullable="false" unsigned="false"/>
15+
<column xsi:type="int" name="integer_without_padding" default="0" nullable="false" unsigned="false"/>
16+
<column xsi:type="smallint" name="smallint_with_big_padding" padding="254" default="0" nullable="false"
17+
unsigned="false"/>
18+
<column xsi:type="smallint" name="smallint_without_default" padding="2" nullable="true" unsigned="false"/>
19+
<column xsi:type="int" name="int_without_unsigned" padding="2" nullable="true"/>
20+
<column xsi:type="int" name="int_unsigned" padding="2" nullable="true" unsigned="true"/>
21+
<column xsi:type="bigint" name="bigint_default_nullable" padding="2" nullable="true" default="1"
22+
unsigned="true"/>
23+
<column xsi:type="bigint" name="bigint_not_default_not_nullable" padding="2" nullable="false" unsigned="true"/>
24+
<constraint xsi:type="primary" name="tinyint_primary">
25+
<column name="tinyint_ref"/>
26+
</constraint>
27+
</table>
28+
<table name="auto_increment_test" resource="default">
29+
<column xsi:type="int" name="int_auto_increment_with_nullable" identity="true" padding="12" unsigned="true"
30+
nullable="true"/>
31+
<column xsi:type="smallint" name="int_disabled_auto_increment" default="0" identity="false" padding="12"
32+
unsigned="true" nullable="true"/>
33+
<constraint xsi:type="unique" name="unique_null_key">
34+
<column name="int_auto_increment_with_nullable"/>
35+
</constraint>
36+
</table>
37+
<table name="test_table" resource="default">
38+
<!--Columns-->
39+
<column xsi:type="smallint" identity="true" name="smallint" padding="3" nullable="true"/>
40+
<column xsi:type="tinyint" name="tinyint" padding="7" nullable="true" unsigned="false"/>
41+
<column xsi:type="bigint" name="bigint" default="0" padding="13" nullable="true" unsigned="false"/>
42+
<column xsi:type="float" name="float" default="0" scale="4" precision="12"/>
43+
<column xsi:type="decimal" name="double" default="11111111.111111" precision="14" scale="6"/>
44+
<column xsi:type="decimal" name="decimal" default="0" scale="4" precision="15"/>
45+
<column xsi:type="date" name="date"/>
46+
<column xsi:type="timestamp" name="timestamp" default="CURRENT_TIMESTAMP" on_update="true"/>
47+
<column xsi:type="datetime" name="datetime" default="0"/>
48+
<column xsi:type="longtext" name="longtext"/>
49+
<column xsi:type="mediumtext" name="mediumtext"/>
50+
<column xsi:type="varchar" name="varchar" length="254" nullable="true"/>
51+
<column xsi:type="mediumblob" name="mediumblob"/>
52+
<column xsi:type="blob" name="blob"/>
53+
<column xsi:type="boolean" name="boolean"/>
54+
<column xsi:type="varbinary" name="varbinary_rename" default="10101" disabled="true"/>
55+
<!--Constraints-->
56+
<constraint xsi:type="unique" name="some_unique_key">
57+
<column name="smallint"/>
58+
<column name="bigint"/>
59+
</constraint>
60+
<constraint xsi:type="foreign" name="some_foreign_key" column="tinyint" table="test_table"
61+
referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="NO ACTION"/>
62+
<!--Indexes-->
63+
<index name="speedup_index" indexType="btree">
64+
<column name="tinyint"/>
65+
<column name="bigint"/>
66+
</index>
67+
</table>
68+
</schema>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"reference_table": {
3+
"column": {
4+
"tinyint_ref": true,
5+
"tinyint_without_padding": true,
6+
"bigint_without_padding": true,
7+
"integer_without_padding": true,
8+
"smallint_with_big_padding": true,
9+
"smallint_without_default": true,
10+
"int_without_unsigned": true,
11+
"int_unsigned": true,
12+
"bigint_default_nullable": true,
13+
"bigint_not_default_not_nullable": true,
14+
"smallint_without_padding": true
15+
},
16+
"constraint": {
17+
"tinyint_primary": true
18+
}
19+
},
20+
"auto_increment_test": {
21+
"column": {
22+
"int_auto_increment_with_nullable": true,
23+
"int_disabled_auto_increment": true
24+
},
25+
"constraint": {
26+
"unique_null_key": true
27+
}
28+
},
29+
"test_table": {
30+
"column": {
31+
"smallint": true,
32+
"tinyint": true,
33+
"bigint": true,
34+
"float": true,
35+
"double": true,
36+
"decimal": true,
37+
"date": true,
38+
"timestamp": true,
39+
"datetime": true,
40+
"longtext": true,
41+
"mediumtext": true,
42+
"varchar": true,
43+
"mediumblob": true,
44+
"blob": true,
45+
"boolean": true,
46+
"varbinary_rename": true
47+
},
48+
"index": {
49+
"speedup_index": true
50+
},
51+
"constraint": {
52+
"some_unique_key": true,
53+
"some_foreign_key": true
54+
}
55+
}
56+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_TestSetupDeclarationModule6" />
10+
</config>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Framework\Component\ComponentRegistrar;
8+
9+
$registrar = new ComponentRegistrar();
10+
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule6') === null) {
11+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule6', __DIR__);
12+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\TestSetupDeclarationModule7\Setup;
8+
9+
use Magento\Framework\Setup\InstallSchemaInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\SchemaSetupInterface;
12+
13+
/**
14+
* InstallSchema mock class
15+
*/
16+
class InstallSchema implements InstallSchemaInterface
17+
{
18+
/**
19+
* {@inheritdoc}
20+
*
21+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
22+
*/
23+
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
24+
{
25+
$installer = $setup;
26+
$installer->startSetup();
27+
$installer
28+
->getConnection()
29+
->modifyColumn('test_table', 'float', ['type' => 'float', 'default' => 25]);
30+
$installer->endSetup();
31+
}
32+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\TestSetupDeclarationModule7\Setup;
7+
8+
use Magento\Framework\Setup\ModuleContextInterface;
9+
use Magento\Framework\Setup\ModuleDataSetupInterface;
10+
use Magento\Framework\Setup\UpgradeDataInterface;
11+
12+
/**
13+
* Class UpgradeData
14+
* @package Magento\TestSetupDeclarationModule7\Setup
15+
*/
16+
class UpgradeData implements UpgradeDataInterface
17+
{
18+
/**
19+
* {@inheritdoc}
20+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
21+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
22+
* @SuppressWarnings(PHPMD.NPathComplexity)
23+
*/
24+
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
25+
{
26+
$adapter = $setup->getConnection();
27+
$setup->startSetup();
28+
29+
if (version_compare($context->getVersion(), '2.0.0') < 0) {
30+
$adapter->insertArray('reference_table', ['bigint_without_padding'], [6, 12, 7]);
31+
}
32+
33+
$setup->endSetup();
34+
}
35+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\TestSetupDeclarationModule7\Setup;
8+
9+
use Magento\Framework\Setup\InstallSchemaInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\SchemaSetupInterface;
12+
use Magento\Framework\Setup\UpgradeSchemaInterface;
13+
14+
/**
15+
* UpgradeSchema mock class
16+
*/
17+
class UpgradeSchema implements UpgradeSchemaInterface
18+
{
19+
/**
20+
* {@inheritdoc}
21+
*
22+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
23+
*/
24+
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
25+
{
26+
$installer = $setup;
27+
$installer->startSetup();
28+
29+
if (version_compare($context->getVersion(), '2.0.1') < 0) {
30+
$installer
31+
->getConnection()
32+
->modifyColumn('test_table', 'float', ['type' => 'float', 'default' => 29]);
33+
}
34+
35+
$installer->endSetup();
36+
}
37+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_TestSetupDeclarationModule7" setup_version="2.0.1">
10+
<sequence>
11+
<module name="Magento_TestSetupDeclarationModule6" />
12+
</sequence>
13+
</module>
14+
</config>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Framework\Component\ComponentRegistrar;
8+
9+
$registrar = new ComponentRegistrar();
10+
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule7') === null) {
11+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule7', __DIR__);
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\TestSetupDeclarationModule7\Setup\Patch\Data;
7+
8+
use Magento\Framework\App\ResourceConnection;
9+
use Magento\Setup\Model\Patch\DataPatchInterface;
10+
use Magento\Setup\Model\Patch\PatchRevertableInterface;
11+
use Magento\Setup\Model\Patch\PatchVersionInterface;
12+
13+
/**
14+
* Class SomePatch
15+
* @package Magento\TestSetupDeclarationModule3\Setup
16+
*/
17+
class SomePatch implements
18+
DataPatchInterface,
19+
PatchRevertableInterface,
20+
PatchVersionInterface
21+
{
22+
/**
23+
* @var ResourceConnection
24+
*/
25+
private $resourceConnection;
26+
27+
/**
28+
* IncrementalSomeIntegerPatch constructor.
29+
* @param ResourceConnection $resourceConnection
30+
*/
31+
public function __construct(ResourceConnection $resourceConnection)
32+
{
33+
$this->resourceConnection = $resourceConnection;
34+
}
35+
36+
/**
37+
* @return string
38+
*/
39+
public static function getVersion()
40+
{
41+
return '2.0.4';
42+
}
43+
44+
/**
45+
* @return array
46+
*/
47+
public function getAliases()
48+
{
49+
return [];
50+
}
51+
52+
/**
53+
* @inheritdoc
54+
*/
55+
public function apply()
56+
{
57+
$adapter = $this->resourceConnection->getConnection();
58+
$adapter->insert('test_table', ['varchar' => "_ref"]);
59+
}
60+
61+
public function revert()
62+
{
63+
}
64+
65+
/**
66+
* @return array
67+
*/
68+
public static function getDependencies()
69+
{
70+
return [];
71+
}
72+
}

0 commit comments

Comments
 (0)