Description
Goal
codeception/aspect-mock
library is still not compatible with PHP 8.0 at the time of the creation of this ticket.
To speed up Magento compatibility with new PHP versions we'd like to eliminate codeception/aspect-mock
dependency from MFTF. This will make MFTF compatible with PHP 8.0 that is required for declaring the Magento core PHP 8 compatible as well.
In order to do this existing unit tests using AspectMock should be refactored to use PHPUnit instead.
Task
Replace AspectMock with PHPUnit for dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php
in https://github.com/magento/magento2-functional-testing-framework repository.
Example
Mocking an object using AspectMock (current):
$mock = AspectMock::double(
MockedClass::class,
[
'mockedMethodName' => 'methodReturnValue',
]
)->make();
Mocking an object using PHPUnit (refactored code):
$mock = $this->createMock(File::class);
$file->expects($this->any())
->method('mockedMethodName')
->willReturn('methodReturnValue');
Example pull request: magento/magento2-functional-testing-framework#833