-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1645 from magento-honey-badgers/declarative_schem…
…a_test [Honey Badgers] Declarative schema: new test framework
- Loading branch information
Showing
31 changed files
with
3,415 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/*.xml | ||
/var/ | ||
/etc/*.php |
168 changes: 168 additions & 0 deletions
168
dev/tests/setup-integration/_files/Magento/TestSetupModule1/Setup/InstallSchema.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\TestSetupModule1\Setup; | ||
|
||
use Magento\Framework\Setup\InstallSchemaInterface; | ||
use Magento\Framework\Setup\ModuleContextInterface; | ||
use Magento\Framework\Setup\SchemaSetupInterface; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
class InstallSchema implements InstallSchemaInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) | ||
*/ | ||
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) | ||
{ | ||
$installer = $setup; | ||
|
||
$installer->startSetup(); | ||
|
||
/** | ||
* Create table 'setup_table1' | ||
*/ | ||
$table = $installer->getConnection()->newTable( | ||
$installer->getTable('setup_tests_table1') | ||
)->addColumn( | ||
'column_with_type_boolean', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN, | ||
null, | ||
['nullable' => false, 'default' => 0], | ||
'Column with type boolean' | ||
)->addColumn( | ||
'column_with_type_smallint', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, | ||
null, | ||
['unsigned' => true, 'nullable' => false, 'default' => '0'], | ||
'Column with type smallint' | ||
)->addColumn( | ||
'column_with_type_integer', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, | ||
null, | ||
['unsigned' => true, 'identity' => true, 'nullable' => false, 'primary' => true], | ||
'Column with type integer' | ||
)->addColumn( | ||
'column_with_type_bigint', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_BIGINT, | ||
null, | ||
['unsigned' => true, 'nullable' => false, 'primary' => true], | ||
'Column with type bigint' | ||
)->addColumn( | ||
'column_with_type_float', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_FLOAT, | ||
null, | ||
['nullable' => true, 'default' => null], | ||
'Column with type float' | ||
)->addColumn( | ||
'column_with_type_numeric', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_NUMERIC, | ||
'12,4', | ||
['unsigned' => true, 'nullable' => true], | ||
'Column with type numeric' | ||
)->addColumn( | ||
'column_with_type_decimal', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, | ||
'12,4', | ||
['unsigned' => true, 'nullable' => true], | ||
'Column with type decimal' | ||
)->addColumn( | ||
'column_with_type_datetime', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_DATETIME, | ||
null, | ||
['nullable' => true, 'default' => null], | ||
'Column with type datetime' | ||
)->addColumn( | ||
'column_with_type_timestamp_update', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, | ||
null, | ||
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_UPDATE], | ||
'Column with type timestamp update' | ||
)->addColumn( | ||
'column_with_type_date', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_DATE, | ||
null, | ||
['nullable' => true, 'default' => null], | ||
'Column with type date' | ||
)->addColumn( | ||
'column_with_type_text', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT, | ||
'64k', | ||
[], | ||
'Column with type text' | ||
)->addColumn( | ||
'column_with_type_blob', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_BLOB, | ||
32, | ||
[], | ||
'Column with type blob' | ||
)->addColumn( | ||
'column_with_type_verbinary', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_VARBINARY, | ||
'2m', | ||
[], | ||
'Column with type varbinary' | ||
)->addIndex( | ||
$installer->getIdxName( | ||
'setup_tests_table1', | ||
['column_with_type_text'], | ||
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT | ||
), | ||
['column_with_type_text'], | ||
['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT] | ||
)->addIndex( | ||
$installer->getIdxName( | ||
'setup_tests_table1', | ||
'column_with_type_integer', | ||
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX | ||
), | ||
'column_with_type_integer', | ||
['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX] | ||
); | ||
|
||
$installer->getConnection()->createTable($table); | ||
|
||
$relatedTable = $installer->getConnection()->newTable( | ||
$installer->getTable('setup_tests_table1_related') | ||
)->addColumn( | ||
'column_with_type_timestamp_init_update', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, | ||
null, | ||
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], | ||
'Column with type timestamp init update' | ||
)->addColumn( | ||
'column_with_type_timestamp_init', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, | ||
null, | ||
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], | ||
'Column with type timestamp init' | ||
)->addColumn( | ||
'column_with_relation', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, | ||
null, | ||
['unsigned' => true, 'nullable' => false], | ||
'Column with type integer and relation' | ||
)->addForeignKey( | ||
$installer->getFkName( | ||
'setup_table1_related', | ||
'column_with_relation', | ||
'setup_tests_table1', | ||
'column_with_type_integer' | ||
), | ||
'column_with_relation', | ||
$installer->getTable('setup_tests_table1'), | ||
'column_with_type_integer', | ||
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE | ||
)->setComment( | ||
'Related Table' | ||
); | ||
$installer->getConnection()->createTable($relatedTable); | ||
$installer->endSetup(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
dev/tests/setup-integration/_files/Magento/TestSetupModule1/etc/module.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Magento_TestSetupModule1" setup_version="0.0.1"/> | ||
</config> |
12 changes: 12 additions & 0 deletions
12
dev/tests/setup-integration/_files/Magento/TestSetupModule1/registration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
|
||
$registrar = new ComponentRegistrar(); | ||
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestSetupModule1') === null) { | ||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestSetupModule1', __DIR__); | ||
} |
62 changes: 62 additions & 0 deletions
62
dev/tests/setup-integration/_files/Magento/TestSetupModule2/Setup/InstallData.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\TestSetupModule2\Setup; | ||
|
||
use Magento\Framework\Setup\InstallDataInterface; | ||
use Magento\Framework\Setup\ModuleContextInterface; | ||
use Magento\Framework\Setup\ModuleDataSetupInterface; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
class InstallData implements InstallDataInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) | ||
*/ | ||
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) | ||
{ | ||
$setup->startSetup(); | ||
|
||
$setup->getConnection()->insertForce( | ||
$setup->getTable('setup_tests_entity_table'), | ||
[ | ||
'website_id' => 1, | ||
'email_field' => 'entity@example.com', | ||
'created_at' => '2017-10-30 09:41:25', | ||
'updated_at' => '2017-10-30 09:45:05', | ||
'created_in' => 'Default Store View', | ||
'firstname' => 'John', | ||
'lastname' => 'Doe', | ||
'dob' => '1973-12-15', | ||
'default_billing_address_id' => 1, | ||
'default_shipping_address_id' => 1 | ||
] | ||
); | ||
$setup->getConnection()->insertForce( | ||
$setup->getTable('setup_tests_address_entity'), | ||
[ | ||
'parent_id' => 1, | ||
'created_at' => '2017-10-30 09:45:05', | ||
'updated_at' => '2017-10-30 09:45:05', | ||
'is_active' => 1, | ||
'city' => 'city', | ||
'company' => 'Magento', | ||
'country_id' => 'US', | ||
'firstname' => 'John', | ||
'lastname' => 'Doe', | ||
'postcode' => '90210', | ||
'region' => 'Alabama', | ||
'region_id' => 1, | ||
'street' => 'street1', | ||
'telephone' => 12345678, | ||
] | ||
); | ||
|
||
$setup->endSetup(); | ||
} | ||
} |
Oops, something went wrong.