Skip to content

Commit 2db410a

Browse files
author
Sergii Kovalenko
committed
MAGETWO-81030: Schema Validation
1 parent 80adf8a commit 2db410a

File tree

3 files changed

+100
-59
lines changed

3 files changed

+100
-59
lines changed

dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ protected function _getSubscribers(\Magento\TestFramework\Application $applicati
3333
new \Magento\TestFramework\Annotation\ComponentRegistrarFixture($this->_fixturesBaseDir),
3434
new \Magento\TestFramework\Annotation\SchemaFixture($this->_fixturesBaseDir),
3535
new \Magento\TestFramework\Annotation\Cache(),
36-
new AppIsolation($application),
3736
new \Magento\TestFramework\Workaround\CacheClean(),
3837
new \Magento\TestFramework\Annotation\ReinstallInstance($application),
3938
new \Magento\TestFramework\Annotation\CopyModules(),

dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -83,62 +83,4 @@ public function testSchemaBuilder()
8383
self::assertEquals('NO ACTION', $foreignKey->getOnDelete());
8484
self::assertEquals('tinyint_ref', $foreignKey->getReferenceColumn()->getName());
8585
}
86-
87-
/**
88-
* @expectedException \Magento\Setup\Exception
89-
* @expectedExceptionMessageRegExp /Primary key can`t be applied on table "test_table". All columns should be not nullable/
90-
* @moduleName Magento_TestSetupDeclarationModule8
91-
*/
92-
public function testFailOnInvalidPrimaryKey()
93-
{
94-
$this->cliCommad->install(
95-
['Magento_TestSetupDeclarationModule8']
96-
);
97-
$this->moduleManager->updateRevision(
98-
'Magento_TestSetupDeclarationModule8',
99-
'invalid_primary_key',
100-
'db_schema.xml',
101-
'etc'
102-
);
103-
104-
$this->schemaConfig->getDeclarationConfig();
105-
}
106-
107-
/**
108-
* @expectedException \Magento\Setup\Exception
109-
* @expectedExceptionMessageRegExp /Column definition "page_id_on" and reference column definition "page_id" are different in tables "dependent" and "test_table"/
110-
* @moduleName Magento_TestSetupDeclarationModule8
111-
*/
112-
public function testFailOnIncosistentReferenceDefinition()
113-
{
114-
$this->cliCommad->install(
115-
['Magento_TestSetupDeclarationModule8']
116-
);
117-
$this->moduleManager->updateRevision(
118-
'Magento_TestSetupDeclarationModule8',
119-
'incosistence_reference_definition',
120-
'db_schema.xml',
121-
'etc'
122-
);
123-
$this->schemaConfig->getDeclarationConfig();
124-
}
125-
126-
/**
127-
* @expectedException \Magento\Setup\Exception
128-
* @expectedExceptionMessageRegExp /Auto Increment column do not have index. Column - "page_id"/
129-
* @moduleName Magento_TestSetupDeclarationModule8
130-
*/
131-
public function testFailOnInvalidAutoIncrementFiel()
132-
{
133-
$this->cliCommad->install(
134-
['Magento_TestSetupDeclarationModule8']
135-
);
136-
$this->moduleManager->updateRevision(
137-
'Magento_TestSetupDeclarationModule8',
138-
'invalid_auto_increment',
139-
'db_schema.xml',
140-
'etc'
141-
);
142-
$this->schemaConfig->getDeclarationConfig();
143-
}
14486
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Setup;
8+
9+
use Magento\Setup\Model\Declaration\Schema\SchemaConfig;
10+
use Magento\TestFramework\Deploy\CliCommand;
11+
use Magento\TestFramework\Deploy\TestModuleManager;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
use Magento\TestFramework\TestCase\SetupTestCase;
14+
15+
/**
16+
* The purpose of this test is verifying initial InstallSchema, InstallData scripts.
17+
*/
18+
class ValidationRulesTest extends SetupTestCase
19+
{
20+
/**
21+
* @var TestModuleManager
22+
*/
23+
private $moduleManager;
24+
25+
/**
26+
* @var SchemaConfig
27+
*/
28+
private $schemaConfig;
29+
30+
/**
31+
* @var CliCommand
32+
*/
33+
private $cliCommad;
34+
35+
public function setUp()
36+
{
37+
$objectManager = Bootstrap::getObjectManager();
38+
$this->schemaConfig = $objectManager->create(SchemaConfig::class);
39+
$this->moduleManager = $objectManager->get(TestModuleManager::class);
40+
$this->cliCommad = $objectManager->get(CliCommand::class);
41+
}
42+
43+
/**
44+
* @expectedException \Magento\Setup\Exception
45+
* @expectedExceptionMessageRegExp /Primary key can`t be applied on table "test_table". All columns should be not nullable/
46+
* @moduleName Magento_TestSetupDeclarationModule8
47+
*/
48+
public function testFailOnInvalidPrimaryKey()
49+
{
50+
$this->cliCommad->install(
51+
['Magento_TestSetupDeclarationModule8']
52+
);
53+
$this->moduleManager->updateRevision(
54+
'Magento_TestSetupDeclarationModule8',
55+
'invalid_primary_key',
56+
'db_schema.xml',
57+
'etc'
58+
);
59+
60+
$this->schemaConfig->getDeclarationConfig();
61+
}
62+
63+
/**
64+
* @expectedException \Magento\Setup\Exception
65+
* @expectedExceptionMessageRegExp /Column definition "page_id_on" and reference column definition "page_id" are different in tables "dependent" and "test_table"/
66+
* @moduleName Magento_TestSetupDeclarationModule8
67+
*/
68+
public function testFailOnIncosistentReferenceDefinition()
69+
{
70+
$this->cliCommad->install(
71+
['Magento_TestSetupDeclarationModule8']
72+
);
73+
$this->moduleManager->updateRevision(
74+
'Magento_TestSetupDeclarationModule8',
75+
'incosistence_reference_definition',
76+
'db_schema.xml',
77+
'etc'
78+
);
79+
$this->schemaConfig->getDeclarationConfig();
80+
}
81+
82+
/**
83+
* @expectedException \Magento\Setup\Exception
84+
* @expectedExceptionMessageRegExp /Auto Increment column do not have index. Column - "page_id"/
85+
* @moduleName Magento_TestSetupDeclarationModule8
86+
*/
87+
public function testFailOnInvalidAutoIncrementFiel()
88+
{
89+
$this->cliCommad->install(
90+
['Magento_TestSetupDeclarationModule8']
91+
);
92+
$this->moduleManager->updateRevision(
93+
'Magento_TestSetupDeclarationModule8',
94+
'invalid_auto_increment',
95+
'db_schema.xml',
96+
'etc'
97+
);
98+
$this->schemaConfig->getDeclarationConfig();
99+
}
100+
}

0 commit comments

Comments
 (0)