magento / magento2-functional-testing-framework

Magento2 Functional Testing Framework
Other
155 stars 133 forks source link

Eliminated Aspect Mock usage from ActionMergeUtilTest #837

Closed vlmed closed 3 years ago

vlmed commented 3 years ago

Description

This PR will pass all tests after related PR will be merged

Eliminated Aspect Mock usage from ActionMergeUtilTest: dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/ActionMergeUtilTest.php

Related Pull Requests

https://github.com/magento/magento2-functional-testing-framework/pull/849

Fixed Issues (if relevant)

  1. magento/magento2#33304: [MFTF] Replace AspectMock with PHPUnit for ActionMergeUtilTest

Contribution checklist

sivaschenko commented 3 years ago

@vlmed was this PR closed intentionally?

vlmed commented 3 years ago

@sivaschenko. Yes i closed this PR. When I run only this test, it passes without errors, if I run with all the tests, it does not pass. The reason is in AspectMock::double(DataObjectHandler::class, ['getInstance' => $mockDOHInstance]); static method. Looks like if we fully remove AspectMock from project my changes in the test should work. I can reopen PR if this changes is correct

sivaschenko commented 3 years ago

Got it, thanks @vlmed . I will add your PR to the issue description and unassign you from the issue

bohdan-harniuk commented 3 years ago

Hello, @jilu1

I have a little bit helped for @vlmed with the aspect mock elimination here. Now all tests run fine.

The problem was that AspectMock mocked the getInstance method of the DataObjectHandler class. In this test, we set mock to the INSTANCE variable through the ReflectionProperty. But we got the wrong mock instance, mocked by the AspectMock (the INSTANCE variable checked in the getInstance method...getInstance method mocked by the AspectMock and that mocked object returned before our mock on the INSTANCE variable).

cc: @vlmed , @sivaschenko

bohdan-harniuk commented 3 years ago

Hello, @jilu1

This task was finished without creating new singletons, so it is not a blocker. You can proceed with the code review.

Thanks, Bohdan

jilu1 commented 3 years ago

@magento import pull request to https://github.com/magento-commerce/magento2-functional-testing-framework

magento-engcom-team commented 3 years ago

@jilu1 the pull request successfully imported.