7
7
8
8
namespace Magento \Setup \Declaration ;
9
9
10
+ use Magento \Framework \App \ResourceConnection ;
10
11
use Magento \Framework \App \Utility \Files ;
11
12
use Magento \Framework \Component \ComponentRegistrar ;
12
13
use Magento \Framework \Component \ComponentRegistrarInterface ;
14
+ use Magento \Framework \ObjectManagerInterface ;
13
15
use Magento \Framework \Setup \Declaration \Schema \Dto \Constraint ;
14
16
use Magento \Framework \Setup \Declaration \Schema \Dto \Index ;
15
- use Magento \Framework \Setup \Declaration \Schema \Dto \Schema ;
16
17
use Magento \Framework \Setup \Declaration \Schema \SchemaConfigInterface ;
17
18
use Magento \TestFramework \Helper \Bootstrap ;
19
+ use Magento \TestFramework \ObjectManager ;
18
20
19
21
/**
20
22
* Class WhitelistDeclarationTest
@@ -25,31 +27,37 @@ class WhitelistDeclarationTest extends \PHPUnit\Framework\TestCase
25
27
* @var ComponentRegistrarInterface
26
28
*/
27
29
private $ componentRegistrar ;
30
+
28
31
/**
29
- * @var Schema
32
+ * @var SchemaConfigInterface
30
33
*/
31
- private $ declarativeSchema ;
34
+ private $ schemaConfig ;
32
35
33
36
public function setUp ()
34
37
{
38
+ /** @var ObjectManagerInterface|ObjectManager $objectManager */
35
39
$ objectManager = Bootstrap::getObjectManager ();
36
- $ schemaConfig = $ objectManager ->get (SchemaConfigInterface::class);
37
- $ this ->declarativeSchema = $ schemaConfig ->getDeclarationConfig ();
40
+ $ resourceConnection = $ objectManager ->create (ResourceConnection::class);
41
+ $ objectManager ->removeSharedInstance (ResourceConnection::class);
42
+ $ objectManager ->addSharedInstance ($ resourceConnection , ResourceConnection::class);
38
43
$ this ->componentRegistrar = $ objectManager ->get (ComponentRegistrarInterface::class);
44
+ $ this ->schemaConfig = $ objectManager ->create (SchemaConfigInterface::class);
39
45
}
40
46
41
47
/**
42
48
* Checks that all declared table elements also declared into whitelist declaration.
43
49
*
50
+ * @appIsolation
44
51
* @throws \Exception
45
52
*/
46
53
public function testConstraintsAndIndexesAreWhitelisted ()
47
54
{
48
55
$ undeclaredElements = [];
49
56
$ resultMessage = "New table elements that do not exist in the whitelist declaration: \n" ;
50
57
$ whitelistTables = $ this ->getWhiteListTables ();
58
+ $ declarativeSchema = $ this ->schemaConfig ->getDeclarationConfig ();
51
59
52
- foreach ($ this -> declarativeSchema ->getTables () as $ schemaTable ) {
60
+ foreach ($ declarativeSchema ->getTables () as $ schemaTable ) {
53
61
$ tableNameWithoutPrefix = $ schemaTable ->getNameWithoutPrefix ();
54
62
foreach ($ schemaTable ->getConstraints () as $ constraint ) {
55
63
$ constraintNameWithoutPrefix = $ constraint ->getNameWithoutPrefix ();
0 commit comments