Skip to content

Commit 85513e8

Browse files
MFTF-33582: Eliminated AspectMock remnants
1 parent b94dbb7 commit 85513e8

File tree

5 files changed

+41
-28
lines changed

5 files changed

+41
-28
lines changed

dev/tests/_bootstrap.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,6 @@
1515
require_once $mftfTestCasePath;
1616
require_once $mftfStaticTestCasePath;
1717

18-
// Set up AspectMock
19-
$kernel = \AspectMock\Kernel::getInstance();
20-
$kernel->init([
21-
'debug' => true,
22-
'includePaths' => [
23-
PROJECT_ROOT . DIRECTORY_SEPARATOR . 'src',
24-
PROJECT_ROOT . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'allure-framework'
25-
],
26-
'cacheDir' => PROJECT_ROOT .
27-
DIRECTORY_SEPARATOR .
28-
'dev' .
29-
DIRECTORY_SEPARATOR .
30-
'tests' .
31-
DIRECTORY_SEPARATOR .
32-
'.cache'
33-
]);
34-
3518
// set mftf appplication context
3619
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::create(
3720
true,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<tests><test name='testName'><annotations>a</annotations></test></tests>

dev/tests/verification/Tests/SchemaValidationTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
namespace tests\verification\Tests;
77

88
use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig;
9+
use ReflectionProperty;
910
use tests\util\MftfTestCase;
10-
use AspectMock\Test as AspectMock;
1111

1212
class SchemaValidationTest extends MftfTestCase
1313
{
@@ -19,7 +19,10 @@ class SchemaValidationTest extends MftfTestCase
1919
*/
2020
public function testInvalidTestSchema()
2121
{
22-
AspectMock::double(MftfApplicationConfig::class, ['getDebugLevel' => MftfApplicationConfig::LEVEL_DEVELOPER]);
22+
$property = new ReflectionProperty(MftfApplicationConfig::class, 'debugLevel');
23+
$property->setAccessible(true);
24+
$property->setValue(MftfApplicationConfig::LEVEL_DEVELOPER);
25+
2326
$testFile = ['testFile.xml' => "<tests><test name='testName'><annotations>a</annotations></test></tests>"];
2427
$expectedError = TESTS_MODULE_PATH .
2528
DIRECTORY_SEPARATOR .
@@ -32,11 +35,12 @@ public function testInvalidTestSchema()
3235
}
3336

3437
/**
35-
* After method functionality
36-
* @return void
38+
* @inheritdoc
3739
*/
3840
protected function tearDown(): void
3941
{
40-
AspectMock::clean();
42+
$property = new ReflectionProperty(MftfApplicationConfig::class, 'debugLevel');
43+
$property->setAccessible(true);
44+
$property->setValue(null);
4145
}
4246
}

dev/tests/verification/Tests/StaticCheck/DeprecationStaticCheckTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*/
66
namespace tests\verification\Tests;
77

8-
use AspectMock\Test as AspectMock;
98
use Magento\FunctionalTestingFramework\StaticCheck\DeprecatedEntityUsageCheck;
109
use Magento\FunctionalTestingFramework\StaticCheck\StaticChecksList;
10+
use ReflectionProperty;
1111
use Symfony\Component\Console\Input\InputInterface;
1212
use tests\util\MftfStaticTestCase;
1313

@@ -33,7 +33,9 @@ public function testDeprecatedEntityUsageCheck()
3333
$staticCheck = new DeprecatedEntityUsageCheck();
3434

3535
$input = $this->mockInputInterface(self::TEST_MODULE_PATH);
36-
AspectMock::double(StaticChecksList::class, ['getErrorFilesPath' => self::STATIC_RESULTS_DIR]);
36+
$property = new ReflectionProperty(StaticChecksList::class, 'errorFilesPath');
37+
$property->setAccessible(true);
38+
$property->setValue(self::STATIC_RESULTS_DIR);
3739

3840
/** @var InputInterface $input */
3941
$staticCheck->execute($input);
@@ -47,4 +49,14 @@ public function testDeprecatedEntityUsageCheck()
4749
self::LOG_FILE
4850
);
4951
}
52+
53+
/**
54+
* @inheritdoc
55+
*/
56+
public function tearDown(): void
57+
{
58+
$property = new ReflectionProperty(StaticChecksList::class, 'errorFilesPath');
59+
$property->setAccessible(true);
60+
$property->setValue(null);
61+
}
5062
}

dev/tests/verification/Tests/StaticCheck/PauseActionStaticCheckTest.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
*/
66
namespace tests\verification\Tests;
77

8-
use AspectMock\Test as AspectMock;
8+
use Exception;
99
use Magento\FunctionalTestingFramework\StaticCheck\PauseActionUsageCheck;
1010
use Magento\FunctionalTestingFramework\StaticCheck\StaticChecksList;
11+
use ReflectionProperty;
1112
use Symfony\Component\Console\Input\InputInterface;
12-
1313
use tests\util\MftfStaticTestCase;
1414

1515
class PauseActionStaticCheckTest extends MftfStaticTestCase
@@ -27,14 +27,17 @@ class PauseActionStaticCheckTest extends MftfStaticTestCase
2727
/**
2828
* test static-check PauseActionUsageCheck.
2929
*
30-
* @throws \Exception
30+
* @throws Exception
3131
*/
3232
public function testPauseActionUsageCheck()
3333
{
3434
$staticCheck = new PauseActionUsageCheck();
3535

3636
$input = $this->mockInputInterface(self::TEST_MODULE_PATH);
37-
AspectMock::double(StaticChecksList::class, ['getErrorFilesPath' => self::STATIC_RESULTS_DIR]);
37+
38+
$property = new ReflectionProperty(StaticChecksList::class, 'errorFilesPath');
39+
$property->setAccessible(true);
40+
$property->setValue(self::STATIC_RESULTS_DIR);
3841

3942
/** @var InputInterface $input */
4043
$staticCheck->execute($input);
@@ -48,4 +51,14 @@ public function testPauseActionUsageCheck()
4851
self::LOG_FILE
4952
);
5053
}
54+
55+
/**
56+
* @inheritdoc
57+
*/
58+
public static function tearDownAfterClass(): void
59+
{
60+
$property = new ReflectionProperty(StaticChecksList::class, 'errorFilesPath');
61+
$property->setAccessible(true);
62+
$property->setValue(null);
63+
}
5164
}

0 commit comments

Comments
 (0)