Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminated Aspect Mock usage from FilesystemTest #833

Merged

Conversation

sivaschenko
Copy link
Member

@sivaschenko sivaschenko commented Jun 20, 2021

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

Resolves magento/magento2#33291

Replace AspectMock with PHPUnit for dev/tests/unit/Magento/FunctionalTestFramework/Config/Reader/FilesystemTest.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');

@sivaschenko sivaschenko requested a review from jilu1 June 20, 2021 10:56
@sivaschenko
Copy link
Member Author

@jilu1 I have created this pull request to use as an example of changes for the following tickets. Please review and suggest any best practices that should be applied or mentioned.

I think it's important for us to have stable Unit tests for the refactoring tasks, are there any expectations on when it can be stabilized?

This was referenced Jun 20, 2021
@jilu1
Copy link
Contributor

jilu1 commented Jun 23, 2021

@magento-engcom-team
Copy link

@jilu1 the pull request successfully imported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MFTF] Replace AspectMock with PHPUnit for FilesystemTest
4 participants