Skip to content

Commit 7550d4a

Browse files
committed
33307: Eliminated AspectMock usage from GenerationErrorHandlerTest.php
1 parent 9dfd3e3 commit 7550d4a

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Util/GenerationErrorHandlerTest.php

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace tests\unit\Magento\FunctionalTestFramework\Util;
89

9-
use AspectMock\Test as AspectMock;
10+
use ReflectionProperty;
1011
use tests\unit\Util\MagentoTestCase;
1112
use Magento\FunctionalTestingFramework\Util\GenerationErrorHandler;
1213
use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig;
@@ -21,10 +22,10 @@ class GenerationErrorHandlerTest extends MagentoTestCase
2122
*/
2223
public function testGetDistinctErrors()
2324
{
24-
AspectMock::double(
25-
MftfApplicationConfig::class,
26-
['getPhase' => MftfApplicationConfig::GENERATION_PHASE]
27-
);
25+
$this->createMock(MftfApplicationConfig::class)
26+
->expects($this->once())
27+
->method('getPhase')
28+
->willReturn(MftfApplicationConfig::GENERATION_PHASE);
2829

2930
$expectedAllErrors = [
3031
'test' => [
@@ -79,10 +80,10 @@ public function testGetDistinctErrors()
7980
*/
8081
public function testGetErrorsWithSameKey()
8182
{
82-
AspectMock::double(
83-
MftfApplicationConfig::class,
84-
['getPhase' => MftfApplicationConfig::GENERATION_PHASE]
85-
);
83+
$this->createMock(MftfApplicationConfig::class)
84+
->expects($this->once())
85+
->method('getPhase')
86+
->willReturn(MftfApplicationConfig::GENERATION_PHASE);
8687

8788
$expectedAllErrors = [
8889
'test' => [
@@ -163,10 +164,10 @@ public function testGetErrorsWithSameKey()
163164
*/
164165
public function testGetAllErrorsDuplicate()
165166
{
166-
AspectMock::double(
167-
MftfApplicationConfig::class,
168-
['getPhase' => MftfApplicationConfig::GENERATION_PHASE]
169-
);
167+
$this->createMock(MftfApplicationConfig::class)
168+
->expects($this->once())
169+
->method('getPhase')
170+
->willReturn(MftfApplicationConfig::GENERATION_PHASE);
170171

171172
$expectedAllErrors = [
172173
'test' => [
@@ -254,7 +255,7 @@ public function testGetAllErrorMessages($expectedErrMessages, $errors)
254255
$handler = GenerationErrorHandler::getInstance();
255256
$handler->reset();
256257

257-
$property = new \ReflectionProperty(GenerationErrorHandler::class, 'errors');
258+
$property = new ReflectionProperty(GenerationErrorHandler::class, 'errors');
258259
$property->setAccessible(true);
259260
$property->setValue($handler, $errors);
260261

@@ -334,10 +335,10 @@ public function getAllErrorMessagesDataProvider()
334335
*/
335336
public function testResetError()
336337
{
337-
AspectMock::double(
338-
MftfApplicationConfig::class,
339-
['getPhase' => MftfApplicationConfig::GENERATION_PHASE]
340-
);
338+
$this->createMock(MftfApplicationConfig::class)
339+
->expects($this->once())
340+
->method('getPhase')
341+
->willReturn(MftfApplicationConfig::GENERATION_PHASE);
341342

342343
GenerationErrorHandler::getInstance()->addError('something', 'some', 'error');
343344
GenerationErrorHandler::getInstance()->addError('otherthing', 'other', 'error');
@@ -353,7 +354,7 @@ public function testResetError()
353354

354355
public function tearDown(): void
355356
{
356-
$property = new \ReflectionProperty(GenerationErrorHandler::class, 'instance');
357+
$property = new ReflectionProperty(GenerationErrorHandler::class, 'instance');
357358
$property->setAccessible(true);
358359
$property->setValue(null);
359360
}

0 commit comments

Comments
 (0)