Skip to content

Commit

Permalink
Merge remote-tracking branch 'arcticfoxes/pr#3879' into 2.3-develop-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
Joan He committed Mar 15, 2019
2 parents 99e7237 + bd09670 commit f3b92fb
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/code/Magento/CatalogAnalytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/CustomerAnalytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

use Magento\Checkout\Model\ConfigProviderInterface;

/**
* Class CompositeConfigProvider
*/
class CompositeConfigProvider implements ConfigProviderInterface
{
/**
Expand All @@ -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()
{
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/QuoteAnalytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/ReviewAnalytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/SalesAnalytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/WishlistAnalytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\TestFramework\Dependency;

/**
* Class provides dependency rule for analytics.xml config file.
*/
class AnalyticsConfigRule implements RuleInterface
{
/**
* @inheritdoc
*/
public function getDependencyInfo($currentModule, $fileType, $file, &$contents)
{
if ('config' != $fileType || !preg_match('#.*/analytics\.xml$#', $file)) {
return [];
}

$dependenciesInfo = [];
if (preg_match_all('#<[customProvider|reportProvider][^>]*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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -176,6 +188,7 @@ public static function setUpBeforeClass()
self::_prepareListConfigXml();
self::_prepareListDbSchemaXml();
self::_prepareListRoutesXml();
self::_prepareListAnalyticsXml();

self::_prepareMapRouters();
self::_prepareMapLayoutBlocks();
Expand Down Expand Up @@ -240,6 +253,7 @@ protected static function _initRules()
),
new DiRule(new VirtualTypeMapper()),
new ReportsConfigRule($dbRuleTables),
new AnalyticsConfigRule(),
];
}

Expand Down Expand Up @@ -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('/(?<namespace>[A-Z][a-z]+)[_\/\\\\](?<module>[A-Z][a-zA-Z]+)/', $file, $matches)) {
$module = $matches['namespace'] . '\\' . $matches['module'];
self::$_listAnalyticsXml[$module] = $file;
}
}
}

/**
* Prepare map of routers
*/
Expand Down

0 comments on commit f3b92fb

Please sign in to comment.