Skip to content

Commit b6555a1

Browse files
authored
Merge pull request #65 from magento-commerce/imported-magento-magento2-functional-testing-framework-841
[Imported] 33307: Eliminated AspectMock usage from GenerationErrorHandlerTest.php
2 parents 9dfd3e3 + 8afc71a commit b6555a1

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

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

Lines changed: 16 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,9 @@ 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+
->method('getPhase')
27+
->willReturn(MftfApplicationConfig::GENERATION_PHASE);
2828

2929
$expectedAllErrors = [
3030
'test' => [
@@ -79,10 +79,9 @@ public function testGetDistinctErrors()
7979
*/
8080
public function testGetErrorsWithSameKey()
8181
{
82-
AspectMock::double(
83-
MftfApplicationConfig::class,
84-
['getPhase' => MftfApplicationConfig::GENERATION_PHASE]
85-
);
82+
$this->createMock(MftfApplicationConfig::class)
83+
->method('getPhase')
84+
->willReturn(MftfApplicationConfig::GENERATION_PHASE);
8685

8786
$expectedAllErrors = [
8887
'test' => [
@@ -163,10 +162,9 @@ public function testGetErrorsWithSameKey()
163162
*/
164163
public function testGetAllErrorsDuplicate()
165164
{
166-
AspectMock::double(
167-
MftfApplicationConfig::class,
168-
['getPhase' => MftfApplicationConfig::GENERATION_PHASE]
169-
);
165+
$this->createMock(MftfApplicationConfig::class)
166+
->method('getPhase')
167+
->willReturn(MftfApplicationConfig::GENERATION_PHASE);
170168

171169
$expectedAllErrors = [
172170
'test' => [
@@ -254,7 +252,7 @@ public function testGetAllErrorMessages($expectedErrMessages, $errors)
254252
$handler = GenerationErrorHandler::getInstance();
255253
$handler->reset();
256254

257-
$property = new \ReflectionProperty(GenerationErrorHandler::class, 'errors');
255+
$property = new ReflectionProperty(GenerationErrorHandler::class, 'errors');
258256
$property->setAccessible(true);
259257
$property->setValue($handler, $errors);
260258

@@ -334,10 +332,9 @@ public function getAllErrorMessagesDataProvider()
334332
*/
335333
public function testResetError()
336334
{
337-
AspectMock::double(
338-
MftfApplicationConfig::class,
339-
['getPhase' => MftfApplicationConfig::GENERATION_PHASE]
340-
);
335+
$this->createMock(MftfApplicationConfig::class)
336+
->method('getPhase')
337+
->willReturn(MftfApplicationConfig::GENERATION_PHASE);
341338

342339
GenerationErrorHandler::getInstance()->addError('something', 'some', 'error');
343340
GenerationErrorHandler::getInstance()->addError('otherthing', 'other', 'error');
@@ -353,7 +350,7 @@ public function testResetError()
353350

354351
public function tearDown(): void
355352
{
356-
$property = new \ReflectionProperty(GenerationErrorHandler::class, 'instance');
353+
$property = new ReflectionProperty(GenerationErrorHandler::class, 'instance');
357354
$property->setAccessible(true);
358355
$property->setValue(null);
359356
}

0 commit comments

Comments
 (0)