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

Integration Test Annotation magentoAppArea breaks with some valid values #2907

Closed
Vinai opened this issue Jan 6, 2016 · 7 comments
Closed
Assignees
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@Vinai
Copy link
Contributor

Vinai commented Jan 6, 2016

The following test breaks due to Annotation\AppArea trying to init the design.

/**
 * @magentoAppArea webapi_rest
 */
public function testTheModuleRegisteresAnAddressRepositoryPlugin()
{
    /** @var \Magento\TestFramework\Interception\PluginList $pluginList */
    $pluginList = $this->objectManager->get(PluginList::class);
    $pluginInfo = $pluginList->get(AddressRepositoryInterface::class, []);
    $this->assertSame(AddressRepositoryPlugin::class, $pluginInfo['example_module'[['instance']);
}

The relevant part of the stack trace is:

PHP Fatal error:  Uncaught InvalidArgumentException: Incorrect theme identification key in .../mage2-ce/vendor/magento/framework/View/Design/Theme/FlyweightFactory.php:56
Stack trace:
#0 .../mage2-ce/vendor/magento/module-theme/Model/View/Design.php(147): Magento\Framework\View\Design\Theme\FlyweightFactory->create(NULL, 'webapi_rest')
#1 .../mage2-ce/vendor/magento/module-theme/Model/View/Design.php(211): Magento\Theme\Model\View\Design->setDesignTheme(NULL)
Fatal error: Uncaught InvalidArgumentException: Incorrect theme identification key in .../mage2-ce/vendor/magento/framework/View/Design/Theme/FlyweightFactory.php on line 56
#2 .../mage2-ce/vendor/magento/framework/App/Area.php(256): Magento\Theme\Model\View\Design->setDefaultDesignTheme()
#3 .../mage2-ce/vendor/magento/framework/App/Area.php(214): Magento\Framework\App\Area->_initDesign()
InvalidArgumentException: Incorrect theme identification key in .../mage2-ce/vendor/magento/framework/View/Design/Theme/FlyweightFactory.php on line 56
#4 .../mage2-ce/vendor/magento/framework/App/Area.php(136): Magento\Framework\App\Area->_loadPart('design')

...

Magento\TestFramework\Annotation\AppArea->startTest() .../mage2-ce/dev/tests/integration/framework/Magento/TestFramework/EventManager.php:49
Magento\TestFramework\Application->loadArea() .../mage2-ce/dev/tests/integration/framework/Magento/TestFramework/Annotation/AppArea.php:82
Magento\TestFramework\Helper\Bootstrap->loadArea() .../mage2-ce/dev/tests/integration/framework/Magento/TestFramework/Application.php:615
Magento\Framework\App\Area->load() .../mage2-ce/dev/tests/integration/framework/Magento/TestFramework/Helper/Bootstrap.php:157
Magento\Framework\App\Area->_loadPart() .../mage2-ce/vendor/magento/framework/App/Area.php:136
Magento\Framework\App\Area->_initDesign() .../mage2-ce/vendor/magento/framework/App/Area.php:214
Magento\Theme\Model\View\Design->setDefaultDesignTheme() .../mage2-ce/vendor/magento/framework/App/Area.php:256
Magento\Theme\Model\View\Design->setDesignTheme() .../mage2-ce/vendor/magento/module-theme/Model/View/Design.php:211
Magento\Framework\View\Design\Theme\FlyweightFactory->create() .../mage2-ce/vendor/magento/module-theme/Model/View/Design.php:147

This is despite \Magento\TestFramework\Annotation\AppArea defining the valid areas as

/**
 * List of allowed areas
 *
 * @var array
 */
private $_allowedAreas = [
    \Magento\Framework\App\Area::AREA_GLOBAL,
    \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE,
    \Magento\Framework\App\Area::AREA_FRONTEND,
    'webapi_rest',
    'webapi_soap',
    'cron',
];

The same error happens for webapi_soap and cron, too.
The other ones, frontend, adminhtml and global work as expected.

@Vinai
Copy link
Contributor Author

Vinai commented Jan 6, 2016

In case google brings someone here, a possible workaround instead of using the @magentoAppArea annotation is:

public function testTheModuleRegisteresAnAddressRepositoryPlugin()
{
    /** @var ScopeInterface $scopeConfig */
    $scopeConfig = $this->objectManager->get(ScopeInterface::class);
    $scopeConfig->setCurrentScope('webapi_rest');

    /** @var \Magento\TestFramework\Interception\PluginList $pluginList */
    $pluginList = $this->objectManager->get(PluginList::class);
    $pluginInfo = $pluginList->get(AddressRepositoryInterface::class, []);
    $this->assertSame(AddressRepositoryPlugin::class, $pluginInfo['example_module'[['instance']);
}

Just be aware the setting will persist between tests, so be sure to reset the current scope in tearDown (something that the annotation does automatically).

@duhon
Copy link
Contributor

duhon commented Jun 22, 2016

Hello @Vinai

Please, provide the used version. If the problem is actual for a specific tag, please, specify it and be sure that the latest update was used.

@Vinai
Copy link
Contributor Author

Vinai commented Jun 22, 2016

This happens in 2.1.0-rc3 and the HEAD of the develop branch.

@duhon duhon removed their assignment Jun 23, 2016
@vkorotun vkorotun removed the PS label Aug 4, 2016
@mam08ixo
Copy link

mam08ixo commented Aug 3, 2017

Thanks @Vinai – Google brought me here. The issue still exists in 2.2.0-dev (da064df).

@magento-engcom-team magento-engcom-team added bug report Dev Tools Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Sep 11, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Nov 24, 2017
@magento-engcom-team
Copy link
Contributor

@Vinai, thank you for your report.
We've created internal ticket(s) MAGETWO-84466 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Nov 24, 2017
@nmalevanec nmalevanec self-assigned this Dec 11, 2017
@ishakhsuvarov
Copy link
Contributor

@Vinai We are closing this ticket now as the issue seems to be fixed now in the 2.2-develop and will be released with 2.2.4.
You may refer to 506d500 for more information on the delivered fix.

Thanks!

@ishakhsuvarov ishakhsuvarov added Fixed in 2.2.x The issue has been fixed in 2.2 release line and removed 2.1.x bug report labels Dec 12, 2017
@magento-team
Copy link
Contributor

Hi @Vinai. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1194 by @nmalevanec in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming patch release.

@magento-team magento-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Jan 18, 2018
magento-engcom-team pushed a commit that referenced this issue Jul 26, 2018
[TSG] Backporting for 2.2 (pr36) (2.2.6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

9 participants