Skip to content

Conversation

@aleron75
Copy link
Contributor

Description

Change regex in ControllerAclTest::getControllerPath() to avoid classes which are under a namespace with a "Controller" part (like for example controller plugins) being interpreted as controllers causing the Act test to fail.

I need this change because, in the scope of MSI development, I have to define the following plugin for a controller:

    <type name="Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter">
        <plugin name="allow_negative_min_qty"
                type="Magento\InventoryCatalog\Plugin\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter\AllowNegativeMinQtyPlugin"
                sortOrder="1"/>

The Magento\InventoryCatalog\Plugin\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter\AllowNegativeMinQtyPlugin plugin class makes the test fail because it is considered a controller but doesn't extend \Magento\Backend\App\AbstractAction.

Manual testing scenarios

  • define a plugin on a controller declaring it under a namespace with a "Controller" part
  • run the ControllerAclTest static test
  • expect the test to fail

Change regex in getControllerPath() to avoid classes which are under "Controller" namespace (like for example controller plugins) being interpreted as controllers causing the Act test to fail.
@magento-engcom-team
Copy link
Contributor

Hi @aleron75. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me {$VERSION} instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@miguelbalparda miguelbalparda self-assigned this Jul 10, 2018
@orlangur orlangur self-assigned this Jul 10, 2018
private function getControllerPath($relativeFilePath)
{
if (preg_match('~(Magento\/.*Controller\/Adminhtml\/.*)\.php~', $relativeFilePath, $matches)) {
if (preg_match('~(Magento\/[^\/]+\/Controller\/Adminhtml\/.*)\.php~', $relativeFilePath, $matches)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, but you need apply changes to 2.2-develop first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created PR #16707 fir 2.2-develop, thanks

@magento-engcom-team
Copy link
Contributor

Hi @orlangur, thank you for the review.
ENGCOM-2275 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

Hi @miguelbalparda, thank you for the review.
ENGCOM-2275 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

Hi @aleron75. Thank you for your contribution.
We will aim to release these changes as part of 2.3.0.
Please check the release notes for final confirmation.

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.

4 participants