Skip to content

Commit 6009ca6

Browse files
committed
Cleanup of some non-existing classes from some unit tests code in the Magento framework.
1 parent adc4105 commit 6009ca6

File tree

6 files changed

+8
-25
lines changed

6 files changed

+8
-25
lines changed

lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ private function getFilesIterator()
5252

5353
foreach ($files as $file) {
5454
$item = $this->getMockBuilder(
55-
\SplFileInfoClass::class
56-
)->setMethods(['__toString', 'getFilename'])->getMock();
55+
\SplFileInfo::class
56+
)->disableOriginalConstructor()->setMethods(['__toString', 'getFilename'])->getMock();
5757
$item->expects($this->any())->method('__toString')->willReturn($file);
5858
$item->expects($this->any())->method('getFilename')->willReturn('notDots');
5959
yield $item;

lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/CompiledTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,12 @@ private function getSimpleNestedConfig()
299299
'_vac_' => [
300300
'array_value' => 'value',
301301
'array_configured_instance' => [
302-
'_i_' => \Magento\Framework\ObjectManager\Test\Unit::class
303-
. '\Factory\Fixture\Compiled\DependencySharedTesting',
302+
'_i_' => DependencySharedTesting::class,
304303
],
305304
'array_configured_array' => [
306305
'array_array_value' => 'value',
307306
'array_array_configured_instance' => [
308-
'_ins_' => \Magento\Framework\ObjectManager::class
309-
. '\Test\Unit\Factory\Fixture\Compiled\DependencyTesting',
307+
'_ins_' => DependencyTesting::class,
310308
],
311309
],
312310
'array_global_argument' => [

lib/internal/Magento/Framework/ObjectManager/Test/Unit/Helper/SortItemsTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212

1313
class SortItemsTest extends TestCase
1414
{
15-
/**
16-
* @var MockObject|InterpreterInterface
17-
*/
18-
protected InterpreterInterface $_itemInterpreter;
19-
2015
/**
2116
* @var SortItemsHelper
2217
*/

lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,8 @@ protected function setUp(): void
7474
$scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
7575
$cacheState = $this->getMockBuilder(StateInterface::class)
7676
->getMockForAbstractClass();
77-
$storeConfig = $this->getMockBuilder(\Magento\Store\Model\Store\Config::class)
78-
->disableOriginalConstructor()
79-
->getMock();
8077
$this->context = $this->getMockBuilder(Context::class)
81-
->setMethods(['getLayout', 'getEventManager', 'getStoreConfig', 'getScopeConfig', 'getCacheState'])
78+
->setMethods(['getLayout', 'getEventManager', 'getScopeConfig', 'getCacheState'])
8279
->disableOriginalConstructor()
8380
->getMock();
8481
$this->context->expects($this->any())
@@ -87,9 +84,6 @@ protected function setUp(): void
8784
$this->context->expects($this->any())
8885
->method('getEventManager')
8986
->willReturn($eventManager);
90-
$this->context->expects($this->any())
91-
->method('getStoreConfig')
92-
->willReturn($storeConfig);
9387
$this->context->expects($this->any())
9488
->method('getScopeConfig')
9589
->willReturn($scopeConfigMock);

lib/internal/Magento/Framework/TestFramework/Unit/Helper/ObjectManager.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Helper class for basic object retrieving, such as blocks, models etc...
1313
*
1414
* @deprecated Class under test should be instantiated with `new` keyword with explicit dependencies declaration
15+
* @see https://github.com/magento/magento2/pull/29272
1516
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1617
*/
1718
class ObjectManager
@@ -29,8 +30,6 @@ class ObjectManager
2930
];
3031

3132
/**
32-
* Test object
33-
*
3433
* @var \PHPUnit\Framework\TestCase
3534
*/
3635
protected $_testObject;
@@ -158,10 +157,7 @@ protected function _getMockWithoutConstructorCall($className)
158157
*/
159158
public function getObject($className, array $arguments = [])
160159
{
161-
// phpstan:ignore
162-
if (is_subclass_of($className, \Magento\Framework\Api\AbstractSimpleObjectBuilder::class)
163-
|| is_subclass_of($className, \Magento\Framework\Api\Builder::class)
164-
) {
160+
if (is_subclass_of($className, \Magento\Framework\Api\AbstractSimpleObjectBuilder::class)) {
165161
return $this->getBuilder($className, $arguments);
166162
}
167163
$constructArguments = $this->getConstructArguments($className, $arguments);

lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/DeserializerFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testGetLogicExceptionInvalidRequestDeserializer()
6262
{
6363
$expectedMetadata = ['text_xml' => ['type' => 'text/xml', 'model' => 'Xml']];
6464
$invalidInterpreter = $this->getMockBuilder(
65-
\Magento\Framework\Webapi\Response\Rest\Renderer\Json::class
65+
\Magento\Framework\Webapi\Rest\Response\Renderer\Json::class
6666
)->disableOriginalConstructor()
6767
->getMock();
6868

0 commit comments

Comments
 (0)