Skip to content

Commit d099cb3

Browse files
committed
Merge branch 'develop' into improvement/mftf-33584-eliminate-aspect-mock-from-object-handler-uti
2 parents 591aaa7 + 93676a8 commit d099cb3

File tree

9 files changed

+144
-66
lines changed

9 files changed

+144
-66
lines changed

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
Magento Functional Testing Framework Changelog
22
================================================
3+
3.6.0
4+
---------
5+
6+
### Enhancements
7+
8+
* Maintainability
9+
* Updated composer dependencies to be PHP 8 compatible with the except of codeception/aspect-mock.
10+
11+
### GitHub Pull Requests:
12+
13+
* [#830](https://github.com/magento/magento2-functional-testing-framework/pull/830) -- Add ability to configure multiple OTPs
14+
* [#832](https://github.com/magento/magento2-functional-testing-framework/pull/832) -- Updated monolog/monolog to ^2.2
15+
* [#833](https://github.com/magento/magento2-functional-testing-framework/pull/833) -- Removed usage of AspectMock in FilesystemTest
16+
* [#834](https://github.com/magento/magento2-functional-testing-framework/pull/834) -- Removed usage of AspectMock in AnnotationsCheckTest
17+
* [#838](https://github.com/magento/magento2-functional-testing-framework/pull/838) -- Removed usage of AspectMock in DeprecatedEntityUsageCheckTest
18+
* [#841](https://github.com/magento/magento2-functional-testing-framework/pull/841) -- Removed usage of AspectMock in GenerationErrorHandlerTest
19+
* [#854](https://github.com/magento/magento2-functional-testing-framework/pull/854) -- Updated "monolog" to the latest version 2.3.1
20+
321
3.5.1
422
---------
523

624
### GitHub Pull Requests:
725

826
* [#825](https://github.com/magento/magento2-functional-testing-framework/pull/825) -- Update allure-codeception in order to support php8
927

10-
1128
3.5.0
1229
---------
1330

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento/magento2-functional-testing-framework",
33
"description": "Magento2 Functional Testing Framework",
44
"type": "library",
5-
"version": "3.5.1",
5+
"version": "3.6.0",
66
"license": "AGPL-3.0",
77
"keywords": ["magento", "automation", "functional", "testing"],
88
"config": {

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/FileStorageTest.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,38 @@
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\DataGenerator\Handlers\SecretStorage;
89

910
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\FileStorage;
11+
use ReflectionClass;
1012
use tests\unit\Util\MagentoTestCase;
11-
use AspectMock\Test as AspectMock;
1213

1314
class FileStorageTest extends MagentoTestCase
1415
{
15-
1616
/**
1717
* Test basic encryption/decryption functionality in FileStorage class.
1818
*/
19-
public function testBasicEncryptDecrypt()
19+
public function testBasicEncryptDecrypt(): void
2020
{
2121
$testKey = 'magento/myKey';
2222
$testValue = 'myValue';
23-
24-
AspectMock::double(FileStorage::class, [
25-
'readInCredentialsFile' => ["$testKey=$testValue"]
26-
]);
23+
$creds = ["$testKey=$testValue"];
2724

2825
$fileStorage = new FileStorage();
26+
$reflection = new ReflectionClass(FileStorage::class);
27+
28+
// Emulate initialize() function result with the test credentials
29+
$reflectionMethod = $reflection->getMethod('encryptCredFileContents');
30+
$reflectionMethod->setAccessible(true);
31+
$secretData = $reflectionMethod->invokeArgs($fileStorage, [$creds]);
32+
33+
// Set encrypted test credentials to the private 'secretData' property
34+
$reflectionProperty = $reflection->getProperty('secretData');
35+
$reflectionProperty->setAccessible(true);
36+
$reflectionProperty->setValue($fileStorage, $secretData);
37+
2938
$encryptedCred = $fileStorage->getEncryptedValue($testKey);
3039

3140
// assert the value we've gotten is in fact not identical to our test value

dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/ActionMergeUtilTest.php

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,29 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace tests\unit\Magento\FunctionalTestFramework\Test\Util;
79

8-
use AspectMock\Test as AspectMock;
910
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
1011
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
1112
use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException;
1213
use Magento\FunctionalTestingFramework\Exceptions\XmlException;
1314
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
1415
use Magento\FunctionalTestingFramework\Test\Util\ActionMergeUtil;
1516
use Magento\FunctionalTestingFramework\Test\Util\ActionObjectExtractor;
17+
use ReflectionProperty;
1618
use tests\unit\Util\MagentoTestCase;
1719
use tests\unit\Util\TestLoggingUtil;
1820

1921
class ActionMergeUtilTest extends MagentoTestCase
2022
{
2123
/**
22-
* Before test functionality
24+
* Before test functionality.
25+
*
2326
* @return void
2427
*/
25-
public function setUp(): void
28+
protected function setUp(): void
2629
{
2730
TestLoggingUtil::getInstance()->setMockLoggingUtil();
2831
}
@@ -31,8 +34,10 @@ public function setUp(): void
3134
* Test to validate actions are properly ordered during a merge.
3235
*
3336
* @return void
37+
* @throws TestReferenceException
38+
* @throws XmlException
3439
*/
35-
public function testResolveActionStepOrdering()
40+
public function testResolveActionStepOrdering(): void
3641
{
3742
$actions = [];
3843
$actionsLength = 11;
@@ -46,7 +51,6 @@ public function testResolveActionStepOrdering()
4651
$stepKey = 'stepKey'. $i;
4752
$type = 'testType';
4853
$actionAttributes = [];
49-
5054
$actions[] = new ActionObject($stepKey, $type, $actionAttributes);
5155
}
5256

@@ -93,8 +97,10 @@ public function testResolveActionStepOrdering()
9397
* Test to validate action steps properly resolve entity data references.
9498
*
9599
* @return void
100+
* @throws TestReferenceException
101+
* @throws XmlException
96102
*/
97-
public function testResolveActionStepEntityData()
103+
public function testResolveActionStepEntityData(): void
98104
{
99105
$dataObjectName = 'myObject';
100106
$dataObjectType = 'testObject';
@@ -110,36 +116,35 @@ public function testResolveActionStepEntityData()
110116
$mockDataObject = new EntityDataObject($dataObjectName, $dataObjectType, $mockData, null, null, null);
111117

112118
// Set up mock DataObject Handler
113-
$mockDOHInstance = AspectMock::double(DataObjectHandler::class, ['getObject' => $mockDataObject])->make();
114-
AspectMock::double(DataObjectHandler::class, ['getInstance' => $mockDOHInstance]);
119+
$mockDOHInstance = $this->createMock(DataObjectHandler::class);
120+
$mockDOHInstance
121+
->expects($this->any())
122+
->method('getObject')
123+
->willReturn($mockDataObject);
124+
$property = new ReflectionProperty(DataObjectHandler::class, 'INSTANCE');
125+
$property->setAccessible(true);
126+
$property->setValue($mockDOHInstance, $mockDOHInstance);
115127

116128
// Create test object and action object
117129
$actionAttributes = [$userInputKey => $userInputValue];
118130
$actions[$actionName] = new ActionObject($actionName, $actionType, $actionAttributes);
119-
120131
$this->assertEquals($userInputValue, $actions[$actionName]->getCustomActionAttributes()[$userInputKey]);
121132

122133
$mergeUtil = new ActionMergeUtil("test", "TestCase");
123134
$resolvedActions = $mergeUtil->resolveActionSteps($actions);
124-
125135
$this->assertEquals($dataFieldValue, $resolvedActions[$actionName]->getCustomActionAttributes()[$userInputKey]);
126136
}
127137

128138
/**
129139
* Verify that an XmlException is thrown when an action references a non-existant action.
130140
*
131-
* @throws TestReferenceException
132-
* @throws XmlException
133141
* @return void
134-
*/
135-
/**
136142
* @throws TestReferenceException
137143
* @throws XmlException
138144
*/
139-
public function testNoActionException()
145+
public function testNoActionException(): void
140146
{
141147
$actionObjects = [];
142-
143148
$actionObjects[] = new ActionObject('actionKey1', 'bogusType', []);
144149
$actionObjects[] = new ActionObject(
145150
'actionKey2',
@@ -149,20 +154,19 @@ public function testNoActionException()
149154
ActionObject::MERGE_ACTION_ORDER_BEFORE
150155
);
151156

152-
$this->expectException(\Magento\FunctionalTestingFramework\Exceptions\XmlException::class);
153-
157+
$this->expectException(XmlException::class);
154158
$actionMergeUtil = new ActionMergeUtil("actionMergeUtilTest", "TestCase");
155159
$actionMergeUtil->resolveActionSteps($actionObjects);
156160
}
157161

158162
/**
159163
* Verify that a <waitForPageLoad> action is added after actions that have a wait (timeout property).
160164
*
165+
* @return void
161166
* @throws TestReferenceException
162167
* @throws XmlException
163-
* @return void
164168
*/
165-
public function testInsertWait()
169+
public function testInsertWait(): void
166170
{
167171
$actionObjectOne = new ActionObject('actionKey1', 'bogusType', []);
168172
$actionObjectOne->setTimeout(42);
@@ -185,10 +189,11 @@ public function testInsertWait()
185189
/**
186190
* Verify that a <fillField> action is replaced by <fillSecretField> when secret _CREDS are referenced.
187191
*
192+
* @return void
188193
* @throws TestReferenceException
189194
* @throws XmlException
190195
*/
191-
public function testValidFillFieldSecretFunction()
196+
public function testValidFillFieldSecretFunction(): void
192197
{
193198
$actionObjectOne = new ActionObject(
194199
'actionKey1',
@@ -198,7 +203,6 @@ public function testValidFillFieldSecretFunction()
198203
$actionObject = [$actionObjectOne];
199204

200205
$actionMergeUtil = new ActionMergeUtil('actionMergeUtilTest', 'TestCase');
201-
202206
$result = $actionMergeUtil->resolveActionSteps($actionObject);
203207

204208
$expectedValue = new ActionObject(
@@ -212,10 +216,11 @@ public function testValidFillFieldSecretFunction()
212216
/**
213217
* Verify that a <magentoCLI> action uses <magentoCLI> when secret _CREDS are referenced.
214218
*
219+
* @return void
215220
* @throws TestReferenceException
216221
* @throws XmlException
217222
*/
218-
public function testValidMagentoCLISecretFunction()
223+
public function testValidMagentoCLISecretFunction(): void
219224
{
220225
$actionObjectOne = new ActionObject(
221226
'actionKey1',
@@ -225,7 +230,6 @@ public function testValidMagentoCLISecretFunction()
225230
$actionObject = [$actionObjectOne];
226231

227232
$actionMergeUtil = new ActionMergeUtil('actionMergeUtilTest', 'TestCase');
228-
229233
$result = $actionMergeUtil->resolveActionSteps($actionObject);
230234

231235
$expectedValue = new ActionObject(
@@ -239,10 +243,11 @@ public function testValidMagentoCLISecretFunction()
239243
/**
240244
* Verify that a <field> override in a <createData> action uses <field> when secret _CREDS are referenced.
241245
*
246+
* @return void
242247
* @throws TestReferenceException
243248
* @throws XmlException
244249
*/
245-
public function testValidCreateDataSecretFunction()
250+
public function testValidCreateDataSecretFunction(): void
246251
{
247252
$actionObjectOne = new ActionObject(
248253
'actionKey1',
@@ -252,7 +257,6 @@ public function testValidCreateDataSecretFunction()
252257
$actionObject = [$actionObjectOne];
253258

254259
$actionMergeUtil = new ActionMergeUtil('actionMergeUtilTest', 'TestCase');
255-
256260
$result = $actionMergeUtil->resolveActionSteps($actionObject);
257261

258262
$expectedValue = new ActionObject(
@@ -266,10 +270,11 @@ public function testValidCreateDataSecretFunction()
266270
/**
267271
* Verify that a <click> action throws an exception when secret _CREDS are referenced.
268272
*
273+
* @return void
269274
* @throws TestReferenceException
270275
* @throws XmlException
271276
*/
272-
public function testInvalidSecretFunctions()
277+
public function testInvalidSecretFunctions(): void
273278
{
274279
$this->expectException(TestReferenceException::class);
275280
$this->expectExceptionMessage(
@@ -288,7 +293,8 @@ public function testInvalidSecretFunctions()
288293
}
289294

290295
/**
291-
* After class functionality
296+
* After class functionality.
297+
*
292298
* @return void
293299
*/
294300
public static function tearDownAfterClass(): void

0 commit comments

Comments
 (0)