From c82cbbdb53064d560082ef65b8296cc60b8cd87b Mon Sep 17 00:00:00 2001 From: Dave Macaulay Date: Fri, 8 Mar 2019 12:14:01 +0100 Subject: [PATCH 1/4] MC-14937: Complete Page Builder Analytics data collection - Add checks on analytics.xml for dependency test --- .../Magento/CatalogAnalytics/composer.json | 3 +- .../Magento/CustomerAnalytics/composer.json | 3 +- app/code/Magento/QuoteAnalytics/composer.json | 3 +- .../Magento/ReviewAnalytics/composer.json | 3 +- app/code/Magento/SalesAnalytics/composer.json | 3 +- .../Magento/WishlistAnalytics/composer.json | 3 +- .../Dependency/AnalyticsConfigRule.php | 43 +++++++++++++++++++ .../Magento/Test/Integrity/DependencyTest.php | 28 ++++++++++++ 8 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 dev/tests/static/framework/Magento/TestFramework/Dependency/AnalyticsConfigRule.php diff --git a/app/code/Magento/CatalogAnalytics/composer.json b/app/code/Magento/CatalogAnalytics/composer.json index 5c97261d483d8..805be8a17765f 100644 --- a/app/code/Magento/CatalogAnalytics/composer.json +++ b/app/code/Magento/CatalogAnalytics/composer.json @@ -4,7 +4,8 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/module-catalog": "*" + "magento/module-catalog": "*", + "magento/module-analytics": "*" }, "type": "magento2-module", "license": [ diff --git a/app/code/Magento/CustomerAnalytics/composer.json b/app/code/Magento/CustomerAnalytics/composer.json index 7dec4279ee280..3840c534b1964 100644 --- a/app/code/Magento/CustomerAnalytics/composer.json +++ b/app/code/Magento/CustomerAnalytics/composer.json @@ -4,7 +4,8 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/module-customer": "*" + "magento/module-customer": "*", + "magento/module-analytics": "*" }, "type": "magento2-module", "license": [ diff --git a/app/code/Magento/QuoteAnalytics/composer.json b/app/code/Magento/QuoteAnalytics/composer.json index 90dae1ec2adca..706bed674b4a9 100644 --- a/app/code/Magento/QuoteAnalytics/composer.json +++ b/app/code/Magento/QuoteAnalytics/composer.json @@ -4,7 +4,8 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/module-quote": "*" + "magento/module-quote": "*", + "magento/module-analytics": "*" }, "type": "magento2-module", "license": [ diff --git a/app/code/Magento/ReviewAnalytics/composer.json b/app/code/Magento/ReviewAnalytics/composer.json index 73f534451580c..a82d4328ca159 100644 --- a/app/code/Magento/ReviewAnalytics/composer.json +++ b/app/code/Magento/ReviewAnalytics/composer.json @@ -4,7 +4,8 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/module-review": "*" + "magento/module-review": "*", + "magento/module-analytics": "*" }, "type": "magento2-module", "license": [ diff --git a/app/code/Magento/SalesAnalytics/composer.json b/app/code/Magento/SalesAnalytics/composer.json index 64424c8f5bc61..b77dcd7e71c65 100644 --- a/app/code/Magento/SalesAnalytics/composer.json +++ b/app/code/Magento/SalesAnalytics/composer.json @@ -4,7 +4,8 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/module-sales": "*" + "magento/module-sales": "*", + "magento/module-analytics": "*" }, "type": "magento2-module", "license": [ diff --git a/app/code/Magento/WishlistAnalytics/composer.json b/app/code/Magento/WishlistAnalytics/composer.json index fc69afe2907ab..747f2a4baaaa9 100644 --- a/app/code/Magento/WishlistAnalytics/composer.json +++ b/app/code/Magento/WishlistAnalytics/composer.json @@ -4,7 +4,8 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/module-wishlist": "*" + "magento/module-wishlist": "*", + "magento/module-analytics": "*" }, "type": "magento2-module", "license": [ diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/AnalyticsConfigRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/AnalyticsConfigRule.php new file mode 100644 index 0000000000000..b1a6da5e43822 --- /dev/null +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/AnalyticsConfigRule.php @@ -0,0 +1,43 @@ +]*class=[\'"]([^\'"]+)[\'"]#i', $contents, $matches)) { + $classes = array_pop($matches); + foreach ($classes as $class) { + $classParts = explode('\\', $class); + $module = implode('\\', array_slice($classParts, 0, 2)); + if (strtolower($currentModule) !== strtolower($module)) { + $dependenciesInfo[] = [ + 'module' => $module, + 'type' => RuleInterface::TYPE_HARD, + 'source' => $file, + ]; + } + } + } + + return $dependenciesInfo; + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php index a4113abed8030..e2e0357a38f77 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php @@ -16,6 +16,7 @@ use Magento\TestFramework\Dependency\LayoutRule; use Magento\TestFramework\Dependency\PhpRule; use Magento\TestFramework\Dependency\ReportsConfigRule; +use Magento\TestFramework\Dependency\AnalyticsConfigRule; use Magento\TestFramework\Dependency\VirtualType\VirtualTypeMapper; /** @@ -78,6 +79,17 @@ class DependencyTest extends \PHPUnit\Framework\TestCase */ protected static $_listRoutesXml = []; + /** + * List of analytics.xml + * + * Format: array( + * '{Module_Name}' => '{Filename}' + * ) + * + * @var array + */ + protected static $_listAnalyticsXml = []; + /** * List of routers * @@ -176,6 +188,7 @@ public static function setUpBeforeClass() self::_prepareListConfigXml(); self::_prepareListDbSchemaXml(); self::_prepareListRoutesXml(); + self::_prepareListAnalyticsXml(); self::_prepareMapRouters(); self::_prepareMapLayoutBlocks(); @@ -240,6 +253,7 @@ protected static function _initRules() ), new DiRule(new VirtualTypeMapper()), new ReportsConfigRule($dbRuleTables), + new AnalyticsConfigRule(), ]; } @@ -571,6 +585,20 @@ protected static function _prepareListRoutesXml() } } + /** + * Prepare list of analytics.xml files + */ + protected static function _prepareListAnalyticsXml() + { + $files = Files::init()->getDbSchemaFiles('analytics.xml', [], false); + foreach ($files as $file) { + if (preg_match('/(?[A-Z][a-z]+)[_\/\\\\](?[A-Z][a-zA-Z]+)/', $file, $matches)) { + $module = $matches['namespace'] . '\\' . $matches['module']; + self::$_listAnalyticsXml[$module] = $file; + } + } + } + /** * Prepare map of routers */ From 7409f92b62113b81e5713877a518bf50fb70cb85 Mon Sep 17 00:00:00 2001 From: Dave Macaulay Date: Fri, 8 Mar 2019 12:51:01 +0100 Subject: [PATCH 2/4] MC-14937: Complete Page Builder Analytics data collection - Move gift message di.xml entries into root di.xml --- app/code/Magento/GiftMessage/etc/di.xml | 7 +++++++ app/code/Magento/GiftMessage/etc/frontend/di.xml | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/GiftMessage/etc/di.xml b/app/code/Magento/GiftMessage/etc/di.xml index 1d03849d978b8..af42eff5d934c 100644 --- a/app/code/Magento/GiftMessage/etc/di.xml +++ b/app/code/Magento/GiftMessage/etc/di.xml @@ -13,6 +13,13 @@ + + + + Magento\GiftMessage\Model\GiftMessageConfigProvider + + + diff --git a/app/code/Magento/GiftMessage/etc/frontend/di.xml b/app/code/Magento/GiftMessage/etc/frontend/di.xml index a4837e0180c0b..3680a7b521217 100644 --- a/app/code/Magento/GiftMessage/etc/frontend/di.xml +++ b/app/code/Magento/GiftMessage/etc/frontend/di.xml @@ -29,13 +29,6 @@ - - - - Magento\GiftMessage\Model\GiftMessageConfigProvider - - - From 4488e63648ba75b3f47e34eda5e0ca6191289534 Mon Sep 17 00:00:00 2001 From: Dave Macaulay Date: Fri, 8 Mar 2019 13:27:23 +0100 Subject: [PATCH 3/4] MC-14937: Complete Page Builder Analytics data collection - Revert gift message changes --- app/code/Magento/GiftMessage/etc/di.xml | 7 ------- app/code/Magento/GiftMessage/etc/frontend/di.xml | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/GiftMessage/etc/di.xml b/app/code/Magento/GiftMessage/etc/di.xml index af42eff5d934c..1d03849d978b8 100644 --- a/app/code/Magento/GiftMessage/etc/di.xml +++ b/app/code/Magento/GiftMessage/etc/di.xml @@ -13,13 +13,6 @@ - - - - Magento\GiftMessage\Model\GiftMessageConfigProvider - - - diff --git a/app/code/Magento/GiftMessage/etc/frontend/di.xml b/app/code/Magento/GiftMessage/etc/frontend/di.xml index 3680a7b521217..a4837e0180c0b 100644 --- a/app/code/Magento/GiftMessage/etc/frontend/di.xml +++ b/app/code/Magento/GiftMessage/etc/frontend/di.xml @@ -29,6 +29,13 @@ + + + + Magento\GiftMessage\Model\GiftMessageConfigProvider + + + From 976803b0618c9983f51d28c789e046c07718dd25 Mon Sep 17 00:00:00 2001 From: Dave Macaulay Date: Fri, 8 Mar 2019 16:34:02 +0100 Subject: [PATCH 4/4] MC-14937: Complete Page Builder Analytics data collection - Add defaults to configProviders --- .../Magento/GiftMessage/Model/CompositeConfigProvider.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/GiftMessage/Model/CompositeConfigProvider.php b/app/code/Magento/GiftMessage/Model/CompositeConfigProvider.php index 0fdce9e9090ac..cb370c27863ca 100644 --- a/app/code/Magento/GiftMessage/Model/CompositeConfigProvider.php +++ b/app/code/Magento/GiftMessage/Model/CompositeConfigProvider.php @@ -7,6 +7,9 @@ use Magento\Checkout\Model\ConfigProviderInterface; +/** + * Class CompositeConfigProvider + */ class CompositeConfigProvider implements ConfigProviderInterface { /** @@ -18,13 +21,13 @@ class CompositeConfigProvider implements ConfigProviderInterface * @param ConfigProviderInterface[] $configProviders */ public function __construct( - array $configProviders + array $configProviders = [] ) { $this->configProviders = $configProviders; } /** - * {@inheritdoc} + * @inheritdoc */ public function getConfig() {