Skip to content

Commit 81572f0

Browse files
committed
MAGETWO-56586: Implement Data and Schema Upgrade Test
1 parent bcdd65f commit 81572f0

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
*
4+
* Scan source code for DB schema or data updates for patch releases in non-actual branches
5+
* Backwards compatibility test
6+
*
7+
* Copyright © 2016 Magento. All rights reserved.
8+
* See COPYING.txt for license details.
9+
*/
10+
namespace Magento\Test\Legacy;
11+
12+
13+
class ModuleDBChangeTest extends \PHPUnit_Framework_TestCase
14+
{
15+
16+
/**
17+
* @var string
18+
*/
19+
protected static $changedFilesPattern = __DIR__ . '/../_files/changed_files*';
20+
21+
/**
22+
* @var string
23+
*/
24+
protected static $changedFileList = '';
25+
26+
/**
27+
* Set changed files paths and list for all projects
28+
*/
29+
public static function setUpBeforeClass()
30+
{
31+
foreach (glob(self::$changedFilesPattern) as $changedFile) {
32+
self::$changedFileList .= file_get_contents($changedFile) . PHP_EOL;
33+
}
34+
}
35+
36+
/**
37+
* Test changes for module.xml files
38+
*/
39+
public function testModuleXmlFiles()
40+
{
41+
preg_match_all('|etc/module\.xml$|mi', self::$changedFileList, $matches);
42+
$this->assertEmpty(
43+
reset($matches),
44+
'module.xml changes for patch releases in non-actual branches are not allowed:' . PHP_EOL .
45+
implode(PHP_EOL, array_values(reset($matches)))
46+
);
47+
}
48+
49+
/**
50+
* Test changes for files in Module Setup dir
51+
*/
52+
public function testModuleSetupFiles()
53+
{
54+
preg_match_all('|app/code/Magento/[^/]+/Setup/[^/]+$|mi', self::$changedFileList, $matches);
55+
$this->assertEmpty(
56+
reset($matches),
57+
'Code with changes for DB schema or data in non-actual branches are not allowed:' . PHP_EOL .
58+
implode(PHP_EOL, array_values(reset($matches)))
59+
);
60+
}
61+
}

0 commit comments

Comments
 (0)