From 4f4c2c3ca21615bac0d35e5f7238f3a83bf8cb16 Mon Sep 17 00:00:00 2001 From: David Alger Date: Wed, 2 Dec 2015 14:20:54 -0600 Subject: [PATCH 1/5] Correct labels in PageCache module to reflect appropriate recommendations --- .../System/Config/Source/Application.php | 19 ++++++++++--------- app/code/Magento/PageCache/i18n/en_US.csv | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/PageCache/Model/System/Config/Source/Application.php b/app/code/Magento/PageCache/Model/System/Config/Source/Application.php index eb428f7c0300a..fbc96d16ec5b1 100644 --- a/app/code/Magento/PageCache/Model/System/Config/Source/Application.php +++ b/app/code/Magento/PageCache/Model/System/Config/Source/Application.php @@ -9,11 +9,13 @@ */ namespace Magento\PageCache\Model\System\Config\Source; +use Magento\Framework\Option\ArrayInterface; +use Magento\PageCache\Model\Config; + /** * Class Application - * */ -class Application implements \Magento\Framework\Option\ArrayInterface +class Application implements ArrayInterface { /** * Options getter @@ -24,12 +26,12 @@ public function toOptionArray() { return [ [ - 'value' => \Magento\PageCache\Model\Config::BUILT_IN, - 'label' => __('Built-in Application (Not Recommended for Production Use)') + 'value' => Config::BUILT_IN, + 'label' => __('Built-in Cache') ], [ - 'value' => \Magento\PageCache\Model\Config::VARNISH, - 'label' => __('Varnish Caching') + 'value' => Config::VARNISH, + 'label' => __('Varnish Cache (Recommended)') ] ]; } @@ -42,9 +44,8 @@ public function toOptionArray() public function toArray() { return [ - \Magento\PageCache\Model\Config::BUILT_IN => - __('Built-in Application (Not Recommended for Production Use)'), - \Magento\PageCache\Model\Config::VARNISH => __('Varnish Caching') + Config::BUILT_IN => __('Built-in Cache'), + Config::VARNISH => __('Varnish Cache (Recommended)') ]; } } diff --git a/app/code/Magento/PageCache/i18n/en_US.csv b/app/code/Magento/PageCache/i18n/en_US.csv index 701e12300596b..abacc674024d7 100644 --- a/app/code/Magento/PageCache/i18n/en_US.csv +++ b/app/code/Magento/PageCache/i18n/en_US.csv @@ -1,7 +1,7 @@ "Export VCL","Export VCL" "Ttl value ""%1"" is not valid. Please use only numbers equal or greater than zero.","Ttl value ""%1"" is not valid. Please use only numbers equal or greater than zero." -"Built-in Application (Not Recommended for Production Use)","Built-in Application (Not Recommended for Production Use)" -"Varnish Caching","Varnish Caching" +"Built-in Cache","Built-in Cache" +"Varnish Cache (Recommended)","Varnish Cache (Recommended)" "Full Page Cache","Full Page Cache" "Caching Application","Caching Application" "Varnish Configuration","Varnish Configuration" From 554cbad332a3c3ed4239f9e2ddd3fd8bea4aeec2 Mon Sep 17 00:00:00 2001 From: Igor Melnikov Date: Fri, 18 Dec 2015 10:10:48 -0600 Subject: [PATCH 2/5] MAGETWO-47083: Update deploy:mode:set command to use single tenant compiler Replacing multi-tenant compiler with single tenant --- app/code/Magento/Deploy/Model/Filesystem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Deploy/Model/Filesystem.php b/app/code/Magento/Deploy/Model/Filesystem.php index 5e882ce327659..18a497b213cce 100644 --- a/app/code/Magento/Deploy/Model/Filesystem.php +++ b/app/code/Magento/Deploy/Model/Filesystem.php @@ -161,7 +161,7 @@ protected function compile( DirectoryList::DI, ] ); - $cmd = $this->functionCallPath . 'setup:di:compile-multi-tenant'; + $cmd = $this->functionCallPath . 'setup:di:compile'; /** * exec command is necessary for now to isolate the autoloaders in the compiler from the memory state From 7db6e972b9348e09eb2ca5066fa353d82fb825d6 Mon Sep 17 00:00:00 2001 From: Igor Melnikov Date: Fri, 18 Dec 2015 15:12:12 -0600 Subject: [PATCH 3/5] MAGETWO-45723: Plugins methods calls two times in case when Proxy exists for subject class Adding NoninterceptableInterface to allow skip interceptor generation --- .../Config/Structure/Element/Group/Proxy.php | 3 +- .../Model/Config/Structure/Search/Proxy.php | 4 +- .../SourceClassWithNamespaceProxy.php.sample | 2 +- .../Magento/Framework/App/AreaList/Proxy.php | 3 +- .../Magento/Framework/App/Cache/Proxy.php | 12 ++-- .../App/Route/ConfigInterface/Proxy.php | 4 +- .../DataObject/Copy/Config/Data/Proxy.php | 3 +- .../ObjectManager/Config/Developer.php | 26 +++++++- .../Framework/Mview/Config/Data/Proxy.php | 3 +- .../ObjectManager/Code/Generator/Proxy.php | 8 ++- .../ObjectManager/InterceptableValidator.php | 59 +++++++++++++++++++ .../NoninterceptableInterface.php | 13 ++++ .../Code/Generator/_files/SampleProxy.txt | 2 +- .../Test/Unit/InterceptableValidatorTest.php | 26 ++++++++ .../ObjectManager/Test/Unit/_files/Proxy.php | 10 ++++ .../Framework/Translate/Inline/Proxy.php | 4 +- .../Magento/Framework/View/Layout/Proxy.php | 2 +- .../Command/DiCompileMultiTenantCommand.php | 4 +- .../InterceptionConfigurationBuilder.php | 15 ++++- .../Scanner/InheritanceInterceptorScanner.php | 33 +++++------ .../InterceptionConfigurationBuilderTest.php | 20 ++++++- 21 files changed, 217 insertions(+), 39 deletions(-) create mode 100644 lib/internal/Magento/Framework/ObjectManager/InterceptableValidator.php create mode 100644 lib/internal/Magento/Framework/ObjectManager/NoninterceptableInterface.php create mode 100644 lib/internal/Magento/Framework/ObjectManager/Test/Unit/InterceptableValidatorTest.php create mode 100644 lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Proxy.php diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Group/Proxy.php b/app/code/Magento/Config/Model/Config/Structure/Element/Group/Proxy.php index 1b3aeca06effc..7365fade4caa3 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Group/Proxy.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Group/Proxy.php @@ -5,7 +5,8 @@ */ namespace Magento\Config\Model\Config\Structure\Element\Group; -class Proxy extends \Magento\Config\Model\Config\Structure\Element\Group +class Proxy extends \Magento\Config\Model\Config\Structure\Element\Group implements + \Magento\Framework\ObjectManager\NoninterceptableInterface { /** * Object manager diff --git a/app/code/Magento/Config/Model/Config/Structure/Search/Proxy.php b/app/code/Magento/Config/Model/Config/Structure/Search/Proxy.php index eb01cd8615d20..9907fbec18576 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Search/Proxy.php +++ b/app/code/Magento/Config/Model/Config/Structure/Search/Proxy.php @@ -5,7 +5,9 @@ */ namespace Magento\Config\Model\Config\Structure\Search; -class Proxy implements \Magento\Config\Model\Config\Structure\SearchInterface +class Proxy implements + \Magento\Config\Model\Config\Structure\SearchInterface, + \Magento\Framework\ObjectManager\NoninterceptableInterface { /** * Object manager diff --git a/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceProxy.php.sample b/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceProxy.php.sample index 5ee9c95448ef8..9074f2a8e0926 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceProxy.php.sample +++ b/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceProxy.php.sample @@ -7,7 +7,7 @@ namespace Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace; * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -class Proxy extends \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace +class Proxy extends \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace implements \Magento\Framework\ObjectManager\NoninterceptableInterface { /** * Object Manager instance diff --git a/lib/internal/Magento/Framework/App/AreaList/Proxy.php b/lib/internal/Magento/Framework/App/AreaList/Proxy.php index 7f2b0a63dbcd8..e7f39ff8aa3e3 100644 --- a/lib/internal/Magento/Framework/App/AreaList/Proxy.php +++ b/lib/internal/Magento/Framework/App/AreaList/Proxy.php @@ -7,7 +7,8 @@ */ namespace Magento\Framework\App\AreaList; -class Proxy extends \Magento\Framework\App\AreaList +class Proxy extends \Magento\Framework\App\AreaList implements + \Magento\Framework\ObjectManager\NoninterceptableInterface { /** * Object Manager instance diff --git a/lib/internal/Magento/Framework/App/Cache/Proxy.php b/lib/internal/Magento/Framework/App/Cache/Proxy.php index 932d5b0c265c8..2e50e0b5d042f 100644 --- a/lib/internal/Magento/Framework/App/Cache/Proxy.php +++ b/lib/internal/Magento/Framework/App/Cache/Proxy.php @@ -3,15 +3,17 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ +namespace Magento\Framework\App\Cache; + +use \Magento\Framework\App\CacheInterface; +use \Magento\Framework\ObjectManager\NoninterceptableInterface; /** * System cache proxy model */ -namespace Magento\Framework\App\Cache; - -use Magento\Framework\App\CacheInterface; - -class Proxy implements CacheInterface +class Proxy implements + CacheInterface, + NoninterceptableInterface { /** * @var \Magento\Framework\ObjectManagerInterface diff --git a/lib/internal/Magento/Framework/App/Route/ConfigInterface/Proxy.php b/lib/internal/Magento/Framework/App/Route/ConfigInterface/Proxy.php index 50a02c458595a..50056798c85ea 100644 --- a/lib/internal/Magento/Framework/App/Route/ConfigInterface/Proxy.php +++ b/lib/internal/Magento/Framework/App/Route/ConfigInterface/Proxy.php @@ -10,7 +10,9 @@ /** * Proxy class for \Magento\Framework\App\ResourceConnection */ -class Proxy implements \Magento\Framework\App\Route\ConfigInterface +class Proxy implements + \Magento\Framework\App\Route\ConfigInterface, + \Magento\Framework\ObjectManager\NoninterceptableInterface { /** * Object Manager instance diff --git a/lib/internal/Magento/Framework/DataObject/Copy/Config/Data/Proxy.php b/lib/internal/Magento/Framework/DataObject/Copy/Config/Data/Proxy.php index 85abc882c7bb4..480af7b06ac86 100644 --- a/lib/internal/Magento/Framework/DataObject/Copy/Config/Data/Proxy.php +++ b/lib/internal/Magento/Framework/DataObject/Copy/Config/Data/Proxy.php @@ -8,7 +8,8 @@ /** * Proxy class for @see \Magento\Framework\DataObject\Copy\Config\Data */ -class Proxy extends \Magento\Framework\DataObject\Copy\Config\Data +class Proxy extends \Magento\Framework\DataObject\Copy\Config\Data implements + \Magento\Framework\ObjectManager\NoninterceptableInterface { /** * Object Manager instance diff --git a/lib/internal/Magento/Framework/Interception/ObjectManager/Config/Developer.php b/lib/internal/Magento/Framework/Interception/ObjectManager/Config/Developer.php index ebe41d0f5b46c..28c68a771cefe 100644 --- a/lib/internal/Magento/Framework/Interception/ObjectManager/Config/Developer.php +++ b/lib/internal/Magento/Framework/Interception/ObjectManager/Config/Developer.php @@ -8,9 +8,31 @@ namespace Magento\Framework\Interception\ObjectManager\Config; use Magento\Framework\Interception\ObjectManager\ConfigInterface; +use Magento\Framework\ObjectManager\DefinitionInterface; +use Magento\Framework\ObjectManager\RelationsInterface; +use Magento\Framework\ObjectManager\InterceptableValidator; class Developer extends \Magento\Framework\ObjectManager\Config\Config implements ConfigInterface { + /** + * @var InterceptableValidator + */ + private $interceptableValidator; + + /** + * @param RelationsInterface $relations + * @param DefinitionInterface $definitions + * @param InterceptableValidator $interceptableValidator + */ + public function __construct( + RelationsInterface $relations = null, + DefinitionInterface $definitions = null, + InterceptableValidator $interceptableValidator = null + ) { + $this->interceptableValidator = $interceptableValidator ?: new InterceptableValidator(); + parent::__construct($relations, $definitions); + } + /** * @var \Magento\Framework\Interception\ConfigInterface */ @@ -36,7 +58,9 @@ public function setInterceptionConfig(\Magento\Framework\Interception\ConfigInte public function getInstanceType($instanceName) { $type = parent::getInstanceType($instanceName); - if ($this->interceptionConfig && $this->interceptionConfig->hasPlugins($instanceName)) { + if ($this->interceptionConfig && $this->interceptionConfig->hasPlugins($instanceName) + && $this->interceptableValidator->validate($instanceName) + ) { return $type . '\\Interceptor'; } return $type; diff --git a/lib/internal/Magento/Framework/Mview/Config/Data/Proxy.php b/lib/internal/Magento/Framework/Mview/Config/Data/Proxy.php index 0a705796ad559..a026f2a60c82e 100644 --- a/lib/internal/Magento/Framework/Mview/Config/Data/Proxy.php +++ b/lib/internal/Magento/Framework/Mview/Config/Data/Proxy.php @@ -8,7 +8,8 @@ /** * Proxy class for \Magento\Framework\Mview\Config\Data */ -class Proxy extends \Magento\Framework\Mview\Config\Data +class Proxy extends \Magento\Framework\Mview\Config\Data implements + \Magento\Framework\ObjectManager\NoninterceptableInterface { /** * Object Manager instance diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php index 82686165132f8..c0f86fa70b2be 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php @@ -14,6 +14,11 @@ class Proxy extends \Magento\Framework\Code\Generator\EntityAbstract */ const ENTITY_TYPE = 'proxy'; + /** + * Marker interface + */ + const NON_INTERCEPTABLE_INTERFACE = '\Magento\Framework\ObjectManager\NoninterceptableInterface'; + /** * @param string $modelClassName * @return string @@ -131,9 +136,10 @@ protected function _generateCode() $reflection = new \ReflectionClass($typeName); if ($reflection->isInterface()) { - $this->_classGenerator->setImplementedInterfaces([$typeName]); + $this->_classGenerator->setImplementedInterfaces([$typeName, self::NON_INTERCEPTABLE_INTERFACE]); } else { $this->_classGenerator->setExtendedClass($typeName); + $this->_classGenerator->setImplementedInterfaces([self::NON_INTERCEPTABLE_INTERFACE]); } return parent::_generateCode(); } diff --git a/lib/internal/Magento/Framework/ObjectManager/InterceptableValidator.php b/lib/internal/Magento/Framework/ObjectManager/InterceptableValidator.php new file mode 100644 index 0000000000000..bc3c17e11d765 --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/InterceptableValidator.php @@ -0,0 +1,59 @@ +isInterceptor($className) && $this->isInterceptable($className); + } + + /** + * + * Check if instance type is interceptor + * + * @param string $instanceName + * @return bool + */ + private function isInterceptor($instanceName) + { + return $this->endsWith($instanceName, '\Interceptor'); + } + + /** + * + * Check if instance type is interceptable + * + * @param string $instanceName + * @return bool + */ + private function isInterceptable($instanceName) + { + return !is_subclass_of( + $instanceName, + \Magento\Framework\ObjectManager\Code\Generator\Proxy::NON_INTERCEPTABLE_INTERFACE + ); + } + + /** + * Check if a string ends with a substring + * + * @param string $haystack + * @param string $needle + * @return bool + */ + private function endsWith($haystack, $needle) + { + // Search forward starting from end minus needle length characters + $temp = strlen($haystack) - strlen($needle); + return $needle === '' || ($temp >= 0 && strpos($haystack, $needle, $temp) !== false); + } +} diff --git a/lib/internal/Magento/Framework/ObjectManager/NoninterceptableInterface.php b/lib/internal/Magento/Framework/ObjectManager/NoninterceptableInterface.php new file mode 100644 index 0000000000000..0950e27c233ce --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/NoninterceptableInterface.php @@ -0,0 +1,13 @@ +assertFalse( + $interceptableValidator->validate( + 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Interceptor' + ) + ); + $this->assertFalse( + $interceptableValidator->validate( + 'Magento\Test\Di\Proxy' + ) + ); + } +} diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Proxy.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Proxy.php new file mode 100644 index 0000000000000..864c00098e9e4 --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/_files/Proxy.php @@ -0,0 +1,10 @@ +getList($path); } } - $inheritanceScanner = new Scanner\InheritanceInterceptorScanner(); + $inheritanceScanner = new Scanner\InheritanceInterceptorScanner( + new \Magento\Framework\ObjectManager\InterceptableValidator() + ); $this->entities['interceptors'] = $inheritanceScanner->collectEntities( get_declared_classes(), $this->entities['interceptors'] diff --git a/setup/src/Magento/Setup/Module/Di/Code/Generator/InterceptionConfigurationBuilder.php b/setup/src/Magento/Setup/Module/Di/Code/Generator/InterceptionConfigurationBuilder.php index 5935e77fa8e71..e929ca2e04a25 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Generator/InterceptionConfigurationBuilder.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Generator/InterceptionConfigurationBuilder.php @@ -12,6 +12,7 @@ use Magento\Framework\App\Interception\Cache\CompiledConfig; use Magento\Framework\Interception\Config\Config as InterceptionConfig; use Magento\Setup\Module\Di\Code\Reader\Type; +use Magento\Framework\ObjectManager\InterceptableValidator; class InterceptionConfigurationBuilder { @@ -42,22 +43,30 @@ class InterceptionConfigurationBuilder */ private $cacheManager; + /** + * @var InterceptableValidator + */ + private $interceptableValidator; + /** * @param InterceptionConfig $interceptionConfig * @param PluginList $pluginList * @param Type $typeReader * @param Manager $cacheManager + * @param InterceptableValidator $interceptableValidator */ public function __construct( InterceptionConfig $interceptionConfig, PluginList $pluginList, Type $typeReader, - Manager $cacheManager + Manager $cacheManager, + InterceptableValidator $interceptableValidator ) { $this->interceptionConfig = $interceptionConfig; $this->pluginList = $pluginList; $this->typeReader = $typeReader; $this->cacheManager = $cacheManager; + $this->interceptableValidator = $interceptableValidator; } /** @@ -99,7 +108,9 @@ private function getInterceptedClasses($definedClasses) { $intercepted = []; foreach ($definedClasses as $definedClass) { - if ($this->interceptionConfig->hasPlugins($definedClass) && $this->typeReader->isConcrete($definedClass)) { + if ($this->interceptionConfig->hasPlugins($definedClass) && $this->typeReader->isConcrete($definedClass) + && $this->interceptableValidator->validate($definedClass) + ) { $intercepted[] = $definedClass; } } diff --git a/setup/src/Magento/Setup/Module/Di/Code/Scanner/InheritanceInterceptorScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Scanner/InheritanceInterceptorScanner.php index 39904e2e20802..733ee606fecf2 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Scanner/InheritanceInterceptorScanner.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Scanner/InheritanceInterceptorScanner.php @@ -5,8 +5,23 @@ */ namespace Magento\Setup\Module\Di\Code\Scanner; +use Magento\Framework\ObjectManager\InterceptableValidator; + class InheritanceInterceptorScanner implements ScannerInterface { + /** + * @var InterceptableValidator + */ + private $interceptableValidator; + + /** + * @param InterceptableValidator $interceptableValidator + */ + public function __construct(InterceptableValidator $interceptableValidator) + { + $this->interceptableValidator = $interceptableValidator; + } + /** * Get intercepted class names * @@ -20,9 +35,7 @@ public function collectEntities(array $classes, array $interceptedEntities = []) foreach ($classes as $class) { foreach ($interceptedEntities as $interceptorClass) { $interceptedEntity = substr($interceptorClass, 0, -12); - if (is_subclass_of($class, $interceptedEntity) - && !$this->endsWith($class, 'RepositoryInterface\\Proxy') - && !$this->endsWith($class, '\\Interceptor')) { + if (is_subclass_of($class, $interceptedEntity) && $this->interceptableValidator->validate($class)) { $reflectionClass = new \ReflectionClass($class); if (!$reflectionClass->isAbstract() && !$reflectionClass->isFinal()) { $output[] = $class . '\\Interceptor'; @@ -53,18 +66,4 @@ private function filterOutAbstractClasses($interceptedEntities) } return $interceptedEntitiesFiltered; } - - /** - * Check if a string ends with a substring - * - * @param string $haystack - * @param string $needle - * @return bool - */ - private function endsWith($haystack, $needle) - { - // search forward starting from end minus needle length characters - return $needle === "" - || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== false); - } } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Generator/InterceptionConfigurationBuilderTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Generator/InterceptionConfigurationBuilderTest.php index 928afe76a0685..1c41ccd774018 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Generator/InterceptionConfigurationBuilderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Generator/InterceptionConfigurationBuilderTest.php @@ -33,6 +33,11 @@ class InterceptionConfigurationBuilderTest extends \PHPUnit_Framework_TestCase */ private $cacheManager; + /** + * @var \Magento\Framework\ObjectManager\InterceptableValidator|\PHPUnit_Framework_MockObject_MockObject + */ + private $interceptableValidator; + protected function setUp() { $this->interceptionConfig = $this->getMock( @@ -56,13 +61,21 @@ protected function setUp() '', false ); + $this->interceptableValidator = $this->getMock( + 'Magento\Framework\ObjectManager\InterceptableValidator', + [], + [], + '', + false + ); $this->typeReader = $this->getMock('Magento\Setup\Module\Di\Code\Reader\Type', ['isConcrete'], [], '', false); $this->model = new \Magento\Setup\Module\Di\Code\Generator\InterceptionConfigurationBuilder( $this->interceptionConfig, $this->pluginList, $this->typeReader, - $this->cacheManager + $this->cacheManager, + $this->interceptableValidator ); } @@ -82,6 +95,11 @@ public function testGetInterceptionConfiguration($plugins) ['Class1', true], ['instance', true], ]); + $this->interceptableValidator->expects($this->any()) + ->method('validate') + ->with('Class1') + ->willReturn(true); + $this->cacheManager->expects($this->once()) ->method('setEnabled') ->with([CompiledConfig::TYPE_IDENTIFIER], true); From fa39bae590fa7f9c17eec5893fb30a5b4e446cc8 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Tue, 8 Dec 2015 16:48:53 -0600 Subject: [PATCH 4/5] MAGETWO-46665: Work around a random exception thrown by selenium web driver when openning swagger page. --- .../Swagger/Test/Page/SwaggerUiPage.php | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Swagger/Test/Page/SwaggerUiPage.php b/dev/tests/functional/tests/app/Magento/Swagger/Test/Page/SwaggerUiPage.php index f12cb68489f22..a1c13c2301f8c 100644 --- a/dev/tests/functional/tests/app/Magento/Swagger/Test/Page/SwaggerUiPage.php +++ b/dev/tests/functional/tests/app/Magento/Swagger/Test/Page/SwaggerUiPage.php @@ -60,7 +60,7 @@ public function __construct(BrowserInterface $browser) */ public function open() { - $this->browser->open($this->url); + $this->openSwaggerUrl(); $this->waitForPageToLoad(); } @@ -209,4 +209,29 @@ function () use ($browser, $selector, $strategy) { } ); } + + /** + * Wait to open swagger url + * + * This is to work around an issue with selenium web driver randomly returns browser url as "about:blank" + * when open swagger page + * + * @return bool|null + */ + private function openSwaggerUrl() + { + $browser = $this->browser; + $pattern = self::MCA;; + return $browser->waitUntil( + function () use ($browser, $pattern) { + try { + $url = $_ENV['app_frontend_url'] . $pattern; + $browser->open($url); + return true; + } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { + return false; + } + } + ); + } } From 5178c98112b1bb7a69d26f4eadf1bf4ff826978a Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Tue, 8 Dec 2015 16:48:53 -0600 Subject: [PATCH 5/5] MAGETWO-46665: Work around a random exception thrown by selenium web driver when openning swagger page. --- .../Swagger/Test/Page/SwaggerUiPage.php | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Swagger/Test/Page/SwaggerUiPage.php b/dev/tests/functional/tests/app/Magento/Swagger/Test/Page/SwaggerUiPage.php index f12cb68489f22..7a760e4dd3240 100644 --- a/dev/tests/functional/tests/app/Magento/Swagger/Test/Page/SwaggerUiPage.php +++ b/dev/tests/functional/tests/app/Magento/Swagger/Test/Page/SwaggerUiPage.php @@ -60,7 +60,7 @@ public function __construct(BrowserInterface $browser) */ public function open() { - $this->browser->open($this->url); + $this->openSwaggerUrl(); $this->waitForPageToLoad(); } @@ -209,4 +209,29 @@ function () use ($browser, $selector, $strategy) { } ); } + + /** + * Wait to open swagger url + * + * This is to work around an issue with selenium web driver randomly returns browser url as "about:blank" + * when open swagger page + * + * @return bool|null + */ + private function openSwaggerUrl() + { + $browser = $this->browser; + $pattern = self::MCA; + return $browser->waitUntil( + function () use ($browser, $pattern) { + try { + $url = $_ENV['app_frontend_url'] . $pattern; + $browser->open($url); + return true; + } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { + return false; + } + } + ); + } }