Skip to content

Commit 038da88

Browse files
committed
MC-38348: Make SVC and Infra changes
- Display full filename for xml changes - Displa package level changes in html report - Fixed tests - Added table for package level changes - Added copy-paste button
1 parent 1a50aa5 commit 038da88

27 files changed

+479
-90
lines changed

src/Analyzer/DBSchema/DbSchemaColumnAnalyzer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,29 @@ public function analyze($registryBefore, $registryAfter)
5858

5959
foreach ($registryTablesBefore as $moduleName => $moduleTables) {
6060
foreach ($moduleTables as $tableName => $tableData) {
61+
$fileBefore = $registryBefore->mapping['table'][$moduleName];
6162
$columns = $tableData['column'] ?? [];
6263
foreach ($columns as $column) {
6364
if (
6465
isset($registryTablesAfter[$moduleName][$tableName])
6566
&& !isset($registryTablesAfter[$moduleName][$tableName]['column'][$column])
6667
) {
67-
$operation = new ColumnRemove($moduleName, $tableName . '/' . $column);
68+
$operation = new ColumnRemove($fileBefore, $tableName . '/' . $column);
6869
$this->getReport()->add($this->context, $operation);
6970
}
7071
}
7172
}
7273
}
7374
foreach ($registryTablesAfter as $moduleName => $moduleTables) {
75+
$fileAfter = $registryAfter->mapping['table'][$moduleName];
7476
foreach ($moduleTables as $tableName => $tableData) {
7577
$columns = $tableData['column'] ?? [];
7678
foreach ($columns as $column) {
7779
if (
7880
isset($registryTablesBefore[$moduleName][$tableName])
7981
&& !isset($registryTablesBefore[$moduleName][$tableName]['column'][$column])
8082
) {
81-
$operation = new ColumnAdd($moduleName, $tableName . '/' . $column);
83+
$operation = new ColumnAdd($fileAfter, $tableName . '/' . $column);
8284
$this->getReport()->add($this->context, $operation);
8385
}
8486
}

src/Analyzer/DBSchema/DbSchemaForeignKeyAnalyzer.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,21 @@ public function analyze($registryBefore, $registryAfter)
5656
$registryTablesAfter = $registryAfter->data['table'] ?? [];
5757

5858
foreach ($registryTablesBefore as $moduleName => $moduleTables) {
59+
$fileBefore = $registryBefore->mapping['table'][$moduleName];
5960
foreach ($moduleTables as $tableName => $tableData) {
6061
$keys = $tableData['foreign'] ?? [];
6162
foreach ($keys as $name => $key) {
6263
if (!isset($registryTablesAfter[$moduleName][$tableName])) {
6364
continue;
6465
}
6566
if ($key !== null && !isset($registryTablesAfter[$moduleName][$tableName]['foreign'][$name])) {
66-
$operation = new ForeignKeyDrop($moduleName, $tableName . '/' . $name);
67+
$operation = new ForeignKeyDrop($fileBefore, $tableName . '/' . $name);
6768
$this->getReport()->add($this->context, $operation);
6869
continue;
6970
}
7071
foreach ($key as $item => $value) {
7172
if ($value !== $registryTablesAfter[$moduleName][$tableName]['foreign'][$name][$item]) {
72-
$operation = new ForeignKeyChange($moduleName, $tableName . '/' . $name . '/' . $item);
73+
$operation = new ForeignKeyChange($fileBefore, $tableName . '/' . $name . '/' . $item);
7374
$this->getReport()->add($this->context, $operation);
7475
}
7576
}
@@ -78,14 +79,15 @@ public function analyze($registryBefore, $registryAfter)
7879
}
7980

8081
foreach ($registryTablesAfter as $moduleName => $moduleTables) {
82+
$fileAfter = $registryAfter->mapping['table'][$moduleName];
8183
foreach ($moduleTables as $tableName => $tableData) {
8284
$keys = $tableData['foreign'] ?? [];
8385
foreach ($keys as $name => $key) {
8486
if (!isset($registryTablesBefore[$moduleName][$tableName])) {
8587
continue;
8688
}
8789
if ($key !== null && !isset($registryTablesBefore[$moduleName][$tableName]['foreign'][$name])) {
88-
$operation = new ForeignKeyAdd($moduleName, $tableName . '/' . $name);
90+
$operation = new ForeignKeyAdd($fileAfter, $tableName . '/' . $name);
8991
$this->getReport()->add($this->context, $operation);
9092
}
9193
}

src/Analyzer/DBSchema/DbSchemaPrimaryKeyAnalyzer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ public function analyze($registryBefore, $registryAfter)
5555
$registryTablesAfter = $registryAfter->data['table'] ?? [];
5656

5757
foreach ($registryTablesBefore as $moduleName => $moduleTables) {
58+
$fileBefore = $registryBefore->mapping['table'][$moduleName];
5859
foreach ($moduleTables as $tableName => $tableData) {
5960
$keys = $tableData['primary'] ?? [];
6061
foreach ($keys as $name => $key) {
6162
if (!isset($registryTablesAfter[$moduleName][$tableName])) {
6263
continue;
6364
}
6465
if ($key !== null && !isset($registryTablesAfter[$moduleName][$tableName]['primary'][$name])) {
65-
$operation = new PrimaryKeyDrop($moduleName, $tableName . '/' . $name);
66+
$operation = new PrimaryKeyDrop($fileBefore, $tableName . '/' . $name);
6667
$this->getReport()->add($this->context, $operation);
6768
continue;
6869
}
@@ -76,7 +77,7 @@ public function analyze($registryBefore, $registryAfter)
7677
}
7778
}
7879
if (!$matchedColumnFlag) {
79-
$operation = new PrimaryKeyChange($moduleName, $tableName . '/' . $name);
80+
$operation = new PrimaryKeyChange($fileBefore, $tableName . '/' . $name);
8081
$this->getReport()->add($this->context, $operation);
8182
break;
8283
}
@@ -86,14 +87,15 @@ public function analyze($registryBefore, $registryAfter)
8687
}
8788

8889
foreach ($registryTablesAfter as $moduleName => $moduleTables) {
90+
$fileAfter = $registryAfter->mapping['table'][$moduleName];
8991
foreach ($moduleTables as $tableName => $tableData) {
9092
$keys = $tableData['primary'] ?? [];
9193
foreach ($keys as $name => $key) {
9294
if (!isset($registryTablesBefore[$moduleName][$tableName])) {
9395
continue;
9496
}
9597
if ($key !== null && !isset($registryTablesBefore[$moduleName][$tableName]['primary'][$name])) {
96-
$operation = new PrimaryKeyAdd($moduleName, $tableName . '/' . $name);
98+
$operation = new PrimaryKeyAdd($fileAfter, $tableName . '/' . $name);
9799
$this->getReport()->add($this->context, $operation);
98100
continue;
99101
}
@@ -108,7 +110,7 @@ public function analyze($registryBefore, $registryAfter)
108110
}
109111
}
110112
if (!$matchedColumnFlag) {
111-
$operation = new PrimaryKeyChange($moduleName, $tableName . '/' . $name);
113+
$operation = new PrimaryKeyChange($fileAfter, $tableName . '/' . $name);
112114
$this->getReport()->add($this->context, $operation);
113115
break;
114116
}

src/Analyzer/DBSchema/DbSchemaTableAnalyzer.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,16 @@ public function analyze($registryBefore, $registryAfter)
5555
$registryTablesAfter = $registryAfter->data['table'] ?? [];
5656

5757
foreach ($registryTablesBefore as $moduleName => $moduleTables) {
58+
$fileBefore = $registryBefore->mapping['table'][$moduleName];
5859
foreach ($moduleTables as $tableName => $tableData) {
5960
if (!isset($registryTablesAfter[$moduleName][$tableName])) {
60-
$operation = new TableDropped($moduleName, $tableName);
61+
$operation = new TableDropped($fileBefore, $tableName);
6162
$this->getReport()->add($this->context, $operation);
6263
continue;
6364
}
6465
if ($tableData['resource'] !== $registryTablesAfter[$moduleName][$tableName]['resource']) {
6566
$operation = new TableChangeResource(
66-
$moduleName,
67+
$fileBefore,
6768
$tableName,
6869
$tableData['resource'],
6970
$registryTablesAfter[$moduleName][$tableName]['resource']
@@ -73,12 +74,13 @@ public function analyze($registryBefore, $registryAfter)
7374
}
7475
}
7576
foreach ($registryTablesAfter as $moduleName => $moduleTables) {
77+
$fileAfter = $registryAfter->mapping['table'][$moduleName];
7678
foreach ($moduleTables as $tableName => $tableData) {
7779
if (
7880
!isset($registryTablesBefore[$moduleName][$tableName])
7981
&& !$this->isModificationTableDeclaration($registryTablesAfter, $moduleName, $tableName)
8082
) {
81-
$operation = new TableAdded($moduleName, $tableName);
83+
$operation = new TableAdded($fileAfter, $tableName);
8284
$this->getReport()->add($this->context, $operation);
8385
}
8486
}

src/Analyzer/DBSchema/DbSchemaUniqueKeyAnalyzer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ public function analyze($registryBefore, $registryAfter)
5656
$registryTablesAfter = $registryAfter->data['table'] ?? [];
5757

5858
foreach ($registryTablesBefore as $moduleName => $moduleTables) {
59+
$fileBefore = $registryBefore->mapping['table'][$moduleName];
5960
foreach ($moduleTables as $tableName => $tableData) {
6061
$keys = $tableData['unique'] ?? [];
6162
foreach ($keys as $name => $key) {
6263
if (!isset($registryTablesAfter[$moduleName][$tableName])) {
6364
continue;
6465
}
6566
if ($key !== null && !isset($registryTablesAfter[$moduleName][$tableName]['unique'][$name])) {
66-
$operation = new UniqueKeyDrop($moduleName, $tableName . '/' . $name);
67+
$operation = new UniqueKeyDrop($fileBefore, $tableName . '/' . $name);
6768
$this->getReport()->add($this->context, $operation);
6869
continue;
6970
}
@@ -77,7 +78,7 @@ public function analyze($registryBefore, $registryAfter)
7778
}
7879
}
7980
if (!$matchedColumnFlag) {
80-
$operation = new UniqueKeyChange($moduleName, $tableName . '/' . $name);
81+
$operation = new UniqueKeyChange($fileBefore, $tableName . '/' . $name);
8182
$this->getReport()->add($this->context, $operation);
8283
break;
8384
}
@@ -87,14 +88,15 @@ public function analyze($registryBefore, $registryAfter)
8788
}
8889

8990
foreach ($registryTablesAfter as $moduleName => $moduleTables) {
91+
$fileAfter = $registryAfter->mapping['table'][$moduleName];
9092
foreach ($moduleTables as $tableName => $tableData) {
9193
$keys = $tableData['unique'] ?? [];
9294
foreach ($keys as $name => $key) {
9395
if (!isset($registryTablesBefore[$moduleName][$tableName])) {
9496
continue;
9597
}
9698
if ($key !== null && !isset($registryTablesBefore[$moduleName][$tableName]['unique'][$name])) {
97-
$operation = new UniqueKeyAdd($moduleName, $tableName . '/' . $name);
99+
$operation = new UniqueKeyAdd($fileAfter, $tableName . '/' . $name);
98100
$this->getReport()->add($this->context, $operation);
99101
continue;
100102
}
@@ -109,7 +111,7 @@ public function analyze($registryBefore, $registryAfter)
109111
}
110112
}
111113
if (!$matchedColumnFlag) {
112-
$operation = new UniqueKeyChange($moduleName, $tableName . '/' . $name);
114+
$operation = new UniqueKeyChange($fileAfter, $tableName . '/' . $name);
113115
$this->getReport()->add($this->context, $operation);
114116
break;
115117
}

src/Analyzer/DBSchema/DbSchemaWhitelistAnalyzer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,16 @@ public function analyze($registryBefore, $registryAfter)
5454
$dbWhiteListContent = $registryAfter->data['whitelist_json'] ?? [];
5555

5656
foreach ($registryTablesAfter as $moduleName => $tablesData) {
57+
$fileAfter = $registryAfter->mapping['table'][$moduleName];
5758
if (count($tablesData)) {
5859
foreach (array_keys($tablesData) as $table) {
5960
if (!isset($dbWhiteListContent[$moduleName][$table])) {
60-
$operation = new InvalidWhitelist($moduleName, $table);
61+
$operation = new InvalidWhitelist($fileAfter, $table);
6162
$this->report->add('database', $operation);
6263
}
6364
}
6465
}
6566
}
66-
67-
6867
return $this->report;
6968
}
7069
}

src/Analyzer/DBSchema/DbSchemaWhitelistReductionOrRemovalAnalyzer.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,32 @@ public function analyze($registryBefore, $registryAfter)
4949

5050
/** @var array $tablesData */
5151
foreach ($whiteListBefore as $moduleName => $beforeModuleTablesData) {
52+
$fileBefore = $registryBefore->mapping['whitelist_json'][$moduleName];
5253
if (!isset($whiteListAfter[$moduleName])) {
53-
$operation = new WhiteListWasRemoved($moduleName);
54+
$operation = new WhiteListWasRemoved($fileBefore, $moduleName);
5455
$this->report->add('database', $operation);
5556
continue;
5657
}
5758
$afterModuleTablesData = $whiteListAfter[$moduleName];
5859
/** @var array $beforeTableData */
5960
foreach ($beforeModuleTablesData as $tableName => $beforeTableData) {
6061
if (!$this->isArrayExistsAndHasSameSize($afterModuleTablesData, $beforeTableData, $tableName)) {
61-
$this->addReport($moduleName, $tableName);
62+
$this->addReport($fileBefore, $tableName);
6263
continue;
6364
}
6465
$afterTableData = $afterModuleTablesData[$tableName];
6566
/** @var array $beforeTablePartData */
6667
foreach ($beforeTableData as $tablePartName => $beforeTablePartData) {
6768
if (!$this->isArrayExistsAndHasSameSize($afterTableData, $beforeTablePartData, $tablePartName)) {
68-
$this->addReport($moduleName, $tableName . '/' . $tablePartName);
69+
$this->addReport($fileBefore, $tableName . '/' . $tablePartName);
6970
continue;
7071
}
7172
$afterTablePartData = $afterTableData[$tablePartName];
7273
/** @var bool $beforeStatus */
7374
foreach ($beforeTablePartData as $name => $beforeStatus) {
7475
//checks if array exists in new whitelist.json and if it has different amount of items inside
7576
if (!isset($afterTablePartData[$name])) {
76-
$this->addReport($moduleName, $tableName . '/' . $tablePartName . '/' . $name);
77+
$this->addReport($fileBefore, $tableName . '/' . $tablePartName . '/' . $name);
7778
}
7879
}
7980
}
@@ -102,14 +103,14 @@ public function isArrayExistsAndHasSameSize(array $after, array $beforeArray, st
102103
}
103104

104105
/**
105-
* @param string $moduleName
106+
* @param string $filePath
106107
* @param string $target
107108
*
108109
* @return void
109110
*/
110-
public function addReport(string $moduleName, string $target): void
111+
public function addReport(string $filePath, string $target): void
111112
{
112-
$operation = new WhiteListReduced($moduleName, $target);
113+
$operation = new WhiteListReduced($filePath, $target);
113114
$this->report->add('database', $operation);
114115
}
115116
}

src/Analyzer/DbSchemaWhitelistAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function analyze($registryBefore, $registryAfter)
5555
$dbWhiteListFile
5656
);
5757
if (!file_exists($dbWhiteListFile)) {
58-
$operation = new WhiteListWasRemoved($moduleName);
58+
$operation = new WhiteListWasRemoved($dbWhiteListFile, $moduleName);
5959
$report->add('database', $operation);
6060
continue;
6161
} else {

src/Analyzer/DiXml/VirtualTypeAnalyzer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,18 @@ public function analyze($registryBefore, $registryAfter)
5656

5757
foreach ($nodesBefore as $moduleName => $moduleNodes) {
5858
/* @var VirtualType $nodeBefore */
59+
$fileBefore = $registryBefore->mapping[XmlRegistry::NODES_KEY][$moduleName];
5960
foreach ($moduleNodes as $name => $nodeBefore) {
6061
// search nodesAfter the by name
6162
$nodeAfter = $nodesAfter[$moduleName][$name] ?? false;
6263

6364
if ($nodeAfter !== false && $nodeBefore !== $nodeAfter) {
6465
/* @var VirtualType $nodeAfter */
65-
$this->triggerNodeChange($nodeBefore, $nodeAfter);
66+
$this->triggerNodeChange($nodeBefore, $nodeAfter, $fileBefore);
6667
continue;
6768
}
6869

69-
$operation = new VirtualTypeRemoved($moduleName, $name);
70+
$operation = new VirtualTypeRemoved($fileBefore, $name);
7071
$this->report->add('di', $operation);
7172
}
7273
}
@@ -103,8 +104,9 @@ private function getVirtualTypeNode(XmlRegistry $xmlRegistry): array
103104
*
104105
* @param VirtualType $nodeBefore
105106
* @param VirtualType $nodeAfter
107+
* @param string $beforeFilePath
106108
*/
107-
private function triggerNodeChange(VirtualType $nodeBefore, VirtualType $nodeAfter): void
109+
private function triggerNodeChange(VirtualType $nodeBefore, VirtualType $nodeAfter, string $beforeFilePath): void
108110
{
109111
$bcFieldBefore = [
110112
'type' => $nodeBefore->getType(),
@@ -124,7 +126,7 @@ private function triggerNodeChange(VirtualType $nodeBefore, VirtualType $nodeAft
124126
foreach ($bcFieldBefore as $fieldName => $valueBefore) {
125127
$valueAfter = $bcFieldAfter[$fieldName];
126128
if ($valueBefore !== $valueAfter) {
127-
$operation = new VirtualTypeChanged($nodeBefore->getName(), $fieldName);
129+
$operation = new VirtualTypeChanged($beforeFilePath, $fieldName);
128130
$this->report->add('di', $operation);
129131
}
130132
}

0 commit comments

Comments
 (0)