Skip to content

Commit 8f55f02

Browse files
committed
Merge branch 'ACP2E-3712' of https://github.com/adobe-commerce-tier-4/magento2ce into PR-05-01-2025
2 parents 683fc14 + f40ed60 commit 8f55f02

File tree

9 files changed

+103
-68
lines changed

9 files changed

+103
-68
lines changed

lib/internal/Magento/Framework/Config/Test/Unit/XsdTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
6+
67
declare(strict_types=1);
78

89
namespace Magento\Framework\Config\Test\Unit;
@@ -17,6 +18,7 @@ class XsdTest extends TestCase
1718
* @param string $invalidXmlFile
1819
* @param int $expectedErrorsQty
1920
* @dataProvider invalidXmlFileDataProvider
21+
* @throws \Exception
2022
*/
2123
public function testInvalidXmlFile($xsdFile, $invalidXmlFile, $expectedErrorsQty)
2224
{
@@ -43,6 +45,6 @@ public function testInvalidXmlFile($xsdFile, $invalidXmlFile, $expectedErrorsQty
4345
*/
4446
public static function invalidXmlFileDataProvider()
4547
{
46-
return [['view.xsd', 'view_invalid.xml', 8], ['theme.xsd', 'theme_invalid.xml', 1]];
48+
return [['view.xsd', 'view_invalid.xml', 10], ['theme.xsd', 'theme_invalid.xml', 1]];
4749
}
4850
}

lib/internal/Magento/Framework/Config/Test/Unit/_files/view_invalid.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2011 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
@@ -16,13 +16,17 @@
1616
<image id="test" type="valid"/>
1717
<image id="test" type="valid_image"/>
1818
<image id="test" type="valid_image_type"/>
19+
<image id="test" type="ii"/>
20+
<image id="test" type="i_i"/>
21+
<image id="test" type="i_i_i"/>
1922
<!-- Invalid image type values -->
2023
<image id="test" type="_invalid_image_type"/>
2124
<image id="test" type="invalid-image"/>
2225
<image id="test" type="Invalid"/>
2326
<image id="test" type="invalid_"/>
2427
<image id="test" type="invalid__image"/>
2528
<image id="test" type="i"/>
29+
<image id="test" type="i_"/>
2630
<image id="test" type="?invalid"/>
2731
<image id="test" type="123"/>
2832
</images>

lib/internal/Magento/Framework/Config/etc/view.xsd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2011 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
@@ -79,6 +79,7 @@
7979
<xs:simpleType>
8080
<xs:restriction base="xs:string">
8181
<xs:pattern value="[a-z]+(_?[a-z])+"/>
82+
<xs:minLength value="2"/>
8283
</xs:restriction>
8384
</xs:simpleType>
8485
</xs:union>

setup/src/Magento/Setup/Test/Unit/Model/UninstallCollectorTest.php

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -28,6 +28,9 @@ class UninstallCollectorTest extends \PHPUnit\Framework\TestCase
2828

2929
protected function setUp(): void
3030
{
31+
require_once '_files/app/code/Magento/A/Setup/Uninstall.php';
32+
require_once '_files/app/code/Magento/B/Setup/Uninstall.php';
33+
3134
$objectManagerProvider = $this->createMock(\Magento\Setup\Model\ObjectManagerProvider::class);
3235
$objectManager =
3336
$this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class, [], '', false);
@@ -46,8 +49,8 @@ protected function setUp(): void
4649
$this->result = $this->createMock(\Magento\Framework\DB\Select::class);
4750
$select->expects($this->once())->method('from')->willReturn($this->result);
4851

49-
$uninstallA = 'Uninstall Class A';
50-
$uninstallB = 'Uninstall Class B';
52+
$uninstallA = 'Magento\A\Setup\Uninstall';
53+
$uninstallB = 'Magento\B\Setup\Uninstall';
5154
$objectManager->expects($this->any())
5255
->method('create')
5356
->willReturnMap(
@@ -71,7 +74,7 @@ public function testUninstallCollector()
7174
->willReturn([['module' => 'Magento_A'], ['module' => 'Magento_B'], ['module' => 'Magento_C']]);
7275

7376
$this->assertEquals(
74-
['Magento_A' => 'Uninstall Class A', 'Magento_B' => 'Uninstall Class B'],
77+
['Magento_A' => 'Magento\A\Setup\Uninstall', 'Magento_B' => 'Magento\B\Setup\Uninstall'],
7578
$this->collector->collectUninstall()
7679
);
7780
}
@@ -84,40 +87,9 @@ public function testUninstallCollectorWithInput()
8487
->with($this->result)
8588
->willReturn([['module' => 'Magento_A']]);
8689

87-
$this->assertEquals(['Magento_A' => 'Uninstall Class A'], $this->collector->collectUninstall(['Magento_A']));
88-
}
89-
}
90-
91-
namespace Magento\Setup\Model;
92-
93-
/**
94-
* This function overrides the native function for the purpose of testing
95-
*
96-
* @param string $obj
97-
* @param string $className
98-
* @return bool
99-
*/
100-
function is_subclass_of($obj, $className)
101-
{
102-
if ($obj == 'Uninstall Class A' && $className == \Magento\Framework\Setup\UninstallInterface::class) {
103-
return true;
104-
}
105-
if ($obj == 'Uninstall Class B' && $className == \Magento\Framework\Setup\UninstallInterface::class) {
106-
return true;
107-
}
108-
return false;
109-
}
110-
111-
/**
112-
* This function overrides the native function for the purpose of testing
113-
*
114-
* @param string $className
115-
* @return bool
116-
*/
117-
function class_exists($className)
118-
{
119-
if ($className == 'Magento\A\Setup\Uninstall' || $className == 'Magento\B\Setup\Uninstall') {
120-
return true;
90+
$this->assertEquals(
91+
['Magento_A' => 'Magento\A\Setup\Uninstall'],
92+
$this->collector->collectUninstall(['Magento_A'])
93+
);
12194
}
122-
return false;
12395
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\A\Setup;
9+
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\SchemaSetupInterface;
12+
13+
class Uninstall implements \Magento\Framework\Setup\UninstallInterface
14+
{
15+
16+
/**
17+
* Uninstall method
18+
*
19+
* @param SchemaSetupInterface $setup
20+
* @param ModuleContextInterface $context
21+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
22+
*/
23+
public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
24+
{
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\B\Setup;
9+
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\SchemaSetupInterface;
12+
13+
class Uninstall implements \Magento\Framework\Setup\UninstallInterface
14+
{
15+
16+
/**
17+
* Uninstall method
18+
*
19+
* @param SchemaSetupInterface $setup
20+
* @param ModuleContextInterface $context
21+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
22+
*/
23+
public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
24+
{
25+
}
26+
}

setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PhpScannerTest.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2013 Adobe.
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -71,15 +71,19 @@ public function testCollectEntities(): void
7171

7272
$this->log
7373
->method('add')
74-
->willReturnCallback(
75-
function ($arg1, $arg2, $arg3) {
76-
if ($arg1 == 4 && $arg2 == 'Magento\SomeModule\Module\Factory') {
77-
return null;
78-
} elseif ($arg1 == 4 && $arg2 == 'Magento\SomeModule\Element\Factory') {
79-
return null;
80-
}
74+
->willReturnCallback(function ($arg1, $arg2, $arg3) use ($testFiles) {
75+
if ($arg1 == 4 && $arg2 == 'Magento\SomeModule\Module\Factory'
76+
&& $arg3 == 'Invalid Factory for nonexistent class Magento\SomeModule\Module in file '
77+
. $testFiles[0]
78+
) {
79+
return null;
80+
} elseif ($arg1 == 4 && $arg2 == 'Magento\SomeModule\Element\Factory'
81+
&& $arg3 == 'Invalid Factory declaration for class Magento\SomeModule\Element in file '
82+
. $testFiles[0]
83+
) {
84+
return null;
8185
}
82-
);
86+
});
8387

8488
$result = $this->scanner->collectEntities($testFiles);
8589

setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/XmlScannerTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2013 Adobe.
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -52,12 +52,14 @@ protected function setUp(): void
5252
$testDir . '/app/code/Magento/SomeModule/etc/di.xml',
5353
$testDir . '/app/code/Magento/SomeModule/view/frontend/default.xml',
5454
];
55-
require_once __DIR__ . '/../../_files/app/code/Magento/SomeModule/Element.php';
56-
require_once __DIR__ . '/../../_files/app/code/Magento/SomeModule/NestedElement.php';
55+
56+
require_once __DIR__ . '/../../_files/app/code/Magento/SomeModule/Element.php';
57+
require_once __DIR__ . '/../../_files/app/code/Magento/SomeModule/NestedElement.php';
5758
}
5859

5960
/**
6061
* @return void
62+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
6163
*/
6264
public function testCollectEntities(): void
6365
{
@@ -81,6 +83,7 @@ public function testCollectEntities(): void
8183

8284
$actual = $this->model->collectEntities($this->testFiles);
8385
$expected = [];
86+
8487
$this->assertEquals($expected, $actual);
8588
}
8689
}

setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/ElementFactory.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\SomeModule;
99

1010
use Magento\Framework\ObjectManagerInterface;
1111

12-
require_once __DIR__ . '/Element.php';
1312
class ElementFactory
1413
{
1514
/**
@@ -26,13 +25,11 @@ public function __construct(ObjectManagerInterface $objectManager)
2625
}
2726

2827
/**
29-
* @param string $className
3028
* @param array $data
3129
* @return mixed
3230
*/
33-
public function create($className, array $data = [])
31+
public function create(array $data = [])
3432
{
35-
$instance = $this->_objectManager->create($className, $data);
36-
return $instance;
33+
return $this->_objectManager->create(\Magento\SomeModule\Element::class, ['data' => $data]);
3734
}
3835
}

0 commit comments

Comments
 (0)