Skip to content

Commit 432cd23

Browse files
authored
Merge branch 'develop' into imported-magento-magento2-functional-testing-framework-852
2 parents 3a1ae0d + 724dd94 commit 432cd23

38 files changed

+2413
-1518
lines changed

CHANGELOG.md

+18-1
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

+4-4
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": {
@@ -25,8 +25,9 @@
2525
"csharpru/vault-php": "^4.2.1",
2626
"csharpru/vault-php-guzzle6-transport": "^2.0",
2727
"hoa/console": "~3.0",
28-
"monolog/monolog": "^2.2",
28+
"monolog/monolog": "^2.3",
2929
"mustache/mustache": "~2.5",
30+
"nikic/php-parser": "^4.4",
3031
"php-webdriver/webdriver": "^1.9.0",
3132
"spomky-labs/otphp": "^10.0",
3233
"symfony/console": "^4.4",
@@ -35,8 +36,7 @@
3536
"symfony/mime": "^5.0",
3637
"symfony/process": "^4.4",
3738
"vlucas/phpdotenv": "^2.4",
38-
"weew/helpers-array": "^1.3",
39-
"nikic/php-parser": "^4.4"
39+
"weew/helpers-array": "^1.3"
4040
},
4141
"require-dev": {
4242
"brainmaestro/composer-git-hooks": "^2.3.1",

composer.lock

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/unit/Magento/FunctionalTestFramework/Allure/AllureHelperTest.php

+74-43
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,36 @@
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\Allure;
79

810
use Magento\FunctionalTestingFramework\Allure\AllureHelper;
911
use Magento\FunctionalTestingFramework\Allure\Event\AddUniqueAttachmentEvent;
12+
use Magento\FunctionalTestingFramework\ObjectManager;
13+
use PHPUnit\Framework\TestCase;
14+
use ReflectionProperty;
1015
use Yandex\Allure\Adapter\Allure;
11-
use Yandex\Allure\Adapter\Event\AddAttachmentEvent;
16+
use Yandex\Allure\Adapter\AllureException;
1217
use Yandex\Allure\Adapter\Event\StepFinishedEvent;
1318
use Yandex\Allure\Adapter\Event\StepStartedEvent;
1419
use Yandex\Allure\Adapter\Model\Attachment;
15-
use AspectMock\Test as AspectMock;
16-
use PHPUnit\Framework\TestCase;
1720

1821
class AllureHelperTest extends TestCase
1922
{
20-
const MOCK_FILENAME = 'filename';
23+
private const MOCK_FILENAME = 'filename';
2124

2225
/**
23-
* Clear Allure Lifecycle
26+
* The AddAttachmentToStep should add an attachment to the current step.
27+
*
28+
* @return void
29+
* @throws AllureException
2430
*/
25-
public function tearDown(): void
31+
public function testAddAttachmentToStep(): void
2632
{
27-
Allure::setDefaultLifecycle();
28-
AspectMock::clean();
29-
}
30-
31-
/**
32-
* AddAtachmentToStep should add an attachment to the current step
33-
* @throws \Yandex\Allure\Adapter\AllureException
34-
*/
35-
public function testAddAttachmentToStep()
36-
{
37-
$this->mockAttachmentWriteEvent();
38-
$expectedData = "string";
39-
$expectedCaption = "caption";
33+
$expectedData = 'string';
34+
$expectedCaption = 'caption';
35+
$this->mockAttachmentWriteEvent($expectedData, $expectedCaption);
4036

4137
//Prepare Allure lifecycle
4238
Allure::lifecycle()->fire(new StepStartedEvent('firstStep'));
@@ -51,14 +47,16 @@ public function testAddAttachmentToStep()
5147
}
5248

5349
/**
54-
* AddAttachmentToLastStep should add an attachment only to the last step
55-
* @throws \Yandex\Allure\Adapter\AllureException
50+
* The AddAttachmentToLastStep should add an attachment only to the last step.
51+
*
52+
* @return void
53+
* @throws AllureException
5654
*/
57-
public function testAddAttachmentToLastStep()
55+
public function testAddAttachmentToLastStep(): void
5856
{
59-
$this->mockAttachmentWriteEvent();
60-
$expectedData = "string";
61-
$expectedCaption = "caption";
57+
$expectedData = 'string';
58+
$expectedCaption = 'caption';
59+
$this->mockAttachmentWriteEvent($expectedData, $expectedCaption);
6260

6361
//Prepare Allure lifecycle
6462
Allure::lifecycle()->fire(new StepStartedEvent('firstStep'));
@@ -87,14 +85,15 @@ public function testAddAttachmentToLastStep()
8785
}
8886

8987
/**
90-
* AddAttachment actions should have files with different attachment names
91-
* @throws \Yandex\Allure\Adapter\AllureException
88+
* The AddAttachment actions should have files with different attachment names.
89+
*
90+
* @return void
91+
* @throws AllureException
9292
*/
93-
public function testAddAttachementUniqueName()
93+
public function testAddAttachmentUniqueName(): void
9494
{
95-
$this->mockCopyFile();
96-
$expectedData = "string";
97-
$expectedCaption = "caption";
95+
$expectedData = 'string';
96+
$expectedCaption = 'caption';
9897

9998
//Prepare Allure lifecycle
10099
Allure::lifecycle()->fire(new StepStartedEvent('firstStep'));
@@ -111,24 +110,56 @@ public function testAddAttachementUniqueName()
111110
}
112111

113112
/**
114-
* Mock entire attachment writing mechanisms
115-
* @throws \Exception
113+
* Clear Allure Lifecycle.
114+
*
115+
* @return void
116116
*/
117-
public function mockAttachmentWriteEvent()
117+
protected function tearDown(): void
118118
{
119-
AspectMock::double(AddUniqueAttachmentEvent::class, [
120-
"getAttachmentFileName" => self::MOCK_FILENAME
121-
]);
119+
Allure::setDefaultLifecycle();
120+
121+
$objectManagerProperty = new ReflectionProperty(ObjectManager::class, 'instance');
122+
$objectManagerProperty->setAccessible(true);
123+
$objectManagerProperty->setValue(null);
122124
}
123125

124126
/**
125-
* Mock only file writing mechanism
126-
* @throws \Exception
127+
* Mock entire attachment writing mechanisms.
128+
*
129+
* @param string $filePathOrContents
130+
* @param string $caption
131+
*
132+
* @return void
127133
*/
128-
public function mockCopyFile()
134+
private function mockAttachmentWriteEvent(string $filePathOrContents, string $caption): void
129135
{
130-
AspectMock::double(AddUniqueAttachmentEvent::class, [
131-
"copyFile" => true
132-
]);
136+
$mockInstance = $this->getMockBuilder(AddUniqueAttachmentEvent::class)
137+
->setConstructorArgs([$filePathOrContents, $caption])
138+
->disallowMockingUnknownTypes()
139+
->onlyMethods(['getAttachmentFileName'])
140+
->getMock();
141+
142+
$mockInstance
143+
->method('getAttachmentFileName')
144+
->willReturn(self::MOCK_FILENAME);
145+
146+
$objectManagerMockInstance = $this->createMock(ObjectManager::class);
147+
$objectManagerMockInstance
148+
->method('create')
149+
->will(
150+
$this->returnCallback(
151+
function (string $class) use ($mockInstance) {
152+
if ($class === AddUniqueAttachmentEvent::class) {
153+
return $mockInstance;
154+
}
155+
156+
return null;
157+
}
158+
)
159+
);
160+
161+
$objectManagerProperty = new ReflectionProperty(ObjectManager::class, 'instance');
162+
$objectManagerProperty->setAccessible(true);
163+
$objectManagerProperty->setValue($objectManagerMockInstance, $objectManagerMockInstance);
133164
}
134165
}

0 commit comments

Comments
 (0)