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

33308: Eliminated AspectMock usage from ModuleResolverTest.php #852

Conversation

anzin
Copy link
Contributor

@anzin anzin commented Jul 7, 2021

Description

I've eliminated AspectMock usage from dev/tests/unit/Magento/FunctionalTestFramework/Util/ModuleResolverTest.php

Fixed Issues (if relevant)

  1. Fixes [MFTF] Eliminate AspectMock from ModuleResolverTest (Complex!) magento2#33308: [MFTF] Eliminate AspectMock from ModuleResolverTest (Complex!)

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/verification tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)
  • Changes to Framework doesn't have backward incompatible changes for tests or have related Pull Request with fixes to tests

andrewbess
andrewbess previously approved these changes Jul 14, 2021
Copy link

@andrewbess andrewbess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @anzin
Thank you for your job.

@andrewbess andrewbess requested a review from jilu1 July 14, 2021 19:32
@bohdan-harniuk bohdan-harniuk added Partner: Atwix partners-contribution Pull Request is created by Magento Partner labels Jul 21, 2021
@jilu1
Copy link
Contributor

jilu1 commented Jul 22, 2021

@magento-engcom-team
Copy link

@jilu1 the pull request successfully imported.

@andrewbess andrewbess self-assigned this Jul 22, 2021
@jilu1
Copy link
Contributor

jilu1 commented Jul 22, 2021

@anzin
Thank you for your PR! Please address unit test failure in ModuleResolverTest.

@bohdan-harniuk bohdan-harniuk self-requested a review July 22, 2021 14:55
bohdan-harniuk
bohdan-harniuk previously approved these changes Jul 22, 2021
Copy link
Contributor

@bohdan-harniuk bohdan-harniuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, @anzin!
Good job! Thank you for your contribution!

Hello, @jilu1!
Could you please check everything here? I've refactored the code a little bit. Now all tests passed successfully!

Thanks, Bohdan

@jilu1
Copy link
Contributor

jilu1 commented Jul 23, 2021

@magento-engcom-team
Copy link

@jilu1 the pull request successfully imported.

Copy link
Contributor

@jilu1 jilu1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anzin @bohdan-harniuk
Can we make sure to have the removed unit tests added back in for the new ModuleResolverService?
For example, testAggregateTestModulePathsDevTests, testGetModulePathsLocations, testGetComposerJsonTestModulePathsForPathInvocation, testGetComposerInstalledTestModulePathsForPathInvocation , etc

@anzin
Copy link
Contributor Author

anzin commented Jul 26, 2021

Hello @jilu1 , sorry I don't understand your question. I removed these tests because we eliminate AspectMock, and these tests are not necessary, or I misunderstood something?

Thank you.

@bohdan-harniuk bohdan-harniuk self-assigned this Jul 27, 2021
@jilu1
Copy link
Contributor

jilu1 commented Jul 28, 2021

Hello @jilu1 , sorry I don't understand your question. I removed these tests because we eliminate AspectMock, and these tests are not necessary, or I misunderstood something?

Thank you.

@anzin Can you explain why these tests are not necessary? In other words, should you add these testAggregateTestModulePathsDevTests, testGetModulePathsLocations, testGetComposerJsonTestModulePathsForPathInvocation, testGetComposerInstalledTestModulePathsForPathInvocation as unit test for new class ModuleResolverService?

@anzin anzin requested a review from jilu1 July 30, 2021 20:00
andrewbess
andrewbess previously approved these changes Jul 30, 2021
Copy link

@andrewbess andrewbess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @anzin
Thank you for your contribution.
Good job.

Comment on lines 164 to 189
$moduleResolverService = $this->createPartialMock(ModuleResolverService::class, ['globRelevantPaths']);
$moduleResolverService
->method('globRelevantPaths')
->withConsecutive()
->will(
$this->returnCallback(
function ($codePath, $pattern) use ($modulePath, $magentoBaseCodePath) {
if ($codePath === $modulePath && $pattern === '') {
return [];
}

if ($codePath === $magentoBaseCodePath . '/vendor' && $pattern === 'Test/Mftf') {
return [];
}

if ($codePath === $magentoBaseCodePath . "/app/code" && $pattern === 'Test/Mftf') {
return [];
}

$this->fail(sprintf(
'Not expected parameter: \'%s\' when invoked method globRelevantPaths().',
$modulePath
));
}
)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anzin
This is close but does not match exactly what the original test does. The original test makes sure that all the paths parameters are used at least once, but the new test will miss that.

Copy link
Contributor

@jilu1 jilu1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All look good except one comment. Please check.

@anzin anzin force-pushed the improvement/mftf-33308-eliminate-aspect-mock-from-module-resolver-test branch from 5cf7039 to 3a1ae0d Compare August 4, 2021 08:38
@anzin
Copy link
Contributor Author

anzin commented Aug 4, 2021

Hello @jilu1 , I've fixed test 'testGetModulePathsLocations', please check if everything is well.

Thanks.

andrewbess
andrewbess previously approved these changes Aug 4, 2021
@jilu1 jilu1 removed the needs update label Aug 4, 2021
jilu1
jilu1 previously approved these changes Aug 4, 2021
@jilu1
Copy link
Contributor

jilu1 commented Aug 4, 2021

@magento-engcom-team
Copy link

@jilu1 the pull request successfully imported.

bohdan-harniuk
bohdan-harniuk previously approved these changes Aug 4, 2021
Copy link
Contributor

@bohdan-harniuk bohdan-harniuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anzin, thank you for your work here!

…ing-framework into improvement/mftf-33308-eliminate-aspect-mock-from-module-resolver-test
@bohdan-harniuk bohdan-harniuk dismissed stale reviews from jilu1, andrewbess, and themself via 89812a2 August 11, 2021 13:54
@bohdan-harniuk bohdan-harniuk force-pushed the improvement/mftf-33308-eliminate-aspect-mock-from-module-resolver-test branch from 3a1ae0d to 89812a2 Compare August 11, 2021 13:54
Copy link
Contributor

@bohdan-harniuk bohdan-harniuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @jilu1!

I've actualised and fixed this PR.
Could you please proceed with the code review and check everything?

Thanks, Bohdan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress Partner: Atwix partners-contribution Pull Request is created by Magento Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MFTF] Eliminate AspectMock from ModuleResolverTest (Complex!)
6 participants