Skip to content

Commit f9da313

Browse files
Merge branch 'develop' of github.com:magento/magento2-functional-testing-framework into 33294-eliminate-aspectmock-from-allure-helpertest
2 parents b0e9c2e + b2b628c commit f9da313

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1748
-1080
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: 4 additions & 4 deletions
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": "^1.17",
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

Lines changed: 30 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/unit/Magento/FunctionalTestFramework/Config/Reader/FilesystemTest.php

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,23 @@
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\Config\Reader;
79

10+
use Magento\FunctionalTestingFramework\Config\ConverterInterface;
811
use Magento\FunctionalTestingFramework\Config\FileResolver\Module;
912
use Magento\FunctionalTestingFramework\Config\Reader\Filesystem;
13+
use Magento\FunctionalTestingFramework\Config\SchemaLocatorInterface;
1014
use Magento\FunctionalTestingFramework\Config\ValidationState;
1115
use Magento\FunctionalTestingFramework\Util\Iterator\File;
16+
use PHPUnit\Framework\MockObject\MockObject;
1217
use PHPUnit\Framework\TestCase;
13-
use AspectMock\Test as AspectMock;
1418
use tests\unit\Util\TestLoggingUtil;
1519

1620
class FilesystemTest extends TestCase
1721
{
1822
/**
19-
* Before test functionality
2023
* @return void
2124
*/
2225
public function setUp(): void
@@ -25,79 +28,80 @@ public function setUp(): void
2528
}
2629

2730
/**
28-
* Test Reading Empty Files
2931
* @throws \Exception
3032
*/
3133
public function testEmptyXmlFile()
3234
{
33-
// create mocked items and read the file
34-
$someFile = $this->setMockFile("somepath.xml", "");
35-
$filesystem = $this->createPseudoFileSystem($someFile);
36-
$filesystem->read();
35+
$filesystem = $this->getFilesystem($this->getFileIterator('somepath.xml', ''));
36+
$this->assertEquals([], $filesystem->read());
3737

38-
// validate log statement
3938
TestLoggingUtil::getInstance()->validateMockLogStatement(
40-
"warning",
41-
"XML File is empty.",
42-
["File" => "somepath.xml"]
39+
'warning',
40+
'XML File is empty.',
41+
['File' => 'somepath.xml']
4342
);
4443
}
4544

4645
/**
47-
* Function used to set mock for File created in test
46+
* Retrieve mocked file iterator
4847
*
4948
* @param string $fileName
5049
* @param string $content
51-
* @return object
50+
* @return File|MockObject
5251
* @throws \Exception
5352
*/
54-
public function setMockFile($fileName, $content)
53+
public function getFileIterator(string $fileName, string $content): File
5554
{
56-
$file = AspectMock::double(
57-
File::class,
58-
[
59-
'current' => "",
60-
'count' => 1,
61-
'getFilename' => $fileName
62-
]
63-
)->make();
55+
$iterator = new \ArrayIterator([$content]);
56+
57+
$file = $this->createMock(File::class);
58+
59+
$file->method('current')
60+
->willReturn($content);
61+
$file->method('getFilename')
62+
->willReturn($fileName);
63+
$file->method('count')
64+
->willReturn(1);
65+
66+
$file->method('next')
67+
->willReturnCallback(function () use ($iterator): void {
68+
$iterator->next();
69+
});
6470

65-
//set mocked data property for File
66-
$property = new \ReflectionProperty(File::class, 'data');
67-
$property->setAccessible(true);
68-
$property->setValue($file, [$fileName => $content]);
71+
$file->method('valid')
72+
->willReturnCallback(function () use ($iterator): bool {
73+
return $iterator->valid();
74+
});
6975

7076
return $file;
7177
}
7278

7379
/**
74-
* Function used to set mock for filesystem class during test
80+
* Get real instance of Filesystem class with mocked dependencies
7581
*
76-
* @param string $fileList
77-
* @return object
78-
* @throws \Exception
82+
* @param File $fileIterator
83+
* @return Filesystem
7984
*/
80-
public function createPseudoFileSystem($fileList)
85+
public function getFilesystem(File $fileIterator): Filesystem
8186
{
82-
$filesystem = AspectMock::double(Filesystem::class)->make();
83-
84-
//set resolver to use mocked resolver
85-
$mockFileResolver = AspectMock::double(Module::class, ['get' => $fileList])->make();
86-
$property = new \ReflectionProperty(Filesystem::class, 'fileResolver');
87-
$property->setAccessible(true);
88-
$property->setValue($filesystem, $mockFileResolver);
89-
90-
//set validator to use mocked validator
91-
$mockValidation = AspectMock::double(ValidationState::class, ['isValidationRequired' => false])->make();
92-
$property = new \ReflectionProperty(Filesystem::class, 'validationState');
93-
$property->setAccessible(true);
94-
$property->setValue($filesystem, $mockValidation);
87+
$fileResolver = $this->createMock(Module::class);
88+
$fileResolver->method('get')
89+
->willReturn($fileIterator);
90+
$validationState = $this->createMock(ValidationState::class);
91+
$validationState->method('isValidationRequired')
92+
->willReturn(false);
93+
$filesystem = new Filesystem(
94+
$fileResolver,
95+
$this->createMock(ConverterInterface::class),
96+
$this->createMock(SchemaLocatorInterface::class),
97+
$validationState,
98+
''
99+
);
95100

96101
return $filesystem;
97102
}
98103

99104
/**
100-
* After class functionality
101105
* @return void
102106
*/
103107
public static function tearDownAfterClass(): void

0 commit comments

Comments
 (0)