',
+ $element->getHtmlId(),
+ $element->getLabelHtml($element->getHtmlId(), "[WEBSITE]"),
+ $element->getElementHtml()
+ );
+ return $rowHtml;
+ }
+}
diff --git a/app/code/Magento/Analytics/Controller/Adminhtml/Reports/Show.php b/app/code/Magento/Analytics/Controller/Adminhtml/Reports/Show.php
index 7f0aade798e18..1b0e5c92420de 100644
--- a/app/code/Magento/Analytics/Controller/Adminhtml/Reports/Show.php
+++ b/app/code/Magento/Analytics/Controller/Adminhtml/Reports/Show.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Analytics\Controller\Adminhtml\Reports;
+use Magento\Analytics\Model\Exception\State\SubscriptionUpdateException;
use Magento\Analytics\Model\ReportUrlProvider;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
@@ -55,6 +56,9 @@ public function execute()
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
try {
$resultRedirect->setUrl($this->reportUrlProvider->getUrl());
+ } catch (SubscriptionUpdateException $e) {
+ $this->getMessageManager()->addNoticeMessage($e->getMessage());
+ $resultRedirect->setPath('adminhtml');
} catch (LocalizedException $e) {
$this->getMessageManager()->addExceptionMessage($e, $e->getMessage());
$resultRedirect->setPath('adminhtml');
diff --git a/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Activate.php b/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Activate.php
deleted file mode 100644
index b5731fc07bb07..0000000000000
--- a/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Activate.php
+++ /dev/null
@@ -1,133 +0,0 @@
-logger = $logger;
- $this->notificationTime = $notificationTime;
- $this->configValueResource = $configValueResource;
- $this->preparedValueFactory = $preparedValueFactory;
- parent::__construct($context);
- }
-
- /**
- * Check admin permissions for this controller
- *
- * @return boolean
- */
- protected function _isAllowed()
- {
- return $this->_authorization->isAllowed('Magento_Analytics::analytics_settings');
- }
-
- /**
- * Activate subscription to Magento BI via AJAX.
- *
- * @return Json
- */
- public function execute()
- {
- try {
- if ($this->getRequest()->getParam($this->subscriptionApprovedField)) {
- $configValue = $this->preparedValueFactory->create(
- Enabled::XML_ENABLED_CONFIG_STRUCTURE_PATH,
- Enabledisable::ENABLE_VALUE,
- ScopeConfigInterface::SCOPE_TYPE_DEFAULT
- );
-
- $this->configValueResource
- ->save($configValue);
- } else {
- $this->notificationTime->unsetLastTimeNotificationValue();
- }
- $responseContent = [
- 'success' => true,
- 'error_message' => '',
- ];
- } catch (LocalizedException $e) {
- $responseContent = [
- 'success' => false,
- 'error_message' => $e->getMessage(),
- ];
- $this->logger->error($e->getMessage());
- } catch (\Exception $e) {
- $responseContent = [
- 'success' => false,
- 'error_message' => __(
- 'Sorry, there was an error processing your registration request to Magento Analytics. '
- . 'Please try again later.'
- ),
- ];
- $this->logger->error($e->getMessage());
- }
- /** @var Json $resultJson */
- $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
- return $resultJson->setData($responseContent);
- }
-}
diff --git a/app/code/Magento/Analytics/Cron/Update.php b/app/code/Magento/Analytics/Cron/Update.php
index 36e6c3e59e5c7..9062a7bac7551 100644
--- a/app/code/Magento/Analytics/Cron/Update.php
+++ b/app/code/Magento/Analytics/Cron/Update.php
@@ -5,14 +5,14 @@
*/
namespace Magento\Analytics\Cron;
+use Magento\Analytics\Model\AnalyticsToken;
+use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Connector;
-use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
/**
- * Class Update
* Executes by cron schedule in case base url was changed
*/
class Update
@@ -28,8 +28,6 @@ class Update
private $configWriter;
/**
- * Reinitable Config Model.
- *
* @var ReinitableConfigInterface
*/
private $reinitableConfig;
@@ -40,22 +38,29 @@ class Update
private $flagManager;
/**
- * Update constructor.
+ * @var AnalyticsToken
+ */
+ private $analyticsToken;
+
+ /**
* @param Connector $connector
* @param WriterInterface $configWriter
* @param ReinitableConfigInterface $reinitableConfig
* @param FlagManager $flagManager
+ * @param AnalyticsToken $analyticsToken
*/
public function __construct(
Connector $connector,
WriterInterface $configWriter,
ReinitableConfigInterface $reinitableConfig,
- FlagManager $flagManager
+ FlagManager $flagManager,
+ AnalyticsToken $analyticsToken
) {
$this->connector = $connector;
$this->configWriter = $configWriter;
$this->reinitableConfig = $reinitableConfig;
$this->flagManager = $flagManager;
+ $this->analyticsToken = $analyticsToken;
}
/**
@@ -65,13 +70,23 @@ public function __construct(
*/
public function execute()
{
- $updateResult = $this->connector->execute('update');
- if ($updateResult === false) {
- return false;
+ $result = false;
+ $attemptsCount = $this->flagManager
+ ->getFlagData(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
+
+ if ($attemptsCount) {
+ $attemptsCount -= 1;
+ $result = $this->connector->execute('update');
+ }
+
+ if ($result || ($attemptsCount <= 0) || (!$this->analyticsToken->isTokenExist())) {
+ $this->flagManager
+ ->deleteFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
+ $this->flagManager->deleteFlag(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE);
+ $this->configWriter->delete(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH);
+ $this->reinitableConfig->reinit();
}
- $this->configWriter->delete(BaseUrlConfigPlugin::UPDATE_CRON_STRING_PATH);
- $this->flagManager->deleteFlag(BaseUrlConfigPlugin::OLD_BASE_URL_FLAG_CODE);
- $this->reinitableConfig->reinit();
- return true;
+
+ return $result;
}
}
diff --git a/app/code/Magento/Analytics/Model/Condition/CanViewNotification.php b/app/code/Magento/Analytics/Model/Condition/CanViewNotification.php
deleted file mode 100644
index bffe746fe7383..0000000000000
--- a/app/code/Magento/Analytics/Model/Condition/CanViewNotification.php
+++ /dev/null
@@ -1,80 +0,0 @@
-notificationTime = $notificationTime;
- $this->dateTimeFactory = $dateTimeFactory;
- }
-
- /**
- * Validate is notification popup can be shown
- *
- * @inheritdoc
- */
- public function isVisible(array $arguments)
- {
- $lastNotificationTime = $this->notificationTime->getLastTimeNotification();
- if (!$lastNotificationTime) {
- return false;
- }
- $datetime = $this->dateTimeFactory->create();
- return (
- $datetime->getTimestamp() >= $lastNotificationTime + $this->notificationInterval
- );
- }
-
- /**
- * @return string
- */
- public function getName()
- {
- return self::NAME;
- }
-}
diff --git a/app/code/Magento/Analytics/Model/Config/Backend/Baseurl/SubscriptionUpdateHandler.php b/app/code/Magento/Analytics/Model/Config/Backend/Baseurl/SubscriptionUpdateHandler.php
new file mode 100644
index 0000000000000..6e6f008d49f7e
--- /dev/null
+++ b/app/code/Magento/Analytics/Model/Config/Backend/Baseurl/SubscriptionUpdateHandler.php
@@ -0,0 +1,107 @@
+analyticsToken = $analyticsToken;
+ $this->flagManager = $flagManager;
+ $this->reinitableConfig = $reinitableConfig;
+ $this->configWriter = $configWriter;
+ }
+
+ /**
+ * Activate process of subscription update handling.
+ *
+ * @param string $url
+ * @return bool
+ */
+ public function processUrlUpdate(string $url)
+ {
+ if ($this->analyticsToken->isTokenExist()) {
+ if (!$this->flagManager->getFlagData(self::PREVIOUS_BASE_URL_FLAG_CODE)) {
+ $this->flagManager->saveFlag(self::PREVIOUS_BASE_URL_FLAG_CODE, $url);
+ }
+
+ $this->flagManager
+ ->saveFlag(self::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue);
+ $this->configWriter->save(self::UPDATE_CRON_STRING_PATH, $this->cronExpression);
+ $this->reinitableConfig->reinit();
+ }
+
+ return true;
+ }
+}
diff --git a/app/code/Magento/Analytics/Model/Config/Backend/Enabled/SubscriptionHandler.php b/app/code/Magento/Analytics/Model/Config/Backend/Enabled/SubscriptionHandler.php
index d23f5a7c60d91..4b125949948c6 100644
--- a/app/code/Magento/Analytics/Model/Config/Backend/Enabled/SubscriptionHandler.php
+++ b/app/code/Magento/Analytics/Model/Config/Backend/Enabled/SubscriptionHandler.php
@@ -7,7 +7,6 @@
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\CollectionTime;
-use Magento\Analytics\Model\NotificationTime;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;
@@ -27,6 +26,17 @@ class SubscriptionHandler
*/
const CRON_STRING_PATH = 'crontab/default/jobs/analytics_subscribe/schedule/cron_expr';
+ /**
+ * Config value for schedule setting of subscription handler.
+ */
+ const CRON_EXPR_ARRAY = [
+ '0', # Minute
+ '*', # Hour
+ '*', # Day of the Month
+ '*', # Month of the Year
+ '*', # Day of the Week
+ ];
+
/**
* Max value for reserve counter of attempts to subscribe.
*
@@ -55,13 +65,6 @@ class SubscriptionHandler
*/
private $analyticsToken;
- /**
- * Resource for managing last notification time about subscription to Magento Analytics.
- *
- * @var NotificationTime
- */
- private $notificationTime;
-
/**
* @var ReinitableConfigInterface
*/
@@ -71,20 +74,17 @@ class SubscriptionHandler
* @param WriterInterface $configWriter
* @param FlagManager $flagManager
* @param AnalyticsToken $analyticsToken
- * @param NotificationTime $notificationTime
* @param ReinitableConfigInterface $reinitableConfig
*/
public function __construct(
WriterInterface $configWriter,
FlagManager $flagManager,
AnalyticsToken $analyticsToken,
- NotificationTime $notificationTime,
ReinitableConfigInterface $reinitableConfig
) {
$this->configWriter = $configWriter;
$this->flagManager = $flagManager;
$this->analyticsToken = $analyticsToken;
- $this->notificationTime = $notificationTime;
$this->reinitableConfig = $reinitableConfig;
}
@@ -100,7 +100,6 @@ public function processEnabled()
if (!$this->analyticsToken->isTokenExist()) {
$this->setCronSchedule();
$this->setAttemptsFlag();
- $this->notificationTime->unsetLastTimeNotificationValue();
$this->reinitableConfig->reinit();
}
@@ -114,18 +113,7 @@ public function processEnabled()
*/
private function setCronSchedule()
{
- $cronExprArray = [
- '0', # Minute
- '*', # Hour
- '*', # Day of the Month
- '*', # Month of the Year
- '*', # Day of the Week
- ];
-
- $cronExprString = join(' ', $cronExprArray);
-
- $this->configWriter->save(self::CRON_STRING_PATH, $cronExprString);
-
+ $this->configWriter->save(self::CRON_STRING_PATH, join(' ', self::CRON_EXPR_ARRAY));
return true;
}
diff --git a/app/code/Magento/Analytics/Model/Config/Data.php b/app/code/Magento/Analytics/Model/Config/Data.php
deleted file mode 100644
index d732d0d6e7cea..0000000000000
--- a/app/code/Magento/Analytics/Model/Config/Data.php
+++ /dev/null
@@ -1,29 +0,0 @@
- 'name',
- ];
-
- /**
- * @param FileResolverInterface $fileResolver
- * @param ConverterInterface $converter
- * @param SchemaLocatorInterface $schemaLocator
- * @param ValidationStateInterface $validationState
- * @param string $fileName
- * @param array $idAttributes
- * @param string $domDocumentClass
- * @param string $defaultScope
- */
- public function __construct(
- FileResolverInterface $fileResolver,
- ConverterInterface $converter,
- SchemaLocatorInterface $schemaLocator,
- ValidationStateInterface $validationState,
- $fileName = 'analytics.xml',
- $idAttributes = [],
- $domDocumentClass = Dom::class,
- $defaultScope = 'global'
- ) {
- parent::__construct(
- $fileResolver,
- $converter,
- $schemaLocator,
- $validationState,
- $fileName,
- $idAttributes,
- $domDocumentClass,
- $defaultScope
- );
- }
-}
diff --git a/app/code/Magento/Analytics/Model/Config/SchemaLocator.php b/app/code/Magento/Analytics/Model/Config/SchemaLocator.php
deleted file mode 100644
index c427101349d45..0000000000000
--- a/app/code/Magento/Analytics/Model/Config/SchemaLocator.php
+++ /dev/null
@@ -1,56 +0,0 @@
-urnResolver = $urnResolver;
- }
-
- /**
- * Get path to merged config schema.
- *
- * @return string|null
- */
- public function getSchema()
- {
- return $this->urnResolver->getRealPath($this->schema);
- }
-
- /**
- * Get path to pre file validation schema.
- *
- * @return string|null
- */
- public function getPerFileSchema()
- {
- return null;
- }
-}
diff --git a/app/code/Magento/Analytics/Model/Connector/NotifyDataChangedCommand.php b/app/code/Magento/Analytics/Model/Connector/NotifyDataChangedCommand.php
index 177ee64c82c5b..f1a8ea6460f9d 100644
--- a/app/code/Magento/Analytics/Model/Connector/NotifyDataChangedCommand.php
+++ b/app/code/Magento/Analytics/Model/Connector/NotifyDataChangedCommand.php
@@ -6,8 +6,8 @@
namespace Magento\Analytics\Model\Connector;
use Magento\Analytics\Model\AnalyticsToken;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\HTTP\ZendClient;
-use Magento\Config\Model\Config;
use Psr\Log\LoggerInterface;
use Magento\Store\Model\Store;
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
@@ -33,7 +33,7 @@ class NotifyDataChangedCommand implements CommandInterface
private $httpClient;
/**
- * @var Config
+ * @var ScopeConfigInterface
*/
private $config;
@@ -51,14 +51,14 @@ class NotifyDataChangedCommand implements CommandInterface
* NotifyDataChangedCommand constructor.
* @param AnalyticsToken $analyticsToken
* @param Http\ClientInterface $httpClient
- * @param Config $config
+ * @param ScopeConfigInterface $config
* @param ResponseResolver $responseResolver
* @param LoggerInterface $logger
*/
public function __construct(
AnalyticsToken $analyticsToken,
Http\ClientInterface $httpClient,
- Config $config,
+ ScopeConfigInterface $config,
ResponseResolver $responseResolver,
LoggerInterface $logger
) {
@@ -80,16 +80,14 @@ public function execute()
if ($this->analyticsToken->isTokenExist()) {
$response = $this->httpClient->request(
ZendClient::POST,
- $this->config->getConfigDataValue($this->notifyDataChangedUrlPath),
+ $this->config->getValue($this->notifyDataChangedUrlPath),
[
"access-token" => $this->analyticsToken->getToken(),
- "url" => $this->config->getConfigDataValue(
- Store::XML_PATH_SECURE_BASE_URL
- ),
+ "url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL),
]
);
$result = $this->responseResolver->getResult($response);
}
- return $result;
+ return (bool)$result;
}
}
diff --git a/app/code/Magento/Analytics/Model/Connector/SignUpCommand.php b/app/code/Magento/Analytics/Model/Connector/SignUpCommand.php
index 367b46de17c4b..a1f23637e04b1 100644
--- a/app/code/Magento/Analytics/Model/Connector/SignUpCommand.php
+++ b/app/code/Magento/Analytics/Model/Connector/SignUpCommand.php
@@ -8,7 +8,7 @@
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
use Magento\Analytics\Model\IntegrationManager;
-use Magento\Config\Model\Config;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Psr\Log\LoggerInterface;
use Magento\Framework\HTTP\ZendClient;
use Magento\Store\Model\Store;
@@ -36,7 +36,7 @@ class SignUpCommand implements CommandInterface
private $integrationManager;
/**
- * @var Config
+ * @var ScopeConfigInterface
*/
private $config;
@@ -60,7 +60,7 @@ class SignUpCommand implements CommandInterface
*
* @param AnalyticsToken $analyticsToken
* @param IntegrationManager $integrationManager
- * @param Config $config
+ * @param ScopeConfigInterface $config
* @param Http\ClientInterface $httpClient
* @param LoggerInterface $logger
* @param ResponseResolver $responseResolver
@@ -68,7 +68,7 @@ class SignUpCommand implements CommandInterface
public function __construct(
AnalyticsToken $analyticsToken,
IntegrationManager $integrationManager,
- Config $config,
+ ScopeConfigInterface $config,
Http\ClientInterface $httpClient,
LoggerInterface $logger,
ResponseResolver $responseResolver
@@ -101,12 +101,10 @@ public function execute()
$this->integrationManager->activateIntegration();
$response = $this->httpClient->request(
ZendClient::POST,
- $this->config->getConfigDataValue($this->signUpUrlPath),
+ $this->config->getValue($this->signUpUrlPath),
[
"token" => $integrationToken->getData('token'),
- "url" => $this->config->getConfigDataValue(
- Store::XML_PATH_SECURE_BASE_URL
- )
+ "url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL),
]
);
@@ -121,6 +119,6 @@ public function execute()
}
}
- return $result;
+ return (bool)$result;
}
}
diff --git a/app/code/Magento/Analytics/Model/Connector/UpdateCommand.php b/app/code/Magento/Analytics/Model/Connector/UpdateCommand.php
index a2d64a98e0409..8f05f1107e87e 100644
--- a/app/code/Magento/Analytics/Model/Connector/UpdateCommand.php
+++ b/app/code/Magento/Analytics/Model/Connector/UpdateCommand.php
@@ -6,9 +6,9 @@
namespace Magento\Analytics\Model\Connector;
use Magento\Analytics\Model\AnalyticsToken;
+use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
-use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
-use Magento\Config\Model\Config;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\FlagManager;
use Magento\Framework\HTTP\ZendClient;
use Magento\Store\Model\Store;
@@ -36,7 +36,7 @@ class UpdateCommand implements CommandInterface
private $httpClient;
/**
- * @var Config
+ * @var ScopeConfigInterface
*/
private $config;
@@ -58,7 +58,7 @@ class UpdateCommand implements CommandInterface
/**
* @param AnalyticsToken $analyticsToken
* @param Http\ClientInterface $httpClient
- * @param Config $config
+ * @param ScopeConfigInterface $config
* @param LoggerInterface $logger
* @param FlagManager $flagManager
* @param ResponseResolver $responseResolver
@@ -66,7 +66,7 @@ class UpdateCommand implements CommandInterface
public function __construct(
AnalyticsToken $analyticsToken,
Http\ClientInterface $httpClient,
- Config $config,
+ ScopeConfigInterface $config,
LoggerInterface $logger,
FlagManager $flagManager,
ResponseResolver $responseResolver
@@ -90,12 +90,11 @@ public function execute()
if ($this->analyticsToken->isTokenExist()) {
$response = $this->httpClient->request(
ZendClient::PUT,
- $this->config->getConfigDataValue($this->updateUrlPath),
+ $this->config->getValue($this->updateUrlPath),
[
- "url" => $this->flagManager->getFlagData(BaseUrlConfigPlugin::OLD_BASE_URL_FLAG_CODE),
- "new-url" => $this->config->getConfigDataValue(
- Store::XML_PATH_SECURE_BASE_URL
- ),
+ "url" => $this->flagManager
+ ->getFlagData(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE),
+ "new-url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL),
"access-token" => $this->analyticsToken->getToken(),
]
);
@@ -110,6 +109,6 @@ public function execute()
}
}
- return $result;
+ return (bool)$result;
}
}
diff --git a/app/code/Magento/Analytics/Model/Exception/State/SubscriptionUpdateException.php b/app/code/Magento/Analytics/Model/Exception/State/SubscriptionUpdateException.php
new file mode 100644
index 0000000000000..5d127037afea9
--- /dev/null
+++ b/app/code/Magento/Analytics/Model/Exception/State/SubscriptionUpdateException.php
@@ -0,0 +1,17 @@
+flagManager = $flagManager;
- }
-
- /**
- * Stores last notification time
- *
- * @param string $value
- * @return bool
- */
- public function storeLastTimeNotification($value)
- {
- return $this->flagManager->saveFlag(self::NOTIFICATION_TIME, $value);
- }
-
- /**
- * Returns last time when merchant was notified about Analytic services
- *
- * @return int
- */
- public function getLastTimeNotification()
- {
- return $this->flagManager->getFlagData(self::NOTIFICATION_TIME);
- }
-
- /**
- * Remove last notification time flag.
- *
- * @return bool
- */
- public function unsetLastTimeNotificationValue()
- {
- return $this->flagManager->deleteFlag(self::NOTIFICATION_TIME);
- }
-}
diff --git a/app/code/Magento/Analytics/Model/Plugin/BaseUrlConfigPlugin.php b/app/code/Magento/Analytics/Model/Plugin/BaseUrlConfigPlugin.php
index 705c627798aa9..174272614fb19 100644
--- a/app/code/Magento/Analytics/Model/Plugin/BaseUrlConfigPlugin.php
+++ b/app/code/Magento/Analytics/Model/Plugin/BaseUrlConfigPlugin.php
@@ -5,97 +5,57 @@
*/
namespace Magento\Analytics\Model\Plugin;
-use Magento\Analytics\Model\SubscriptionStatusProvider;
-use Magento\Framework\FlagManager;
-use Magento\Framework\App\Config\Storage\WriterInterface;
+use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Config\Value;
+use Magento\Store\Model\Store;
/**
- * Class BaseUrlConfigPlugin
- *
- * Plugin checks if value changed than save old base url and call subscription update.
+ * Plugin on Base URL config value AfterSave method.
*/
class BaseUrlConfigPlugin
{
/**
- * @var FlagManager
+ * @var SubscriptionUpdateHandler
*/
- private $flagManager;
+ private $subscriptionUpdateHandler;
/**
- * @var SubscriptionStatusProvider
- */
- private $subscriptionStatusProvider;
-
- /**
- * @var WriterInterface
- */
- private $configWriter;
-
- /**
- * Cron expression by next pattern:
- * # Minute # Hour # Day of the Month # Month of the Year # Day of the Week.
- *
- * @var string
- */
- private $cronExpression = '0 * * * *';
-
- /**
- * Config path for schedule setting of subscription handler.
- */
- const UPDATE_CRON_STRING_PATH = "crontab/default/jobs/analytics_update/schedule/cron_expr";
-
- /**
- * Represents a flag code for analytics old base url.
- */
- const OLD_BASE_URL_FLAG_CODE = 'analytics_old_base_url';
-
- /**
- * @param FlagManager $flagManager
- * @param SubscriptionStatusProvider $subscriptionStatusProvider
- * @param WriterInterface $configWriter
+ * @param SubscriptionUpdateHandler $subscriptionUpdateHandler
*/
public function __construct(
- FlagManager $flagManager,
- SubscriptionStatusProvider $subscriptionStatusProvider,
- WriterInterface $configWriter
+ SubscriptionUpdateHandler $subscriptionUpdateHandler
) {
- $this->flagManager = $flagManager;
- $this->subscriptionStatusProvider = $subscriptionStatusProvider;
- $this->configWriter = $configWriter;
+ $this->subscriptionUpdateHandler = $subscriptionUpdateHandler;
}
/**
- * Sets update analytics cron job if base url was changed.
+ * Add additional handling after config value was saved.
*
- * @param \Magento\Config\Model\Config\Backend\Baseurl $subject
- * @param \Magento\Config\Model\Config\Backend\Baseurl $result
- * @return \Magento\Config\Model\Config\Backend\Baseurl
+ * @param Value $subject
+ * @param Value $result
+ * @return Value
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterAfterSave(
- \Magento\Config\Model\Config\Backend\Baseurl $subject,
- \Magento\Config\Model\Config\Backend\Baseurl $result
+ Value $subject,
+ Value $result
) {
- if (!$result->isValueChanged()) {
- return $result;
- }
-
if ($this->isPluginApplicable($result)) {
- $this->flagManager->saveFlag(static::OLD_BASE_URL_FLAG_CODE, $result->getOldValue());
- $this->configWriter->save(self::UPDATE_CRON_STRING_PATH, $this->cronExpression);
+ $this->subscriptionUpdateHandler->processUrlUpdate($result->getOldValue());
}
return $result;
}
/**
- * @param \Magento\Config\Model\Config\Backend\Baseurl $result
- *
+ * @param Value $result
* @return bool
*/
- private function isPluginApplicable(\Magento\Config\Model\Config\Backend\Baseurl $result)
+ private function isPluginApplicable(Value $result)
{
- return $result->getData('path') === \Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL
- && $this->subscriptionStatusProvider->getStatus() === SubscriptionStatusProvider::ENABLED;
+ return $result->isValueChanged()
+ && ($result->getPath() === Store::XML_PATH_SECURE_BASE_URL)
+ && ($result->getScope() === ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
}
}
diff --git a/app/code/Magento/Analytics/Model/ReportUrlProvider.php b/app/code/Magento/Analytics/Model/ReportUrlProvider.php
index b72374f4d9f62..e7fdf6f9e8132 100644
--- a/app/code/Magento/Analytics/Model/ReportUrlProvider.php
+++ b/app/code/Magento/Analytics/Model/ReportUrlProvider.php
@@ -5,8 +5,11 @@
*/
namespace Magento\Analytics\Model;
+use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Connector\OTPRequest;
+use Magento\Analytics\Model\Exception\State\SubscriptionUpdateException;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\FlagManager;
/**
* Provide URL on resource with reports.
@@ -32,6 +35,11 @@ class ReportUrlProvider
*/
private $config;
+ /**
+ * @var FlagManager
+ */
+ private $flagManager;
+
/**
* Path to config value with URL which provide reports.
*
@@ -43,24 +51,35 @@ class ReportUrlProvider
* @param AnalyticsToken $analyticsToken
* @param OTPRequest $otpRequest
* @param ScopeConfigInterface $config
+ * @param FlagManager $flagManager
*/
public function __construct(
AnalyticsToken $analyticsToken,
OTPRequest $otpRequest,
- ScopeConfigInterface $config
+ ScopeConfigInterface $config,
+ FlagManager $flagManager
) {
$this->analyticsToken = $analyticsToken;
$this->otpRequest = $otpRequest;
$this->config = $config;
+ $this->flagManager = $flagManager;
}
/**
* Provide URL on resource with reports.
*
* @return string
+ * @throws SubscriptionUpdateException
*/
public function getUrl()
{
+ if ($this->flagManager->getFlagData(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)) {
+ throw new SubscriptionUpdateException(__(
+ 'Your Base URL has been changed and your reports are being updated. '
+ . 'Advanced Reporting will be available once this change has been processed. Please try again later.'
+ ));
+ }
+
$url = $this->config->getValue($this->urlReportConfigPath);
if ($this->analyticsToken->isTokenExist()) {
$otp = $this->otpRequest->call();
diff --git a/app/code/Magento/Analytics/Model/SubscriptionStatusProvider.php b/app/code/Magento/Analytics/Model/SubscriptionStatusProvider.php
index 8fe548013c206..1dd831a672faa 100644
--- a/app/code/Magento/Analytics/Model/SubscriptionStatusProvider.php
+++ b/app/code/Magento/Analytics/Model/SubscriptionStatusProvider.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Analytics\Model;
+use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\FlagManager;
@@ -93,6 +94,10 @@ public function getStatus()
public function getStatusForEnabledSubscription()
{
$status = static::ENABLED;
+ if ($this->flagManager->getFlagData(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)) {
+ $status = self::PENDING;
+ }
+
if (!$this->analyticsToken->isTokenExist()) {
$status = static::PENDING;
if ($this->flagManager->getFlagData(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE) === null) {
diff --git a/app/code/Magento/Analytics/README.md b/app/code/Magento/Analytics/README.md
index cb8fdc3287190..7ec64abcd9b86 100644
--- a/app/code/Magento/Analytics/README.md
+++ b/app/code/Magento/Analytics/README.md
@@ -1,12 +1,41 @@
-## Overview
+# Magento_Analytics Module
-The Magento_Analytics module provides integration with
-[Magento Business Intelligence](https://magento.com/products/business-intelligence). Admin user can subscribe to
-Advanced Analytics, navigate to Advanced Analytics reports and Magento Business Intelligence subscription page.
+The Magento_Analytics module integrates your Magento instance with the [Magento Business Intelligence (MBI)](https://magento.com/products/business-intelligence) to use [Advanced Reporting](http://devdocs.magento.com/guides/v2.2/advanced-reporting/modules.html) functionality.
-The Magento_Analytics module adds:
+The module implements the following functionality:
-- Advanced Analytics subscription pop-up
-- backend menu link to Magento Business Intelligence subscription page under Reports menu
-- Magento Analytics configuration page in Stores-Configuration->General menu
-- configuration to build a data collection for BI system
\ No newline at end of file
+* enabling subscription to the MBI and automatic re-subscription
+* changing the base URL with the same MBI account remained
+* declaring the configuration schemas for report data collection
+* collecting the Magento instance data as reports for the MBI
+* introducing API that provides the collected data
+* extending Magento configuration with the module parameters:
+ * subscription status (enabled/disabled)
+ * industry (a business area in which the instance website works)
+ * time of data collection (time of the day when the module collects data)
+
+## Structure
+
+Beyond the [usual module file structure](http://devdocs.magento.com/guides/v2.2/architecture/archi_perspectives/components/modules/mod_intro.html) the module contains a directory `ReportXml`.
+[Report XML](http://devdocs.magento.com/guides/v2.2/advanced-reporting/report-xml.html) is a markup language used to build reports for Advanced Reporting.
+The language declares SQL queries using XML declaration.
+
+## Subscription Process
+
+The subscription to the MBI service is enabled during the installation process of the Analytics module. Each administrator will be notified of these new features upon their initial login to the Admin Panel.
+
+## Analytics Settings
+
+Configuration settings for the Analytics module can be modified in the Admin Panel on the Stores > Configuration page under the General > Advanced Reporting tab.
+
+The following options can be adjusted:
+* Advanced Reporting Service (Enabled/Disabled)
+ * Alters the status of the Advanced Reporting subscription
+* Time of day to send data (Hour/Minute/Second in the store's time zone)
+ * Defines when the data collection process for the Advanced Reporting service occurs
+* Industry
+ * Defines the industry of the store in order to create a personalized Advanced Reporting experience
+
+## Extensibility
+
+We do not recommend to extend the Magento_Analytics module. It introduces an API that is purposed to transfer the collected data. Note that the API cannot be used for other needs.
diff --git a/app/code/Magento/Analytics/ReportXml/Config.php b/app/code/Magento/Analytics/ReportXml/Config.php
index d2d0a87ca6e9e..f50dcf941bf50 100644
--- a/app/code/Magento/Analytics/ReportXml/Config.php
+++ b/app/code/Magento/Analytics/ReportXml/Config.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Analytics\ReportXml;
-use Magento\Analytics\ReportXml\Config\Data;
+use Magento\Framework\Config\DataInterface;
/**
* Class Config
@@ -15,17 +15,17 @@
class Config implements ConfigInterface
{
/**
- * @var Data
+ * @var DataInterface
*/
private $data;
/**
* Config constructor.
*
- * @param Data $data
+ * @param DataInterface $data
*/
public function __construct(
- Data $data
+ DataInterface $data
) {
$this->data = $data;
}
diff --git a/app/code/Magento/Analytics/ReportXml/Config/Data.php b/app/code/Magento/Analytics/ReportXml/Config/Data.php
deleted file mode 100644
index 3281093a2c07d..0000000000000
--- a/app/code/Magento/Analytics/ReportXml/Config/Data.php
+++ /dev/null
@@ -1,29 +0,0 @@
- 'name'
- ];
-
- /**
- * @param \Magento\Framework\Config\FileResolverInterface $fileResolver
- * @param \Magento\Analytics\ReportXml\Config\Converter\Xml $converter
- * @param \Magento\Analytics\ReportXml\Config\SchemaLocator $schemaLocator
- * @param \Magento\Framework\Config\ValidationStateInterface $validationState
- * @param string $fileName
- * @param array $idAttributes
- * @param string $domDocumentClass
- * @param string $defaultScope
- */
- public function __construct(
- \Magento\Framework\Config\FileResolverInterface $fileResolver,
- \Magento\Analytics\ReportXml\Config\Converter\Xml $converter,
- \Magento\Analytics\ReportXml\Config\SchemaLocator $schemaLocator,
- \Magento\Framework\Config\ValidationStateInterface $validationState,
- $fileName = 'reports.xml',
- $idAttributes = [],
- $domDocumentClass = \Magento\Framework\Config\Dom::class,
- $defaultScope = 'global'
- ) {
- parent::__construct(
- $fileResolver,
- $converter,
- $schemaLocator,
- $validationState,
- $fileName,
- $idAttributes,
- $domDocumentClass,
- $defaultScope
- );
- }
-}
diff --git a/app/code/Magento/Analytics/ReportXml/Config/SchemaLocator.php b/app/code/Magento/Analytics/ReportXml/Config/SchemaLocator.php
deleted file mode 100644
index 57c0ac6e1a9e9..0000000000000
--- a/app/code/Magento/Analytics/ReportXml/Config/SchemaLocator.php
+++ /dev/null
@@ -1,51 +0,0 @@
-urnResolver = $urnResolver;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getSchema()
- {
- return $this->urnResolver->getRealPath($this->realPath);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getPerFileSchema()
- {
- return null;
- }
-}
diff --git a/app/code/Magento/Analytics/ReportXml/DB/ColumnsResolver.php b/app/code/Magento/Analytics/ReportXml/DB/ColumnsResolver.php
index e9953a3a2452f..e6474d4c5dc6d 100644
--- a/app/code/Magento/Analytics/ReportXml/DB/ColumnsResolver.php
+++ b/app/code/Magento/Analytics/ReportXml/DB/ColumnsResolver.php
@@ -6,6 +6,7 @@
namespace Magento\Analytics\ReportXml\DB;
+use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Sql\ColumnValueExpression;
/**
@@ -20,14 +21,41 @@ class ColumnsResolver
*/
private $nameResolver;
+ /**
+ * @var ResourceConnection
+ */
+ private $resourceConnection;
+
+ /**
+ * @var \Magento\Framework\DB\Adapter\AdapterInterface
+ */
+ private $connection;
+
/**
* ColumnsResolver constructor.
+ *
* @param NameResolver $nameResolver
+ * @param ResourceConnection $resourceConnection
*/
public function __construct(
- NameResolver $nameResolver
+ NameResolver $nameResolver,
+ ResourceConnection $resourceConnection
) {
$this->nameResolver = $nameResolver;
+ $this->resourceConnection = $resourceConnection;
+ }
+
+ /**
+ * Returns connection
+ *
+ * @return \Magento\Framework\DB\Adapter\AdapterInterface
+ */
+ private function getConnection()
+ {
+ if (!$this->connection) {
+ $this->connection = $this->resourceConnection->getConnection();
+ }
+ return $this->connection;
}
/**
@@ -54,7 +82,9 @@ public function getColumns(SelectBuilder $selectBuilder, $entityConfig)
$prefix = ' DISTINCT ';
}
$expression = new ColumnValueExpression(
- strtoupper($attributeData['function']) . '(' . $prefix . $tableAlias . '.' . $columnName . ')'
+ strtoupper($attributeData['function']) . '(' . $prefix
+ . $this->getConnection()->quoteIdentifier($tableAlias . '.' . $columnName)
+ . ')'
);
} else {
$expression = $tableAlias . '.' . $columnName;
diff --git a/app/code/Magento/Analytics/ReportXml/DB/ConditionResolver.php b/app/code/Magento/Analytics/ReportXml/DB/ConditionResolver.php
index 83a15444003ec..773b96959e794 100644
--- a/app/code/Magento/Analytics/ReportXml/DB/ConditionResolver.php
+++ b/app/code/Magento/Analytics/ReportXml/DB/ConditionResolver.php
@@ -116,7 +116,7 @@ private function getCondition(SelectBuilder $selectBuilder, $tableName, $conditi
) {
$expression = $columns[$condition['attribute']];
} else {
- $expression = $tableName . '.' . $condition['attribute'];
+ $expression = $this->getConnection()->quoteIdentifier($tableName . '.' . $condition['attribute']);
}
return sprintf(
$this->conditionMap[$condition['operator']],
@@ -161,6 +161,6 @@ public function getFilter(SelectBuilder $selectBuilder, $filterConfig, $aliasNam
}
$filtersParts[] = '(' . implode(' ' . strtoupper($glue) . ' ', $parts) . ')';
}
- return implode(' AND ', $filtersParts);
+ return implode(' OR ', $filtersParts);
}
}
diff --git a/app/code/Magento/Analytics/ReportXml/ReportProvider.php b/app/code/Magento/Analytics/ReportXml/ReportProvider.php
index 15f510f5cb671..3ebe5941108bc 100644
--- a/app/code/Magento/Analytics/ReportXml/ReportProvider.php
+++ b/app/code/Magento/Analytics/ReportXml/ReportProvider.php
@@ -64,11 +64,9 @@ private function getIteratorName(Query $query)
* Returns report data by name and criteria
*
* @param string $name
- * @param SearchCriteria|null $criteria
* @return \IteratorIterator
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function getReport($name, SearchCriteria $criteria = null)
+ public function getReport($name)
{
$query = $this->queryFactory->create($name);
$connection = $this->connectionFactory->getConnection($query->getConnectionName());
diff --git a/app/code/Magento/Analytics/Setup/InstallData.php b/app/code/Magento/Analytics/Setup/InstallData.php
index 4314bb3199541..aaa619bbb0caa 100644
--- a/app/code/Magento/Analytics/Setup/InstallData.php
+++ b/app/code/Magento/Analytics/Setup/InstallData.php
@@ -6,31 +6,16 @@
namespace Magento\Analytics\Setup;
+use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
-use Magento\Analytics\Model\NotificationTime;
/**
* @codeCoverageIgnore
*/
class InstallData implements InstallDataInterface
{
- /**
- * @var NotificationTime
- */
- private $notificationTime;
-
- /**
- * InstallData constructor.
- *
- * @param NotificationTime $notificationTime
- */
- public function __construct(
- NotificationTime $notificationTime
- ) {
- $this->notificationTime = $notificationTime;
- }
/**
* {@inheritdoc}
@@ -38,6 +23,31 @@ public function __construct(
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
- $this->notificationTime->storeLastTimeNotification(1);
+ $setup->getConnection()->insertMultiple(
+ $setup->getTable('core_config_data'),
+ [
+ [
+ 'scope' => 'default',
+ 'scope_id' => 0,
+ 'path' => 'analytics/subscription/enabled',
+ 'value' => 1
+ ],
+ [
+ 'scope' => 'default',
+ 'scope_id' => 0,
+ 'path' => SubscriptionHandler::CRON_STRING_PATH,
+ 'value' => join(' ', SubscriptionHandler::CRON_EXPR_ARRAY)
+ ]
+ ]
+ );
+
+ $setup->getConnection()->insert(
+ $setup->getTable('flag'),
+ [
+ 'flag_code' => SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE,
+ 'state' => 0,
+ 'flag_data' => 24,
+ ]
+ );
}
}
diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php
index b94a295c86527..cbf06264096ac 100644
--- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php
@@ -9,8 +9,9 @@
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Data\Form;
use Magento\Framework\Data\Form\Element\AbstractElement;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-class AdditionalCommentTest extends \PHPUnit_Framework_TestCase
+class AdditionalCommentTest extends \PHPUnit\Framework\TestCase
{
/**
* @var AdditionalComment
@@ -32,9 +33,6 @@ class AdditionalCommentTest extends \PHPUnit_Framework_TestCase
*/
private $formMock;
- /**
- * @return void
- */
protected function setUp()
{
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
@@ -48,12 +46,15 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $this->additionalComment = new AdditionalComment($this->contextMock);
+ $objectManager = new ObjectManager($this);
+ $this->additionalComment = $objectManager->getObject(
+ AdditionalComment::class,
+ [
+ 'context' => $this->contextMock
+ ]
+ );
}
- /**
- * @return void
- */
public function testRender()
{
$this->abstractElementMock->setForm($this->formMock);
diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php
index d37daf9525119..a652cf6b3d548 100644
--- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php
@@ -10,8 +10,9 @@
use Magento\Framework\Data\Form;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-class CollectionTimeLabelTest extends \PHPUnit_Framework_TestCase
+class CollectionTimeLabelTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CollectionTimeLabel
@@ -33,9 +34,6 @@ class CollectionTimeLabelTest extends \PHPUnit_Framework_TestCase
*/
private $abstractElementMock;
- /**
- * @return void
- */
protected function setUp()
{
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
@@ -55,12 +53,16 @@ protected function setUp()
$this->contextMock->expects($this->any())
->method('getLocaleDate')
->willReturn($this->timeZoneMock);
- $this->collectionTimeLabel = new CollectionTimeLabel($this->contextMock);
+
+ $objectManager = new ObjectManager($this);
+ $this->collectionTimeLabel = $objectManager->getObject(
+ CollectionTimeLabel::class,
+ [
+ 'context' => $this->contextMock
+ ]
+ );
}
- /**
- * @return void
- */
public function testRender()
{
$timeZone = "America/New_York";
diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php
index e25e745317699..09e753e4ac8aa 100644
--- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php
@@ -10,11 +10,12 @@
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Data\Form;
use Magento\Framework\Data\Form\Element\AbstractElement;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
/**
* Class SignupTest
*/
-class SubscriptionStatusLabelTest extends \PHPUnit_Framework_TestCase
+class SubscriptionStatusLabelTest extends \PHPUnit\Framework\TestCase
{
/**
* @var SubscriptionStatusLabel
@@ -41,9 +42,6 @@ class SubscriptionStatusLabelTest extends \PHPUnit_Framework_TestCase
*/
private $formMock;
- /**
- * @return void
- */
protected function setUp()
{
$this->subscriptionStatusProviderMock = $this->getMockBuilder(SubscriptionStatusProvider::class)
@@ -60,15 +58,16 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $this->subscriptionStatusLabel = new SubscriptionStatusLabel(
- $this->contextMock,
- $this->subscriptionStatusProviderMock
+ $objectManager = new ObjectManager($this);
+ $this->subscriptionStatusLabel = $objectManager->getObject(
+ SubscriptionStatusLabel::class,
+ [
+ 'context' => $this->contextMock,
+ 'subscriptionStatusProvider' => $this->subscriptionStatusProviderMock
+ ]
);
}
- /**
- * @return void
- */
public function testRender()
{
$this->abstractElementMock->setForm($this->formMock);
diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php
new file mode 100644
index 0000000000000..abce48c36c86a
--- /dev/null
+++ b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php
@@ -0,0 +1,77 @@
+abstractElementMock = $this->getMockBuilder(AbstractElement::class)
+ ->setMethods(['getComment', 'getLabel', 'getHint'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->contextMock = $this->getMockBuilder(Context::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->formMock = $this->getMockBuilder(Form::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $objectManager = new ObjectManager($this);
+ $this->vertical = $objectManager->getObject(
+ Vertical::class,
+ [
+ 'context' => $this->contextMock
+ ]
+ );
+ }
+
+ public function testRender()
+ {
+ $this->abstractElementMock->setForm($this->formMock);
+ $this->abstractElementMock->expects($this->any())
+ ->method('getComment')
+ ->willReturn('New comment');
+ $this->abstractElementMock->expects($this->any())
+ ->method('getHint')
+ ->willReturn('New hint');
+ $html = $this->vertical->render($this->abstractElementMock);
+ $this->assertRegexp(
+ "/New comment/",
+ $html
+ );
+ $this->assertRegExp(
+ "/New hint/",
+ $html
+ );
+ }
+}
diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/BIEssentials/SignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/BIEssentials/SignUpTest.php
index 3a251f9a8685a..6f613cdc4d639 100644
--- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/BIEssentials/SignUpTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/BIEssentials/SignUpTest.php
@@ -14,7 +14,7 @@
/**
* Class SignupTest
*/
-class SignUpTest extends \PHPUnit_Framework_TestCase
+class SignUpTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerHelper
diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Reports/ShowTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Reports/ShowTest.php
index eaab952178daa..4f54ce5059965 100644
--- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Reports/ShowTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Reports/ShowTest.php
@@ -6,6 +6,7 @@
namespace Magento\Analytics\Test\Unit\Controller\Adminhtml\Reports;
use Magento\Analytics\Controller\Adminhtml\Reports\Show;
+use Magento\Analytics\Model\Exception\State\SubscriptionUpdateException;
use Magento\Analytics\Model\ReportUrlProvider;
use Magento\Framework\Controller\Result\Redirect;
use Magento\Framework\Controller\ResultFactory;
@@ -16,7 +17,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ShowTest extends \PHPUnit_Framework_TestCase
+class ShowTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ReportUrlProvider|\PHPUnit_Framework_MockObject_MockObject
@@ -152,4 +153,33 @@ public function executeWithExceptionDataProvider()
'ExecuteWithException' => [new \Exception('TestMessage')],
];
}
+
+ /**
+ * @return void
+ */
+ public function testExecuteWithSubscriptionUpdateException()
+ {
+ $exception = new SubscriptionUpdateException(__('TestMessage'));
+ $this->resultFactoryMock
+ ->expects($this->once())
+ ->method('create')
+ ->with(ResultFactory::TYPE_REDIRECT)
+ ->willReturn($this->redirectMock);
+ $this->reportUrlProviderMock
+ ->expects($this->once())
+ ->method('getUrl')
+ ->with()
+ ->willThrowException($exception);
+ $this->messageManagerMock
+ ->expects($this->once())
+ ->method('addNoticeMessage')
+ ->with($exception->getMessage())
+ ->willReturnSelf();
+ $this->redirectMock
+ ->expects($this->once())
+ ->method('setPath')
+ ->with('adminhtml')
+ ->willReturnSelf();
+ $this->assertSame($this->redirectMock, $this->showController->execute());
+ }
}
diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/ActivateTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/ActivateTest.php
deleted file mode 100644
index 9097349e9137c..0000000000000
--- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/ActivateTest.php
+++ /dev/null
@@ -1,252 +0,0 @@
-resultFactoryMock = $this->getMockBuilder(ResultFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->resultJsonMock = $this->getMockBuilder(Json::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->preparedValueFactoryMock = $this->getMockBuilder(PreparedValueFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->configValueResourceMock = $this->getMockBuilder(AbstractDb::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->requestMock = $this->getMockBuilder(RequestInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->notificationTimeMock = $this->getMockBuilder(NotificationTime::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->objectManagerHelper = new ObjectManagerHelper($this);
-
- $this->activateController = $this->objectManagerHelper->getObject(
- Activate::class,
- [
- 'resultFactory' => $this->resultFactoryMock,
- 'preparedValueFactory' => $this->preparedValueFactoryMock,
- 'configValueResource' => $this->configValueResourceMock,
- 'logger' => $this->loggerMock,
- 'notificationTime' => $this->notificationTimeMock,
- '_request' => $this->requestMock,
- 'subscriptionApprovedFiled' => $this->subscriptionApprovedField,
- ]
- );
- }
-
- /**
- * @dataProvider executeDataProvider
- *
- * @param bool $isSubscriptionEnabled
- * @return void
- */
- public function testExecute($isSubscriptionEnabled)
- {
- $successResult = [
- 'success' => true,
- 'error_message' => '',
- ];
-
- $this->requestMock
- ->expects($this->once())
- ->method('getParam')
- ->with($this->subscriptionApprovedField)
- ->willReturn($isSubscriptionEnabled);
-
- if ($isSubscriptionEnabled) {
- $configValue = $this->createConfigValueMock();
- $this->preparedValueFactoryMock
- ->expects($this->once())
- ->method('create')
- ->willReturn($configValue);
- $this->configValueResourceMock->expects($this->once())->method('save')->with($configValue);
- } else {
- $this->notificationTimeMock
- ->expects($this->once())
- ->method('unsetLastTimeNotificationValue')
- ->willReturn(true);
- }
-
- $this->resultFactoryMock->expects($this->once())
- ->method('create')
- ->with(ResultFactory::TYPE_JSON)
- ->willReturn($this->resultJsonMock);
- $this->resultJsonMock->expects($this->once())
- ->method('setData')
- ->with($successResult)
- ->willReturnSelf();
- $this->assertSame(
- $this->resultJsonMock,
- $this->activateController->execute()
- );
- }
-
- /**
- * @dataProvider executeExceptionsDataProvider
- *
- * @param \Exception $exception
- */
- public function testExecuteWithException(\Exception $exception)
- {
- $this->requestMock
- ->expects($this->once())
- ->method('getParam')
- ->with($this->subscriptionApprovedField)
- ->willReturn(true);
-
- $this->preparedValueFactoryMock
- ->expects($this->once())
- ->method('create')
- ->willThrowException($exception);
- $this->loggerMock
- ->expects($this->once())
- ->method('error')
- ->with($exception->getMessage());
- $this->resultFactoryMock
- ->expects($this->once())
- ->method('create')
- ->with(ResultFactory::TYPE_JSON)
- ->willReturn($this->resultJsonMock);
-
- if ($exception instanceof LocalizedException) {
- $this->resultJsonMock
- ->expects($this->once())
- ->method('setData')
- ->with([
- 'success' => false,
- 'error_message' => $exception->getMessage(),
- ])
- ->willReturnSelf();
- } else {
- $this->resultJsonMock
- ->expects($this->once())
- ->method('setData')
- ->withAnyParameters()
- ->willReturnSelf();
- }
-
- $this->assertSame(
- $this->resultJsonMock,
- $this->activateController->execute()
- );
- }
-
- /**
- * @return \PHPUnit_Framework_MockObject_MockObject
- */
- private function createConfigValueMock()
- {
- return $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class)
- ->disableOriginalConstructor()
- ->getMock();
- }
-
- /**
- * @return array
- */
- public function executeExceptionsDataProvider()
- {
- return [
- [new LocalizedException(__('TestMessage'))],
- [new \Exception('TestMessage')],
- ];
- }
-
- /**
- * @return array
- */
- public function executeDataProvider()
- {
- return [
- [true],
- [false],
- ];
- }
-}
diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/PostponeTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/PostponeTest.php
deleted file mode 100644
index 0f425291bf999..0000000000000
--- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/PostponeTest.php
+++ /dev/null
@@ -1,168 +0,0 @@
-dateTimeFactoryMock = $this->getMockBuilder(DateTimeFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->dateTimeMock = $this->getMockBuilder(\DateTime::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->notificationTimeMock = $this->getMockBuilder(NotificationTime::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
- ->getMock();
- $this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->resultMock = $this->getMockBuilder(Json::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->resultFactoryMock->expects($this->once())
- ->method('create')
- ->with(ResultFactory::TYPE_JSON)
- ->willReturn($this->resultMock);
- $objectManagerHelper = new ObjectManagerHelper($this);
- $this->action = $objectManagerHelper->getObject(
- Postpone::class,
- [
- 'resultFactory' => $this->resultFactoryMock,
- 'dateTimeFactory' => $this->dateTimeFactoryMock,
- 'notificationTime' => $this->notificationTimeMock,
- 'logger' => $this->loggerMock
- ]
- );
- }
-
- public function testExecuteSuccess()
- {
- $this->dateTimeFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($this->dateTimeMock);
- $this->dateTimeMock->expects($this->once())
- ->method('getTimestamp')
- ->willReturn(100500);
- $this->notificationTimeMock->expects($this->once())
- ->method('storeLastTimeNotification')
- ->with(100500)
- ->willReturn(true);
- $this->resultMock->expects($this->once())
- ->method('setData')
- ->with(
- [
- 'success' => true,
- 'error_message' => ''
- ],
- false,
- []
- )->willReturnSelf();
- $this->assertEquals($this->resultMock, $this->action->execute());
- }
-
- public function testExecuteFailedWithLocalizedException()
- {
- $this->dateTimeFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($this->dateTimeMock);
- $this->dateTimeMock->expects($this->once())
- ->method('getTimestamp')
- ->willReturn(100500);
- $this->notificationTimeMock->expects($this->once())
- ->method('storeLastTimeNotification')
- ->with(100500)
- ->willThrowException(new LocalizedException(__('Error message')));
- $this->resultMock->expects($this->once())
- ->method('setData')
- ->with(
- [
- 'success' => false,
- 'error_message' => 'Error message'
- ],
- false,
- []
- )->willReturnSelf();
- $this->assertEquals($this->resultMock, $this->action->execute());
- }
-
- public function testExecuteFailedWithException()
- {
- $this->dateTimeFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($this->dateTimeMock);
- $this->dateTimeMock->expects($this->once())
- ->method('getTimestamp')
- ->willReturn(100500);
- $this->notificationTimeMock->expects($this->once())
- ->method('storeLastTimeNotification')
- ->with(100500)
- ->willThrowException(new \Exception('Any message'));
- $this->resultMock->expects($this->once())
- ->method('setData')
- ->with(
- [
- 'success' => false,
- 'error_message' => __('Error occurred during postponement notification')
- ],
- false,
- []
- )->willReturnSelf();
- $this->assertEquals($this->resultMock, $this->action->execute());
- }
-}
diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/RetryTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/RetryTest.php
index 2c921e2260140..17c485a8df230 100644
--- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/RetryTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/RetryTest.php
@@ -18,7 +18,7 @@
/**
* Class RetryTest
*/
-class RetryTest extends \PHPUnit_Framework_TestCase
+class RetryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ResultFactory|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Cron/CollectDataTest.php b/app/code/Magento/Analytics/Test/Unit/Cron/CollectDataTest.php
index ef071cdf3a911..81c57d79033c8 100644
--- a/app/code/Magento/Analytics/Test/Unit/Cron/CollectDataTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Cron/CollectDataTest.php
@@ -13,7 +13,7 @@
/**
* Class CollectDataTest
*/
-class CollectDataTest extends \PHPUnit_Framework_TestCase
+class CollectDataTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ExportDataHandlerInterface|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php
index c8ab5a6f4649e..959a11f9e1058 100644
--- a/app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php
@@ -15,7 +15,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SignUpTest extends \PHPUnit_Framework_TestCase
+class SignUpTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Connector|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php b/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php
index 9a5355de62a5c..ede53d8783a7a 100644
--- a/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php
@@ -6,8 +6,9 @@
namespace Magento\Analytics\Test\Unit\Cron;
use Magento\Analytics\Cron\Update;
+use Magento\Analytics\Model\AnalyticsToken;
+use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Connector;
-use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;
@@ -15,7 +16,7 @@
/**
* Class Update
*/
-class UpdateTest extends \PHPUnit_Framework_TestCase
+class UpdateTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Connector|\PHPUnit_Framework_MockObject_MockObject
@@ -37,6 +38,11 @@ class UpdateTest extends \PHPUnit_Framework_TestCase
*/
private $reinitableConfigMock;
+ /**
+ * @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $analyticsTokenMock;
+
/**
* @var Update
*/
@@ -56,38 +62,153 @@ protected function setUp()
$this->reinitableConfigMock = $this->getMockBuilder(ReinitableConfigInterface::class)
->disableOriginalConstructor()
->getMock();
+ $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
+ ->disableOriginalConstructor()
+ ->getMock();
$this->update = new Update(
$this->connectorMock,
$this->configWriterMock,
$this->reinitableConfigMock,
- $this->flagManagerMock
+ $this->flagManagerMock,
+ $this->analyticsTokenMock
);
}
- public function testExecute()
+ /**
+ * @return void
+ */
+ public function testExecuteWithoutToken()
{
- $this->connectorMock->expects($this->once())
+ $this->flagManagerMock
+ ->method('getFlagData')
+ ->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE)
+ ->willReturn(10);
+ $this->connectorMock
+ ->expects($this->once())
->method('execute')
->with('update')
- ->willReturn(true);
- $this->configWriterMock->expects($this->once())
- ->method('delete')
- ->with(BaseUrlConfigPlugin::UPDATE_CRON_STRING_PATH);
- $this->flagManagerMock->expects($this->once())
+ ->willReturn(false);
+ $this->analyticsTokenMock
+ ->expects($this->once())
+ ->method('isTokenExist')
+ ->willReturn(false);
+ $this->addFinalOutputAsserts();
+ $this->assertFalse($this->update->execute());
+ }
+
+ /**
+ * @param bool $isExecuted
+ */
+ private function addFinalOutputAsserts(bool $isExecuted = true)
+ {
+ $this->flagManagerMock
+ ->expects($this->exactly(2 * $isExecuted))
->method('deleteFlag')
- ->with(BaseUrlConfigPlugin::OLD_BASE_URL_FLAG_CODE);
- $this->reinitableConfigMock->expects($this->once())
- ->method('reinit');
- $this->assertTrue($this->update->execute());
+ ->withConsecutive(
+ [SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE],
+ [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE]
+ );
+ $this->configWriterMock
+ ->expects($this->exactly((int)$isExecuted))
+ ->method('delete')
+ ->with(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH);
+ $this->reinitableConfigMock
+ ->expects($this->exactly((int)$isExecuted))
+ ->method('reinit')
+ ->with();
}
- public function testExecuteUnsuccess()
+ /**
+ * @param $counterData
+ * @return void
+ * @dataProvider executeWithEmptyReverseCounterDataProvider
+ */
+ public function testExecuteWithEmptyReverseCounter($counterData)
{
- $this->connectorMock->expects($this->once())
+ $this->flagManagerMock
+ ->method('getFlagData')
+ ->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE)
+ ->willReturn($counterData);
+ $this->connectorMock
+ ->expects($this->never())
->method('execute')
->with('update')
->willReturn(false);
+ $this->analyticsTokenMock
+ ->method('isTokenExist')
+ ->willReturn(true);
+ $this->addFinalOutputAsserts();
$this->assertFalse($this->update->execute());
}
+
+ /**
+ * Provides empty states of the reverse counter.
+ *
+ * @return array
+ */
+ public function executeWithEmptyReverseCounterDataProvider()
+ {
+ return [
+ [null],
+ [0]
+ ];
+ }
+
+ /**
+ * @param int $reverseCount
+ * @param bool $commandResult
+ * @param bool $finalConditionsIsExpected
+ * @param bool $functionResult
+ * @return void
+ * @dataProvider executeRegularScenarioDataProvider
+ */
+ public function testExecuteRegularScenario(
+ int $reverseCount,
+ bool $commandResult,
+ bool $finalConditionsIsExpected,
+ bool $functionResult
+ ) {
+ $this->flagManagerMock
+ ->method('getFlagData')
+ ->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE)
+ ->willReturn($reverseCount);
+ $this->connectorMock
+ ->expects($this->once())
+ ->method('execute')
+ ->with('update')
+ ->willReturn($commandResult);
+ $this->analyticsTokenMock
+ ->method('isTokenExist')
+ ->willReturn(true);
+ $this->addFinalOutputAsserts($finalConditionsIsExpected);
+ $this->assertSame($functionResult, $this->update->execute());
+ }
+
+ /**
+ * @return array
+ */
+ public function executeRegularScenarioDataProvider()
+ {
+ return [
+ 'The last attempt with command execution result False' => [
+ 'Reverse count' => 1,
+ 'Command result' => false,
+ 'Executed final output conditions' => true,
+ 'Function result' => false,
+ ],
+ 'Not the last attempt with command execution result False' => [
+ 'Reverse count' => 10,
+ 'Command result' => false,
+ 'Executed final output conditions' => false,
+ 'Function result' => false,
+ ],
+ 'Command execution result True' => [
+ 'Reverse count' => 10,
+ 'Command result' => true,
+ 'Executed final output conditions' => true,
+ 'Function result' => true,
+ ],
+ ];
+ }
}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/AnalyticsTokenTest.php b/app/code/Magento/Analytics/Test/Unit/Model/AnalyticsTokenTest.php
index e078bbe99f93a..57315543bc32d 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/AnalyticsTokenTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/AnalyticsTokenTest.php
@@ -14,7 +14,7 @@
/**
* Class AnalyticsTokenTest
*/
-class AnalyticsTokenTest extends \PHPUnit_Framework_TestCase
+class AnalyticsTokenTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ReinitableConfigInterface|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Condition/CanViewNotificationTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Condition/CanViewNotificationTest.php
deleted file mode 100644
index bfdc971efc79e..0000000000000
--- a/app/code/Magento/Analytics/Test/Unit/Model/Condition/CanViewNotificationTest.php
+++ /dev/null
@@ -1,81 +0,0 @@
-dateTimeFactoryMock = $this->getMockBuilder(DateTimeFactory::class)
- ->getMock();
- $this->dateTimeMock = $this->getMockBuilder(\DateTime::class)
- ->getMock();
- $this->notificationTimeMock = $this->getMockBuilder(NotificationTime::class)
- ->disableOriginalConstructor()
- ->getMock();
- $objectManager = new ObjectManager($this);
- $this->canViewNotification = $objectManager->getObject(
- CanViewNotification::class,
- [
- 'notificationTime' => $this->notificationTimeMock,
- 'dateTimeFactory' => $this->dateTimeFactoryMock
- ]
- );
- }
-
- public function testValidate()
- {
- $this->notificationTimeMock->expects($this->once())
- ->method('getLastTimeNotification')
- ->willReturn(1);
- $this->dateTimeFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($this->dateTimeMock);
- $this->dateTimeMock->expects($this->once())
- ->method('getTimestamp')
- ->willReturn(10005000);
- $this->assertTrue($this->canViewNotification->isVisible([]));
- }
-
- public function testValidateFlagRemoved()
- {
- $this->notificationTimeMock->expects($this->once())
- ->method('getLastTimeNotification')
- ->willReturn(null);
- $this->dateTimeFactoryMock->expects($this->never())
- ->method('create');
- $this->assertFalse($this->canViewNotification->isVisible([]));
- }
-}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php
new file mode 100644
index 0000000000000..f5f721c038c57
--- /dev/null
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php
@@ -0,0 +1,178 @@
+reinitableConfigMock = $this->getMockBuilder(ReinitableConfigInterface::class)
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->configWriterMock = $this->getMockBuilder(WriterInterface::class)
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->objectManagerHelper = new ObjectManagerHelper($this);
+
+ $this->subscriptionUpdateHandler = $this->objectManagerHelper->getObject(
+ SubscriptionUpdateHandler::class,
+ [
+ 'reinitableConfig' => $this->reinitableConfigMock,
+ 'analyticsToken' => $this->analyticsTokenMock,
+ 'flagManager' => $this->flagManagerMock,
+ 'configWriter' => $this->configWriterMock,
+ ]
+ );
+ }
+
+ /**
+ * @return void
+ */
+ public function testTokenDoesNotExist()
+ {
+ $this->analyticsTokenMock
+ ->expects($this->once())
+ ->method('isTokenExist')
+ ->with()
+ ->willReturn(false);
+ $this->flagManagerMock
+ ->expects($this->never())
+ ->method('saveFlag');
+ $this->configWriterMock
+ ->expects($this->never())
+ ->method('save');
+ $this->assertTrue($this->subscriptionUpdateHandler->processUrlUpdate('http://store.com'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testTokenAndPreviousBaseUrlExist()
+ {
+ $url = 'https://store.com';
+ $this->analyticsTokenMock
+ ->expects($this->once())
+ ->method('isTokenExist')
+ ->with()
+ ->willReturn(true);
+ $this->flagManagerMock
+ ->expects($this->once())
+ ->method('getFlagData')
+ ->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)
+ ->willReturn(true);
+ $this->flagManagerMock
+ ->expects($this->once())
+ ->method('saveFlag')
+ ->withConsecutive(
+ [SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue],
+ [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, $url]
+ );
+ $this->configWriterMock
+ ->expects($this->once())
+ ->method('save')
+ ->with(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH, $this->cronExpression);
+ $this->reinitableConfigMock
+ ->expects($this->once())
+ ->method('reinit')
+ ->with();
+ $this->assertTrue($this->subscriptionUpdateHandler->processUrlUpdate($url));
+ }
+
+ /**
+ * @return void
+ */
+ public function testTokenExistAndWithoutPreviousBaseUrl()
+ {
+ $url = 'https://store.com';
+ $this->analyticsTokenMock
+ ->expects($this->once())
+ ->method('isTokenExist')
+ ->with()
+ ->willReturn(true);
+ $this->flagManagerMock
+ ->expects($this->once())
+ ->method('getFlagData')
+ ->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)
+ ->willReturn(false);
+ $this->flagManagerMock
+ ->expects($this->exactly(2))
+ ->method('saveFlag')
+ ->withConsecutive(
+ [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, $url],
+ [SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue]
+ );
+ $this->configWriterMock
+ ->expects($this->once())
+ ->method('save')
+ ->with(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH, $this->cronExpression);
+ $this->reinitableConfigMock
+ ->expects($this->once())
+ ->method('reinit')
+ ->with();
+ $this->assertTrue($this->subscriptionUpdateHandler->processUrlUpdate($url));
+ }
+}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/CollectionTimeTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/CollectionTimeTest.php
index 555020ffd247f..071b96111ac8b 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/CollectionTimeTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/CollectionTimeTest.php
@@ -14,7 +14,7 @@
/**
* Class CollectionTimeTest
*/
-class CollectionTimeTest extends \PHPUnit_Framework_TestCase
+class CollectionTimeTest extends \PHPUnit\Framework\TestCase
{
/**
* @var WriterInterface|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Enabled/SubscriptionHandlerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Enabled/SubscriptionHandlerTest.php
index d01101bf5cc3b..82aa4dc72dfe0 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Enabled/SubscriptionHandlerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Enabled/SubscriptionHandlerTest.php
@@ -9,7 +9,6 @@
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\CollectionTime;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
-use Magento\Analytics\Model\NotificationTime;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
@@ -17,7 +16,7 @@
/**
* Class SubscriptionHandlerTest
*/
-class SubscriptionHandlerTest extends \PHPUnit_Framework_TestCase
+class SubscriptionHandlerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var FlagManager|\PHPUnit_Framework_MockObject_MockObject
@@ -34,11 +33,6 @@ class SubscriptionHandlerTest extends \PHPUnit_Framework_TestCase
*/
private $tokenMock;
- /**
- * @var NotificationTime|\PHPUnit_Framework_MockObject_MockObject
- */
- private $notificationTimeMock;
-
/**
* @var ObjectManagerHelper
*/
@@ -54,9 +48,6 @@ class SubscriptionHandlerTest extends \PHPUnit_Framework_TestCase
*/
private $subscriptionHandler;
- /**
- * @return void
- */
protected function setUp()
{
$this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
@@ -71,10 +62,6 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $this->notificationTimeMock = $this->getMockBuilder(NotificationTime::class)
- ->disableOriginalConstructor()
- ->getMock();
-
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->subscriptionHandler = $this->objectManagerHelper->getObject(
@@ -84,14 +71,10 @@ protected function setUp()
'configWriter' => $this->configWriterMock,
'attemptsInitValue' => $this->attemptsInitValue,
'analyticsToken' => $this->tokenMock,
- 'notificationTime' => $this->notificationTimeMock,
]
);
}
- /**
- * @return void
- */
public function testProcessEnabledTokenExist()
{
$this->tokenMock
@@ -104,17 +87,11 @@ public function testProcessEnabledTokenExist()
$this->flagManagerMock
->expects($this->never())
->method('saveFlag');
- $this->notificationTimeMock
- ->expects($this->never())
- ->method('unsetLastTimeNotificationValue');
$this->assertTrue(
$this->subscriptionHandler->processEnabled()
);
}
- /**
- * @return void
- */
public function testProcessEnabledTokenDoesNotExist()
{
$this->tokenMock
@@ -130,18 +107,11 @@ public function testProcessEnabledTokenDoesNotExist()
->method('saveFlag')
->with(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue)
->willReturn(true);
- $this->notificationTimeMock
- ->expects($this->once())
- ->method('unsetLastTimeNotificationValue')
- ->willReturn(true);
$this->assertTrue(
$this->subscriptionHandler->processEnabled()
);
}
- /**
- * @return void
- */
public function testProcessDisabledTokenDoesNotExist()
{
$this->configWriterMock
@@ -162,9 +132,6 @@ public function testProcessDisabledTokenDoesNotExist()
);
}
- /**
- * @return void
- */
public function testProcessDisabledTokenExists()
{
$this->configWriterMock
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/EnabledTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/EnabledTest.php
index d64827d2d18d2..eea3193258bc6 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/EnabledTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/EnabledTest.php
@@ -16,7 +16,7 @@
/**
* Class EnabledTest
*/
-class EnabledTest extends \PHPUnit_Framework_TestCase
+class EnabledTest extends \PHPUnit\Framework\TestCase
{
/**
* @var SubscriptionHandler|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/VerticalTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/VerticalTest.php
index d689f040c48b3..6fe7d0aa93998 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/VerticalTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/VerticalTest.php
@@ -8,7 +8,7 @@
/**
* A unit test for testing of the backend model for verticals configuration.
*/
-class VerticalTest extends \PHPUnit_Framework_TestCase
+class VerticalTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Analytics\Model\Config\Backend\Vertical
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/MapperTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/MapperTest.php
index 7c94fb1b60a14..0b7f4870dbac8 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/MapperTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/MapperTest.php
@@ -11,7 +11,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class MapperTest extends \PHPUnit_Framework_TestCase
+class MapperTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerHelper
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/ReaderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/ReaderTest.php
index 1eee74a1f93a0..6aa9c7ef3106c 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/ReaderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/ReaderTest.php
@@ -13,7 +13,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ReaderTest extends \PHPUnit_Framework_TestCase
+class ReaderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Mapper|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/SchemaLocatorTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/SchemaLocatorTest.php
deleted file mode 100644
index 4d26f1cae9ee1..0000000000000
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/SchemaLocatorTest.php
+++ /dev/null
@@ -1,80 +0,0 @@
-urnResolverMock = $this->getMockBuilder(UrnResolver::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->objectManagerHelper = new ObjectManagerHelper($this);
-
- $this->schemaLocator = $this->objectManagerHelper->getObject(
- SchemaLocator::class,
- [
- 'urnResolver' => $this->urnResolverMock,
- 'schema' => $this->schema,
- ]
- );
- }
-
- /**
- * @return void
- */
- public function testGetSchema()
- {
- $schemaRealPath = '/path/test.xml';
-
- $this->urnResolverMock
- ->expects($this->once())
- ->method('getRealPath')
- ->with($this->schema)
- ->willReturn($schemaRealPath);
-
- $this->assertSame($schemaRealPath, $this->schemaLocator->getSchema());
- }
-
- /**
- * @return void
- */
- public function testGetPerFileSchema()
- {
- $this->assertNull($this->schemaLocator->getPerFileSchema());
- }
-}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Source/VerticalTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Source/VerticalTest.php
index b96f3543ff701..c13205d34f25b 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Source/VerticalTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Config/Source/VerticalTest.php
@@ -8,7 +8,7 @@
/**
* A unit test for testing of the source model for verticals configuration.
*/
-class VerticalTest extends \PHPUnit_Framework_TestCase
+class VerticalTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Analytics\Model\Config\Source\Vertical
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ConfigTest.php
index 8282b1ae52617..8739219ebdf09 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ConfigTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ConfigTest.php
@@ -12,7 +12,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ConfigTest extends \PHPUnit_Framework_TestCase
+class ConfigTest extends \PHPUnit\Framework\TestCase
{
/**
* @var DataInterface|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php
index 6890fe200f9dc..f8f3919b2489e 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php
@@ -12,7 +12,7 @@
/**
* A unit test for testing of the CURL HTTP client.
*/
-class CurlTest extends \PHPUnit_Framework_TestCase
+class CurlTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Analytics\Model\Connector\Http\Client\Curl
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php
index 7ac6f50ea24c4..60a19f3d5079e 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php
@@ -10,7 +10,7 @@
/**
* Class JsonConverterTest
*/
-class JsonConverterTest extends \PHPUnit_Framework_TestCase
+class JsonConverterTest extends \PHPUnit\Framework\TestCase
{
public function testConverterContainsHeader()
{
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/ResponseResolverTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/ResponseResolverTest.php
index 5047e8a9dd391..7c3c484843285 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/ResponseResolverTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/ResponseResolverTest.php
@@ -12,7 +12,7 @@
/**
* Class ResponseResolverTest
*/
-class ResponseResolverTest extends \PHPUnit_Framework_TestCase
+class ResponseResolverTest extends \PHPUnit\Framework\TestCase
{
public function testGetResultHandleResponseSuccess()
{
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/NotifyDataChangedCommandTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/NotifyDataChangedCommandTest.php
index a30211c7f3475..cee3877631c2e 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/NotifyDataChangedCommandTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/NotifyDataChangedCommandTest.php
@@ -8,13 +8,13 @@
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Connector\Http\JsonConverter;
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\HTTP\ZendClient;
-use Magento\Config\Model\Config;
use Psr\Log\LoggerInterface;
use Magento\Analytics\Model\Connector\NotifyDataChangedCommand;
use Magento\Analytics\Model\Connector\Http\ClientInterface;
-class NotifyDataChangedCommandTest extends \PHPUnit_Framework_TestCase
+class NotifyDataChangedCommandTest extends \PHPUnit\Framework\TestCase
{
/**
* @var NotifyDataChangedCommand
@@ -32,7 +32,7 @@ class NotifyDataChangedCommandTest extends \PHPUnit_Framework_TestCase
private $httpClientMock;
/**
- * @var Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
*/
public $configMock;
@@ -51,7 +51,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $this->configMock = $this->getMockBuilder(Config::class)
+ $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class)
->disableOriginalConstructor()
->getMock();
@@ -80,7 +80,7 @@ public function testExecuteSuccess()
->method('isTokenExist')
->willReturn(true);
$this->configMock->expects($this->any())
- ->method('getConfigDataValue')
+ ->method('getValue')
->willReturn($configVal);
$this->analyticsTokenMock->expects($this->once())
->method('getToken')
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/OTPRequestTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/OTPRequestTest.php
index a33d7d0d7c1bf..8a3f4efb15cf4 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/OTPRequestTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/OTPRequestTest.php
@@ -15,7 +15,7 @@
/**
* A unit test for testing of the representation of a 'OTP' request.
*/
-class OTPRequestTest extends \PHPUnit_Framework_TestCase
+class OTPRequestTest extends \PHPUnit\Framework\TestCase
{
/**
* @var OTPRequest
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/OTPTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/OTPTest.php
index 203eb57157e0e..0ff36cca5db2d 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/OTPTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/OTPTest.php
@@ -10,7 +10,7 @@
/**
* Class OTPTest
*/
-class OTPTest extends \PHPUnit_Framework_TestCase
+class OTPTest extends \PHPUnit\Framework\TestCase
{
public function testHandleResult()
{
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/ReSignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/ReSignUpTest.php
index 4c3dde7a92c3f..707003149bcfd 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/ReSignUpTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/ReSignUpTest.php
@@ -13,7 +13,7 @@
/**
* Class ReSignUpTest
*/
-class ReSignUpTest extends \PHPUnit_Framework_TestCase
+class ReSignUpTest extends \PHPUnit\Framework\TestCase
{
public function testHandleResult()
{
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/SignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/SignUpTest.php
index 2bbd528638a19..81711cfc56950 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/SignUpTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/SignUpTest.php
@@ -12,7 +12,7 @@
/**
* Class SignUpTest
*/
-class SignUpTest extends \PHPUnit_Framework_TestCase
+class SignUpTest extends \PHPUnit\Framework\TestCase
{
public function testHandleResult()
{
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/UpdateTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/UpdateTest.php
index 90102e2c3d868..7779357e8bea7 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/UpdateTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/UpdateTest.php
@@ -10,7 +10,7 @@
/**
* Class UpdateTest
*/
-class UpdateTest extends \PHPUnit_Framework_TestCase
+class UpdateTest extends \PHPUnit\Framework\TestCase
{
public function testHandleResult()
{
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/SignUpCommandTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/SignUpCommandTest.php
index 624728f3440c9..5593496a957b7 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/SignUpCommandTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/SignUpCommandTest.php
@@ -11,14 +11,14 @@
use Magento\Analytics\Model\Connector\SignUpCommand;
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\IntegrationManager;
-use Magento\Config\Model\Config;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Integration\Model\Oauth\Token as IntegrationToken;
use Psr\Log\LoggerInterface;
/**
* Class SignUpCommandTest
*/
-class SignUpCommandTest extends \PHPUnit_Framework_TestCase
+class SignUpCommandTest extends \PHPUnit\Framework\TestCase
{
/**
* @var SignUpCommand
@@ -41,7 +41,7 @@ class SignUpCommandTest extends \PHPUnit_Framework_TestCase
private $integrationToken;
/**
- * @var Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $configMock;
@@ -71,7 +71,7 @@ protected function setUp()
$this->integrationToken = $this->getMockBuilder(IntegrationToken::class)
->disableOriginalConstructor()
->getMock();
- $this->configMock = $this->getMockBuilder(Config::class)
+ $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class)
->disableOriginalConstructor()
->getMock();
$this->httpClientMock = $this->getMockBuilder(ClientInterface::class)
@@ -105,7 +105,7 @@ public function testExecuteSuccess()
$data = $this->getTestData();
$this->configMock->expects($this->any())
- ->method('getConfigDataValue')
+ ->method('getValue')
->willReturn($data['url']);
$this->integrationToken->expects($this->any())
->method('getData')
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/UpdateCommandTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/UpdateCommandTest.php
index c5f96a96b4432..47253a13530e5 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/UpdateCommandTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Connector/UpdateCommandTest.php
@@ -6,19 +6,19 @@
namespace Magento\Analytics\Test\Unit\Model\Connector;
use Magento\Analytics\Model\AnalyticsToken;
+use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\FlagManager;
use Magento\Framework\HTTP\ZendClient;
-use Magento\Config\Model\Config;
use Psr\Log\LoggerInterface;
-use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
use Magento\Analytics\Model\Connector\UpdateCommand;
use Magento\Analytics\Model\Connector\Http\ClientInterface;
/**
* Class SignUpCommandTest
*/
-class UpdateCommandTest extends \PHPUnit_Framework_TestCase
+class UpdateCommandTest extends \PHPUnit\Framework\TestCase
{
/**
* @var UpdateCommand
@@ -36,7 +36,7 @@ class UpdateCommandTest extends \PHPUnit_Framework_TestCase
private $httpClientMock;
/**
- * @var Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
*/
public $configMock;
@@ -65,7 +65,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $this->configMock = $this->getMockBuilder(Config::class)
+ $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class)
->disableOriginalConstructor()
->getMock();
@@ -101,12 +101,12 @@ public function testExecuteSuccess()
->willReturn(true);
$this->configMock->expects($this->any())
- ->method('getConfigDataValue')
+ ->method('getValue')
->willReturn($configVal);
$this->flagManagerMock->expects($this->once())
->method('getFlagData')
- ->with(BaseUrlConfigPlugin::OLD_BASE_URL_FLAG_CODE)
+ ->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)
->willReturn($url);
$this->analyticsTokenMock->expects($this->once())
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php
index 14d641a19729d..4414b81cbc183 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php
@@ -12,7 +12,7 @@
/**
* Class SignUpCommandTest
*/
-class ConnectorTest extends \PHPUnit_Framework_TestCase
+class ConnectorTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php
index 3de718d843a1d..a896c309b4007 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php
@@ -14,7 +14,7 @@
/**
* Class CryptographerTest
*/
-class CryptographerTest extends \PHPUnit_Framework_TestCase
+class CryptographerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var AnalyticsToken|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/EncodedContextTest.php b/app/code/Magento/Analytics/Test/Unit/Model/EncodedContextTest.php
index 283b13212919d..a1a7c54510681 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/EncodedContextTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/EncodedContextTest.php
@@ -11,7 +11,7 @@
/**
* Class EncodedContextTest
*/
-class EncodedContextTest extends \PHPUnit_Framework_TestCase
+class EncodedContextTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerHelper
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerNotificationTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerNotificationTest.php
index b3826c232ed0c..1582c241bf45d 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerNotificationTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerNotificationTest.php
@@ -13,7 +13,7 @@
/**
* Class ExportDataHandlerNotificationTest
*/
-class ExportDataHandlerNotificationTest extends \PHPUnit_Framework_TestCase
+class ExportDataHandlerNotificationTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerHelper
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php
index 7c181bea81aab..6ffb61d088567 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php
@@ -19,7 +19,7 @@
/**
* Class ExportDataHandlerTest
*/
-class ExportDataHandlerTest extends \PHPUnit_Framework_TestCase
+class ExportDataHandlerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Filesystem|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoManagerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/FileInfoManagerTest.php
index c8c07ae8240c3..da5f6af3ca4e1 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoManagerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/FileInfoManagerTest.php
@@ -14,7 +14,7 @@
/**
* Class FileInfoManagerTest
*/
-class FileInfoManagerTest extends \PHPUnit_Framework_TestCase
+class FileInfoManagerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var FlagManager|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoTest.php b/app/code/Magento/Analytics/Test/Unit/Model/FileInfoTest.php
index 73f6ed644721a..43ce833f1f03f 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/FileInfoTest.php
@@ -11,7 +11,7 @@
/**
* Class FileInfoTest
*/
-class FileInfoTest extends \PHPUnit_Framework_TestCase
+class FileInfoTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerHelper
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/FileRecorderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/FileRecorderTest.php
index 68ff00a433fd2..3c9520bdd995b 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/FileRecorderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/FileRecorderTest.php
@@ -18,7 +18,7 @@
/**
* Class FileRecorderTest
*/
-class FileRecorderTest extends \PHPUnit_Framework_TestCase
+class FileRecorderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var FileInfoManager|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/IntegrationManagerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/IntegrationManagerTest.php
index 31d5c77ce50b0..3076a22c85be4 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/IntegrationManagerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/IntegrationManagerTest.php
@@ -16,7 +16,7 @@
/**
* Class IntegrationManagerTest
*/
-class IntegrationManagerTest extends \PHPUnit_Framework_TestCase
+class IntegrationManagerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var IntegrationServiceInterface|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/LinkProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/LinkProviderTest.php
index afda37962a3cb..c7aa2219d1eee 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/LinkProviderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/LinkProviderTest.php
@@ -18,7 +18,7 @@
/**
* Class LinkProviderTest
*/
-class LinkProviderTest extends \PHPUnit_Framework_TestCase
+class LinkProviderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerHelper
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/NotificationTimeTest.php b/app/code/Magento/Analytics/Test/Unit/Model/NotificationTimeTest.php
deleted file mode 100644
index 03fe7d968a7f5..0000000000000
--- a/app/code/Magento/Analytics/Test/Unit/Model/NotificationTimeTest.php
+++ /dev/null
@@ -1,76 +0,0 @@
-flagManagerMock = $this->getMockBuilder(FlagManager::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $objectManagerHelper = new ObjectManagerHelper($this);
- $this->notificationTime = $objectManagerHelper->getObject(
- NotificationTime::class,
- [
- 'flagManager' => $this->flagManagerMock,
- ]
- );
- }
-
- public function testStoreLastTimeNotification()
- {
- $value = 100500;
-
- $this->flagManagerMock
- ->expects($this->once())
- ->method('saveFlag')
- ->with(NotificationTime::NOTIFICATION_TIME, $value)
- ->willReturn(true);
- $this->assertTrue($this->notificationTime->storeLastTimeNotification($value));
- }
-
- public function testGetLastTimeNotification()
- {
- $value = 100500;
-
- $this->flagManagerMock
- ->expects($this->once())
- ->method('getFlagData')
- ->with(NotificationTime::NOTIFICATION_TIME)
- ->willReturn(true);
- $this->assertEquals($value, $this->notificationTime->getLastTimeNotification());
- }
-
- public function testUnsetLastTimeNotificationValue()
- {
- $this->flagManagerMock
- ->expects($this->once())
- ->method('deleteFlag')
- ->with(NotificationTime::NOTIFICATION_TIME)
- ->willReturn(true);
- $this->assertTrue($this->notificationTime->unsetLastTimeNotificationValue());
- }
-}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php
index caf81b77fbdf9..a89e06562383b 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php
@@ -5,39 +5,30 @@
*/
namespace Magento\Analytics\Test\Unit\Model\Plugin;
+use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
use Magento\Analytics\Model\SubscriptionStatusProvider;
-use Magento\Config\Model\Config\Backend\Baseurl;
-use Magento\Framework\FlagManager;
-use Magento\Framework\App\Config\Storage\WriterInterface;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Config\Value;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\Store;
/**
* Class BaseUrlConfigPluginTest
*/
-class BaseUrlConfigPluginTest extends \PHPUnit_Framework_TestCase
+class BaseUrlConfigPluginTest extends \PHPUnit\Framework\TestCase
{
/**
- * @var FlagManager | \PHPUnit_Framework_MockObject_MockObject
+ * @var SubscriptionUpdateHandler | \PHPUnit_Framework_MockObject_MockObject
*/
- private $flagManagerMock;
+ private $subscriptionUpdateHandlerMock;
/**
- * @var BaseUrl | \PHPUnit_Framework_MockObject_MockObject
+ * @var Value | \PHPUnit_Framework_MockObject_MockObject
*/
private $configValueMock;
- /**
- * @var SubscriptionStatusProvider | \PHPUnit_Framework_MockObject_MockObject
- */
- private $subscriptionStatusProvider;
-
- /**
- * @var WriterInterface | \PHPUnit_Framework_MockObject_MockObject
- */
- private $configWriterMock;
-
/**
* @var ObjectManagerHelper
*/
@@ -53,70 +44,42 @@ class BaseUrlConfigPluginTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
- $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->configValueMock = $this->getMockBuilder(Baseurl::class)
+ $this->subscriptionUpdateHandlerMock = $this->getMockBuilder(SubscriptionUpdateHandler::class)
->disableOriginalConstructor()
->getMock();
- $this->subscriptionStatusProvider = $this->getMockBuilder(SubscriptionStatusProvider::class)
+ $this->configValueMock = $this->getMockBuilder(Value::class)
->disableOriginalConstructor()
+ ->setMethods(['isValueChanged', 'getPath', 'getScope', 'getOldValue'])
->getMock();
- $this->configWriterMock = $this->getMockBuilder(WriterInterface::class)
- ->disableOriginalConstructor()
- ->getMockForAbstractClass();
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->plugin = $this->objectManagerHelper->getObject(
BaseUrlConfigPlugin::class,
[
- 'flagManager' => $this->flagManagerMock,
- 'subscriptionStatusProvider' => $this->subscriptionStatusProvider,
- 'configWriter' => $this->configWriterMock
+ 'subscriptionUpdateHandler' => $this->subscriptionUpdateHandlerMock,
]
);
}
/**
- * @param array $testData
- * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $saveConfigInvokeMatcher
- * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $oldValueInvokeMatcher
- * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $saveFlagInvokeMatcher
- * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $configValueGetPathMatcher
- *
+ * @param array $configValueData
* @return void
- * @dataProvider pluginDataProvider
+ * @dataProvider afterSavePluginIsNotApplicableDataProvider
*/
- public function testPluginForAfterSave(
- array $testData,
- \PHPUnit_Framework_MockObject_Matcher_InvokedCount $saveConfigInvokeMatcher,
- \PHPUnit_Framework_MockObject_Matcher_InvokedCount $oldValueInvokeMatcher,
- \PHPUnit_Framework_MockObject_Matcher_InvokedCount $saveFlagInvokeMatcher,
- \PHPUnit_Framework_MockObject_Matcher_InvokedCount $configValueGetPathMatcher
+ public function testAfterSavePluginIsNotApplicable(
+ array $configValueData
) {
- $this->configValueMock->expects($this->once())
+ $this->configValueMock
->method('isValueChanged')
- ->willReturn($testData['isValueChanged']);
-
- $this->configValueMock->expects($configValueGetPathMatcher)
- ->method('getData')
- ->with('path')
- ->willReturn($testData['path']);
- $this->subscriptionStatusProvider->expects($this->any())->method('getStatus')
- ->willReturn($testData['subscriptionStatus']);
-
- $oldUrl = 'mage.dev';
- $this->configValueMock->expects($oldValueInvokeMatcher)
- ->method('getOldValue')
- ->willReturn($oldUrl);
- $this->flagManagerMock->expects($saveFlagInvokeMatcher)
- ->method('saveFlag')
- ->with(BaseUrlConfigPlugin::OLD_BASE_URL_FLAG_CODE, $oldUrl);
-
- $this->configWriterMock->expects($saveConfigInvokeMatcher)->method('save')
- ->with(
- BaseUrlConfigPlugin::UPDATE_CRON_STRING_PATH,
- '0 * * * *'
- );
+ ->willReturn($configValueData['isValueChanged']);
+ $this->configValueMock
+ ->method('getPath')
+ ->willReturn($configValueData['path']);
+ $this->configValueMock
+ ->method('getScope')
+ ->willReturn($configValueData['scope']);
+ $this->subscriptionUpdateHandlerMock
+ ->expects($this->never())
+ ->method('processUrlUpdate');
$this->assertEquals(
$this->configValueMock,
@@ -127,64 +90,58 @@ public function testPluginForAfterSave(
/**
* @return array
*/
- public function pluginDataProvider()
+ public function afterSavePluginIsNotApplicableDataProvider()
{
return [
- 'setup_subscription_update_cron_job' => [
- 'testData' => [
- 'isValueChanged' => true,
- 'subscriptionStatus' => SubscriptionStatusProvider::ENABLED,
- 'path' => Store::XML_PATH_SECURE_BASE_URL
- ],
- 'saveConfigInvokeMatcher' => $this->once(),
- 'oldValueInvokeMatcher' => $this->once(),
- 'saveFlagInvokeMatcher' => $this->once(),
- 'configValueGetPathMatcher' => $this->once(),
- ],
- 'base_url_not_changed' => [
- 'testData' => [
+ 'Value has not been changed' => [
+ 'Config Value Data' => [
'isValueChanged' => false,
- 'subscriptionStatus' => SubscriptionStatusProvider::ENABLED,
- 'path' => Store::XML_PATH_SECURE_BASE_URL
+ 'path' => Store::XML_PATH_SECURE_BASE_URL,
+ 'scope' => ScopeConfigInterface::SCOPE_TYPE_DEFAULT
],
- 'saveConfigInvokeMatcher' => $this->never(),
- 'oldValueInvokeMatcher' => $this->never(),
- 'saveFlagInvokeMatcher' => $this->never(),
- 'configValueGetPathMatcher' => $this->never(),
],
- 'analytics_disabled' => [
- 'testData' => [
+ 'Unsecure URL has been changed' => [
+ 'Config Value Data' => [
'isValueChanged' => true,
- 'subscriptionStatus' => SubscriptionStatusProvider::DISABLED,
- 'path' => Store::XML_PATH_SECURE_BASE_URL
+ 'path' => Store::XML_PATH_UNSECURE_BASE_URL,
+ 'scope' => ScopeConfigInterface::SCOPE_TYPE_DEFAULT
],
- 'saveConfigInvokeMatcher' => $this->never(),
- 'oldValueInvokeMatcher' => $this->never(),
- 'saveFlagInvokeMatcher' => $this->never(),
- 'configValueGetPathMatcher' => $this->once(),
],
- 'analytics_pending' => [
- 'testData' => [
+ 'Secure URL has been changed not in the Default scope' => [
+ 'Config Value Data' => [
'isValueChanged' => true,
- 'subscriptionStatus' => SubscriptionStatusProvider::PENDING,
- 'path' => Store::XML_PATH_SECURE_BASE_URL
+ 'path' => Store::XML_PATH_SECURE_BASE_URL,
+ 'scope' => ScopeInterface::SCOPE_STORES
],
- 'saveConfigInvokeMatcher' => $this->never(),
- 'oldValueInvokeMatcher' => $this->never(),
- 'saveFlagInvokeMatcher' => $this->never(),
- 'configValueGetPathMatcher' => $this->once(),
],
- 'unsecure_url_changed' => [
- 'testData' => [
- 'isValueChanged' => true,
- 'subscriptionStatus' => SubscriptionStatusProvider::PENDING,
- 'path' => Store::XML_PATH_UNSECURE_BASE_URL
- ],
- 'saveConfigInvokeMatcher' => $this->never(),
- 'oldValueInvokeMatcher' => $this->never(),
- 'saveFlagInvokeMatcher' => $this->never(),
- 'configValueGetPathMatcher' => $this->once(),
- ]
];
}
+
+ /**
+ * @return void
+ */
+ public function testAfterSavePluginIsApplicable()
+ {
+ $this->configValueMock
+ ->method('isValueChanged')
+ ->willReturn(true);
+ $this->configValueMock
+ ->method('getPath')
+ ->willReturn(Store::XML_PATH_SECURE_BASE_URL);
+ $this->configValueMock
+ ->method('getScope')
+ ->willReturn(ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
+ $this->configValueMock
+ ->method('getOldValue')
+ ->willReturn('http://store.com');
+ $this->subscriptionUpdateHandlerMock
+ ->expects($this->once())
+ ->method('processUrlUpdate')
+ ->with('http://store.com');
+
+ $this->assertEquals(
+ $this->configValueMock,
+ $this->plugin->afterAfterSave($this->configValueMock, $this->configValueMock)
+ );
+ }
}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php
index 1be0524d72b7f..0607a977e5b68 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php
@@ -6,15 +6,18 @@
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\AnalyticsToken;
+use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Connector\OTPRequest;
+use Magento\Analytics\Model\Exception\State\SubscriptionUpdateException;
use Magento\Analytics\Model\ReportUrlProvider;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\FlagManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ReportUrlProviderTest extends \PHPUnit_Framework_TestCase
+class ReportUrlProviderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
@@ -31,6 +34,11 @@ class ReportUrlProviderTest extends \PHPUnit_Framework_TestCase
*/
private $otpRequestMock;
+ /**
+ * @var FlagManager|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $flagManagerMock;
+
/**
* @var ObjectManagerHelper
*/
@@ -63,6 +71,10 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
+ $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->reportUrlProvider = $this->objectManagerHelper->getObject(
@@ -71,6 +83,7 @@ protected function setUp()
'config' => $this->configMock,
'analyticsToken' => $this->analyticsTokenMock,
'otpRequest' => $this->otpRequestMock,
+ 'flagManager' => $this->flagManagerMock,
'urlReportConfigPath' => $this->urlReportConfigPath,
]
);
@@ -119,4 +132,18 @@ public function getUrlDataProvider()
'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab'],
];
}
+
+ /**
+ * @return void
+ */
+ public function testGetUrlWhenSubscriptionUpdateRunning()
+ {
+ $this->flagManagerMock
+ ->expects($this->once())
+ ->method('getFlagData')
+ ->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)
+ ->willReturn('http://store.com');
+ $this->expectException(SubscriptionUpdateException::class);
+ $this->reportUrlProvider->getUrl();
+ }
}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php
index 96ac1143ec5ec..d9b030b84d639 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php
@@ -16,7 +16,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ReportWriterTest extends \PHPUnit_Framework_TestCase
+class ReportWriterTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php
index 654fad74ef309..f314d77f32b41 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php
@@ -10,7 +10,7 @@
use Magento\Framework\Module\Manager as ModuleManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-class ModuleIteratorTest extends \PHPUnit_Framework_TestCase
+class ModuleIteratorTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ModuleManager|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/StoreConfigurationProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/StoreConfigurationProviderTest.php
index a2f9be1461c15..cc46d175543ad 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/StoreConfigurationProviderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/StoreConfigurationProviderTest.php
@@ -12,7 +12,7 @@
use Magento\Store\Api\Data\WebsiteInterface;
use Magento\Store\Model\StoreManagerInterface;
-class StoreConfigurationProviderTest extends \PHPUnit_Framework_TestCase
+class StoreConfigurationProviderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/SubscriptionStatusProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/SubscriptionStatusProviderTest.php
index 90707b2db7e1a..d6b041ce03178 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/SubscriptionStatusProviderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/SubscriptionStatusProviderTest.php
@@ -6,6 +6,7 @@
namespace Magento\Analytics\Test\Unit\Model;
use Magento\Analytics\Model\AnalyticsToken;
+use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Analytics\Model\SubscriptionStatusProvider;
use Magento\Framework\App\Config\ScopeConfigInterface;
@@ -15,7 +16,7 @@
/**
* Class SubscriptionStatusProviderTest.
*/
-class SubscriptionStatusProviderTest extends \PHPUnit_Framework_TestCase
+class SubscriptionStatusProviderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
@@ -70,7 +71,11 @@ protected function setUp()
);
}
- public function testGetStatusShouldBeFailed()
+ /**
+ * @param array $flagManagerData
+ * @dataProvider getStatusShouldBeFailedDataProvider
+ */
+ public function testGetStatusShouldBeFailed(array $flagManagerData)
{
$this->analyticsTokenMock->expects($this->once())
->method('isTokenExist')
@@ -80,26 +85,86 @@ public function testGetStatusShouldBeFailed()
->with('analytics/subscription/enabled')
->willReturn(true);
- $this->expectFlagCounterReturn(null);
+ $this->expectFlagManagerReturn($flagManagerData);
$this->assertEquals(SubscriptionStatusProvider::FAILED, $this->statusProvider->getStatus());
}
- public function testGetStatusShouldBePending()
+ /**
+ * @return array
+ */
+ public function getStatusShouldBeFailedDataProvider()
+ {
+ return [
+ 'Subscription update doesn\'t active' => [
+ 'Flag Manager data mapping' => [
+ [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, null],
+ [SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, null]
+ ],
+ ],
+ 'Subscription update is active' => [
+ 'Flag Manager data mapping' => [
+ [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, 'http://store.com'],
+ [SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, null]
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * @param array $flagManagerData
+ * @param bool $isTokenExist
+ * @dataProvider getStatusShouldBePendingDataProvider
+ */
+ public function testGetStatusShouldBePending(array $flagManagerData, bool $isTokenExist)
{
$this->analyticsTokenMock->expects($this->once())
->method('isTokenExist')
- ->willReturn(false);
+ ->willReturn($isTokenExist);
$this->scopeConfigMock->expects($this->once())
->method('getValue')
->with('analytics/subscription/enabled')
->willReturn(true);
- $this->expectFlagCounterReturn(45);
+ $this->expectFlagManagerReturn($flagManagerData);
$this->assertEquals(SubscriptionStatusProvider::PENDING, $this->statusProvider->getStatus());
}
+ /**
+ * @return array
+ */
+ public function getStatusShouldBePendingDataProvider()
+ {
+ return [
+ 'Subscription update doesn\'t active and the token does not exist' => [
+ 'Flag Manager data mapping' => [
+ [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, null],
+ [SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, 45]
+ ],
+ 'isTokenExist' => false,
+ ],
+ 'Subscription update is active and the token does not exist' => [
+ 'Flag Manager data mapping' => [
+ [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, 'http://store.com'],
+ [SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, 45]
+ ],
+ 'isTokenExist' => false,
+ ],
+ 'Subscription update is active and token exist' => [
+ 'Flag Manager data mapping' => [
+ [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, 'http://store.com'],
+ [SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, null]
+ ],
+ 'isTokenExist' => true,
+ ],
+ ];
+ }
+
public function testGetStatusShouldBeEnabled()
{
+ $this->flagManagerMock
+ ->method('getFlagData')
+ ->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)
+ ->willReturn(null);
$this->analyticsTokenMock->expects($this->once())
->method('isTokenExist')
->willReturn(true);
@@ -120,15 +185,12 @@ public function testGetStatusShouldBeDisabled()
}
/**
- * @param null|int $value
+ * @param array $mapping
*/
- private function expectFlagCounterReturn($value)
+ private function expectFlagManagerReturn(array $mapping)
{
- $this->flagManagerMock->expects($this->once())->method('getFlagData')
- ->willReturnMap(
- [
- [SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, $value],
- ]
- );
+ $this->flagManagerMock
+ ->method('getFlagData')
+ ->willReturnMap($mapping);
}
}
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/System/Message/NotificationAboutFailedSubscriptionTest.php b/app/code/Magento/Analytics/Test/Unit/Model/System/Message/NotificationAboutFailedSubscriptionTest.php
index 536a7dbb5dfe9..ad1d87488d751 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/System/Message/NotificationAboutFailedSubscriptionTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/System/Message/NotificationAboutFailedSubscriptionTest.php
@@ -13,7 +13,7 @@
/**
* Class NotificationAboutFailedSubscriptionTest
*/
-class NotificationAboutFailedSubscriptionTest extends \PHPUnit_Framework_TestCase
+class NotificationAboutFailedSubscriptionTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject|SubscriptionStatusProvider
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/Converter/XmlTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/Converter/XmlTest.php
index 325d3d4a85c7e..3f1ed9a5cf4c0 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/Converter/XmlTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/Converter/XmlTest.php
@@ -8,7 +8,7 @@
/**
* A unit test for testing of the reports configuration converter (XML to PHP array).
*/
-class XmlTest extends \PHPUnit_Framework_TestCase
+class XmlTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Analytics\ReportXml\Config\Converter\Xml
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/MapperTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/MapperTest.php
index f69b40118b935..85343b6b301d6 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/MapperTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/MapperTest.php
@@ -10,7 +10,7 @@
/**
* Class MapperTest
*/
-class MapperTest extends \PHPUnit_Framework_TestCase
+class MapperTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Mapper
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/SchemaLocatorTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/SchemaLocatorTest.php
deleted file mode 100644
index 2b327b2291864..0000000000000
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/SchemaLocatorTest.php
+++ /dev/null
@@ -1,74 +0,0 @@
-urnResolverMock = $this->getMockBuilder(UrnResolver::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->objectManagerHelper = new ObjectManagerHelper($this);
-
- $this->schemaLocator = $this->objectManagerHelper->getObject(
- SchemaLocator::class,
- [
- 'urnResolver' => $this->urnResolverMock,
- 'realPath' => $this->examplePath,
- ]
- );
- }
-
- public function testGetSchema()
- {
- $schema = 'schema';
-
- $this->urnResolverMock
- ->expects($this->once())
- ->method('getRealPath')
- ->with($this->examplePath)
- ->willReturn($schema);
-
- $this->assertSame($schema, $this->schemaLocator->getSchema());
- }
-
- public function testGetPerFileSchema()
- {
- $this->assertNull($this->schemaLocator->getPerFileSchema());
- }
-}
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConfigTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/ConfigTest.php
index 7d40fad528b5f..cbc9aa129d874 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConfigTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/ConfigTest.php
@@ -6,16 +6,16 @@
namespace Magento\Analytics\Test\Unit\ReportXml;
use Magento\Analytics\ReportXml\Config;
-use Magento\Analytics\ReportXml\Config\Data;
+use Magento\Framework\Config\DataInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
/**
* Class ConfigTest
*/
-class ConfigTest extends \PHPUnit_Framework_TestCase
+class ConfigTest extends \PHPUnit\Framework\TestCase
{
/**
- * @var Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var DataInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $dataMock;
@@ -34,7 +34,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
- $this->dataMock = $this->getMockBuilder(Data::class)
+ $this->dataMock = $this->getMockBuilder(DataInterface::class)
->disableOriginalConstructor()
->getMock();
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConnectionFactoryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/ConnectionFactoryTest.php
index 330f7f1a6707a..1e4ae9142c13d 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConnectionFactoryTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/ConnectionFactoryTest.php
@@ -15,7 +15,7 @@
/**
* Class ConnectionFactoryTest
*/
-class ConnectionFactoryTest extends \PHPUnit_Framework_TestCase
+class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FilterAssemblerTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FilterAssemblerTest.php
index 6ebfd1ffa2da6..3b01105a8873b 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FilterAssemblerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FilterAssemblerTest.php
@@ -8,7 +8,7 @@
/**
* A unit test for testing of the 'filter' assembler.
*/
-class FilterAssemblerTest extends \PHPUnit_Framework_TestCase
+class FilterAssemblerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Analytics\ReportXml\DB\Assembler\FilterAssembler
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FromAssemblerTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FromAssemblerTest.php
index cbabac5613a8b..575db94a7b7e1 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FromAssemblerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FromAssemblerTest.php
@@ -10,7 +10,7 @@
/**
* A unit test for testing of the 'from' assembler.
*/
-class FromAssemblerTest extends \PHPUnit_Framework_TestCase
+class FromAssemblerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Analytics\ReportXml\DB\Assembler\FromAssembler
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php
index b913689513ce5..aaafd731552a0 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php
@@ -10,7 +10,7 @@
/**
* A unit test for testing of the 'join' assembler.
*/
-class JoinAssemblerTest extends \PHPUnit_Framework_TestCase
+class JoinAssemblerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Analytics\ReportXml\DB\Assembler\JoinAssembler
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php
index dd004a11db02d..bdbe3d1d22c22 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php
@@ -9,17 +9,15 @@
use Magento\Analytics\ReportXml\DB\NameResolver;
use Magento\Analytics\ReportXml\DB\SelectBuilder;
use Magento\Framework\DB\Sql\ColumnValueExpression;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
/**
* Class ColumnsResolverTest
*/
-class ColumnsResolverTest extends \PHPUnit_Framework_TestCase
+class ColumnsResolverTest extends \PHPUnit\Framework\TestCase
{
- /**
- * @var NameResolver|\PHPUnit_Framework_MockObject_MockObject
- */
- private $nameResolverMock;
-
/**
* @var SelectBuilder|\PHPUnit_Framework_MockObject_MockObject
*/
@@ -30,20 +28,41 @@ class ColumnsResolverTest extends \PHPUnit_Framework_TestCase
*/
private $columnsResolver;
+ /**
+ * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $resourceConnectionMock;
+
+ /**
+ * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $connectionMock;
+
/**
* @return void
*/
protected function setUp()
{
- $this->nameResolverMock = $this->getMockBuilder(NameResolver::class)
+ $this->selectBuilderMock = $this->getMockBuilder(SelectBuilder::class)
->disableOriginalConstructor()
->getMock();
- $this->selectBuilderMock = $this->getMockBuilder(SelectBuilder::class)
+ $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
->disableOriginalConstructor()
->getMock();
- $this->columnsResolver = new ColumnsResolver($this->nameResolverMock);
+ $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $objectManager = new ObjectManagerHelper($this);
+ $this->columnsResolver = $objectManager->getObject(
+ ColumnsResolver::class,
+ [
+ 'nameResolver' => new NameResolver(),
+ 'resourceConnection' => $this->resourceConnectionMock
+ ]
+ );
}
public function testGetColumnsWithoutAttributes()
@@ -54,41 +73,30 @@ public function testGetColumnsWithoutAttributes()
/**
* @dataProvider getColumnsDataProvider
*/
- public function testGetColumns($expression, $attributeData)
+ public function testGetColumnsWithFunction($expectedColumns, $expectedGroup, $entityConfig)
{
- $columnAlias = 'fn';
- $expr = new ColumnValueExpression($expression);
- $expectedResult = [$columnAlias => $expr];
- $columns = [$columnAlias => 'name'];
- $entityConfig['attribute'] = ['attribute1' => $attributeData];
+ $this->resourceConnectionMock->expects($this->any())
+ ->method('getConnection')
+ ->willReturn($this->connectionMock);
+ $this->connectionMock->expects($this->any())
+ ->method('quoteIdentifier')
+ ->with('cpe.name')
+ ->willReturn('`cpe`.`name`');
$this->selectBuilderMock->expects($this->once())
->method('getColumns')
- ->willReturn($columns);
- $this->nameResolverMock->expects($this->at(0))
- ->method('getAlias')
- ->with($attributeData)
- ->willReturn($columnAlias);
- $this->nameResolverMock->expects($this->at(1))
- ->method('getAlias')
- ->with($entityConfig)
- ->willReturn($columnAlias);
- $this->nameResolverMock->expects($this->once())
- ->method('getName')
- ->with($attributeData)
- ->willReturn('name');
- $group = ['g'];
+ ->willReturn([]);
$this->selectBuilderMock->expects($this->once())
->method('getGroup')
- ->willReturn($group);
+ ->willReturn([]);
$this->selectBuilderMock->expects($this->once())
->method('setGroup')
- ->with(array_merge($group, $expectedResult));
+ ->with($expectedGroup);
$this->assertEquals(
+ $expectedColumns,
$this->columnsResolver->getColumns(
$this->selectBuilderMock,
$entityConfig
- ),
- $expectedResult
+ )
);
}
@@ -98,14 +106,45 @@ public function testGetColumns($expression, $attributeData)
public function getColumnsDataProvider()
{
return [
- 'TestWithFunction' => [
- 'expression' => "SUM( DISTINCT fn.name)",
- 'attributeData' => ['adata1', 'function' => 'SUM', 'distinct' => true, 'group' => true],
+ 'COUNT( DISTINCT `cpe`.`name`) AS name' => [
+ 'expectedColumns' => [
+ 'name' => new ColumnValueExpression('COUNT( DISTINCT `cpe`.`name`)')
+ ],
+ 'expectedGroup' => [
+ 'name' => new ColumnValueExpression('COUNT( DISTINCT `cpe`.`name`)')
+ ],
+ 'entityConfig' =>
+ [
+ 'name' => 'catalog_product_entity',
+ 'alias' => 'cpe',
+ 'attribute' => [
+ [
+ 'name' => 'name',
+ 'function' => 'COUNT',
+ 'distinct' => true,
+ 'group' => true
+ ]
+ ],
+ ],
+ ],
+ 'AVG(`cpe`.`name`) AS avg_name' => [
+ 'expectedColumns' => [
+ 'avg_name' => new ColumnValueExpression('AVG(`cpe`.`name`)')
],
- 'TestWithoutFunction' => [
- 'expression' => "fn.name",
- 'attributeData' => ['adata1', 'distinct' => true, 'group' => true],
- ],
+ 'expectedGroup' => [],
+ 'entityConfig' =>
+ [
+ 'name' => 'catalog_product_entity',
+ 'alias' => 'cpe',
+ 'attribute' => [
+ [
+ 'name' => 'name',
+ 'alias' => 'avg_name',
+ 'function' => 'AVG',
+ ]
+ ],
+ ],
+ ]
];
}
}
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php
index 3ec33af531c91..c8182d068fba5 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php
@@ -14,7 +14,7 @@
/**
* Class ConditionResolverTest
*/
-class ConditionResolverTest extends \PHPUnit_Framework_TestCase
+class ConditionResolverTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
@@ -62,7 +62,7 @@ public function testGetFilter()
$valueCondition = ["type" => "value", "_value" => "2", "attribute" => "first_name", "operator" => "eq"];
$identifierCondition = [
"type" => "identifier",
- "_value" => "3",
+ "_value" => "other_field",
"attribute" => "last_name",
"operator" => "eq"];
$filter = [["glue" => "AND", "condition" => [$valueCondition]]];
@@ -90,14 +90,19 @@ public function testGetFilter()
$this->connectionMock->expects($this->any())
->method('quote')
->willReturn("'John'");
-
- $this->connectionMock->expects($this->once())
+ $this->connectionMock->expects($this->exactly(4))
->method('quoteIdentifier')
- ->willReturn("'Smith'");
- $result = "(n.id != 1 OR ((n.first_name = 'John'))) AND (n.last_name = 'Smith')";
+ ->willReturnMap([
+ ['n.id', false, '`n`.`id`'],
+ ['n.first_name', false, '`n`.`first_name`'],
+ ['n.last_name', false, '`n`.`last_name`'],
+ ['other_field', false, '`other_field`'],
+ ]);
+
+ $result = "(`n`.`id` != 1 OR ((`n`.`first_name` = 'John'))) OR (`n`.`last_name` = `other_field`)";
$this->assertEquals(
- $this->conditionResolver->getFilter($this->selectBuilderMock, $filterConfig, $aliasName),
- $result
+ $result,
+ $this->conditionResolver->getFilter($this->selectBuilderMock, $filterConfig, $aliasName)
);
}
}
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/NameResolverTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/NameResolverTest.php
index ef051feda0722..4accd03aef3ea 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/NameResolverTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/NameResolverTest.php
@@ -11,7 +11,7 @@
/**
* Class NameResolverTest
*/
-class NameResolverTest extends \PHPUnit_Framework_TestCase
+class NameResolverTest extends \PHPUnit\Framework\TestCase
{
/**
* @var NameResolver|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php
index fad0a80856b70..bbb9ca4b511b6 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php
@@ -16,7 +16,7 @@
/**
* Class ReportValidatorTest
*/
-class ReportValidatorTest extends \PHPUnit_Framework_TestCase
+class ReportValidatorTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ConnectionFactory|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php
index fb8f5b4a1ff0e..a82a187cdb3f8 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php
@@ -13,7 +13,7 @@
/**
* Class SelectBuilderTest
*/
-class SelectBuilderTest extends \PHPUnit_Framework_TestCase
+class SelectBuilderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var SelectBuilder
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/IteratorFactoryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/IteratorFactoryTest.php
index 38abc3683f81f..1d3f293ed676a 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/IteratorFactoryTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/IteratorFactoryTest.php
@@ -11,7 +11,7 @@
/**
* Class IteratorFactoryTest
*/
-class IteratorFactoryTest extends \PHPUnit_Framework_TestCase
+class IteratorFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php
index e358bf00fe37a..9a3805a50f167 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php
@@ -8,7 +8,7 @@
/**
* A unit test for testing of the query factory.
*/
-class QueryFactoryTest extends \PHPUnit_Framework_TestCase
+class QueryFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Analytics\ReportXml\QueryFactory
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php
index e288c668a54f7..a4b08a9ce5e0a 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php
@@ -13,7 +13,7 @@
/**
* Class QueryTest
*/
-class QueryTest extends \PHPUnit_Framework_TestCase
+class QueryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Select|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/ReportProviderTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/ReportProviderTest.php
index 124d5f32078c8..5f329993dd291 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/ReportProviderTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/ReportProviderTest.php
@@ -8,7 +8,7 @@
/**
* A unit test for testing of the reports provider.
*/
-class ReportProviderTest extends \PHPUnit_Framework_TestCase
+class ReportProviderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Analytics\ReportXml\ReportProvider
diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php
index dce8089a787dc..ce57a1eca3689 100644
--- a/app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php
@@ -16,7 +16,7 @@
/**
* Class SelectHydratorTest
*/
-class SelectHydratorTest extends \PHPUnit_Framework_TestCase
+class SelectHydratorTest extends \PHPUnit\Framework\TestCase
{
/**
* @var SelectHydrator
diff --git a/app/code/Magento/Analytics/Test/Unit/Ui/DataProvider/DummyDataProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Ui/DataProvider/DummyDataProviderTest.php
deleted file mode 100644
index 94f6ed1845c40..0000000000000
--- a/app/code/Magento/Analytics/Test/Unit/Ui/DataProvider/DummyDataProviderTest.php
+++ /dev/null
@@ -1,228 +0,0 @@
- 'value'];
-
- /**
- * @return void
- */
- protected function setUp()
- {
- $this->searchResultMock = $this->getMockBuilder(SearchResultInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->searchCriteriaMock = $this->getMockBuilder(SearchCriteriaInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->dataCollectionMock = $this->getMockBuilder(Collection::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->filterMock = $this->getMockBuilder(Filter::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->objectManagerHelper = new ObjectManagerHelper($this);
-
- $this->dummyDataProvider = $this->objectManagerHelper->getObject(
- DummyDataProvider::class,
- [
- 'name' => $this->providerName,
- 'searchResult' => $this->searchResultMock,
- 'searchCriteria' => $this->searchCriteriaMock,
- 'collection' => $this->dataCollectionMock,
- 'data' => ['config' => $this->configData],
- ]
- );
- }
-
- /**
- * @return void
- */
- public function testGetName()
- {
- $this->assertSame($this->providerName, $this->dummyDataProvider->getName());
- }
-
- /**
- * @return void
- */
- public function testGetConfigData()
- {
- $this->assertSame($this->configData, $this->dummyDataProvider->getConfigData());
- $dataProvider = $this->objectManagerHelper
- ->getObject(
- DummyDataProvider::class,
- []
- );
- $this->assertSame([], $dataProvider->getConfigData());
- }
-
- /**
- * @return void
- */
- public function testSetConfigData()
- {
- $configValue = ['key' => 'value'];
-
- $this->assertTrue($this->dummyDataProvider->setConfigData($configValue));
- $this->assertSame($configValue, $this->dummyDataProvider->getConfigData());
- }
-
- /**
- * @return void
- */
- public function testGetMeta()
- {
- $this->assertSame([], $this->dummyDataProvider->getMeta());
- }
-
- /**
- * @return void
- */
- public function testGetFieldMetaInfo()
- {
- $this->assertSame([], $this->dummyDataProvider->getFieldMetaInfo('', ''));
- }
-
- /**
- * @return void
- */
- public function testGetFieldSetMetaInfo()
- {
- $this->assertSame([], $this->dummyDataProvider->getFieldSetMetaInfo(''));
- }
-
- /**
- * @return void
- */
- public function testGetFieldsMetaInfo()
- {
- $this->assertSame([], $this->dummyDataProvider->getFieldsMetaInfo(''));
- }
-
- /**
- * @return void
- */
- public function testGetPrimaryFieldName()
- {
- $this->assertSame('', $this->dummyDataProvider->getPrimaryFieldName());
- }
-
- /**
- * @return void
- */
- public function testGetRequestFieldName()
- {
- $this->assertSame('', $this->dummyDataProvider->getRequestFieldName());
- }
-
- /**
- * @return void
- */
- public function testGetData()
- {
- $this->dataCollectionMock
- ->expects($this->once())
- ->method('toArray')
- ->willReturn([]);
- $this->assertSame([], $this->dummyDataProvider->getData());
- }
-
- /**
- * @return void
- */
- public function testAddFilter()
- {
- $this->assertNull($this->dummyDataProvider->addFilter($this->filterMock));
- }
-
- /**
- * @return void
- */
- public function testAddOrder()
- {
- $this->assertNull($this->dummyDataProvider->addOrder('', ''));
- }
-
- /**
- * @return void
- */
- public function testSetLimit()
- {
- $this->assertNull($this->dummyDataProvider->setLimit(1, 1));
- }
-
- /**
- * @return void
- */
- public function testGetSearchCriteria()
- {
- $this->assertSame($this->searchCriteriaMock, $this->dummyDataProvider->getSearchCriteria());
- }
-
- /**
- * @return void
- */
- public function testGetSearchResult()
- {
- $this->assertSame($this->searchResultMock, $this->dummyDataProvider->getSearchResult());
- }
-}
diff --git a/app/code/Magento/Analytics/composer.json b/app/code/Magento/Analytics/composer.json
index edc3443e487b6..b17bb10cb4112 100644
--- a/app/code/Magento/Analytics/composer.json
+++ b/app/code/Magento/Analytics/composer.json
@@ -10,7 +10,7 @@
"magento/framework": "100.2.*"
},
"type": "magento2-module",
- "version": "100.2.0-dev",
+ "version": "100.2.0",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/Analytics/docs/images/M2_MA_signup.png b/app/code/Magento/Analytics/docs/images/M2_MA_signup.png
new file mode 100644
index 0000000000000..78ed8fad92881
Binary files /dev/null and b/app/code/Magento/Analytics/docs/images/M2_MA_signup.png differ
diff --git a/app/code/Magento/Analytics/docs/images/analytics_modules.png b/app/code/Magento/Analytics/docs/images/analytics_modules.png
new file mode 100644
index 0000000000000..0bf6048b0d9cc
Binary files /dev/null and b/app/code/Magento/Analytics/docs/images/analytics_modules.png differ
diff --git a/app/code/Magento/Analytics/docs/images/data_transition.png b/app/code/Magento/Analytics/docs/images/data_transition.png
new file mode 100644
index 0000000000000..a75e97983e15d
Binary files /dev/null and b/app/code/Magento/Analytics/docs/images/data_transition.png differ
diff --git a/app/code/Magento/Analytics/docs/images/definition.png b/app/code/Magento/Analytics/docs/images/definition.png
new file mode 100644
index 0000000000000..16acc576320b0
Binary files /dev/null and b/app/code/Magento/Analytics/docs/images/definition.png differ
diff --git a/app/code/Magento/Analytics/docs/images/mbi_file_exchange.png b/app/code/Magento/Analytics/docs/images/mbi_file_exchange.png
new file mode 100644
index 0000000000000..f39d2e4900703
Binary files /dev/null and b/app/code/Magento/Analytics/docs/images/mbi_file_exchange.png differ
diff --git a/app/code/Magento/Analytics/docs/images/signup.png b/app/code/Magento/Analytics/docs/images/signup.png
new file mode 100644
index 0000000000000..561e18b3a351f
Binary files /dev/null and b/app/code/Magento/Analytics/docs/images/signup.png differ
diff --git a/app/code/Magento/Analytics/docs/images/update.png b/app/code/Magento/Analytics/docs/images/update.png
new file mode 100644
index 0000000000000..149f5b5d3f9bd
Binary files /dev/null and b/app/code/Magento/Analytics/docs/images/update.png differ
diff --git a/app/code/Magento/Analytics/docs/images/update_request.png b/app/code/Magento/Analytics/docs/images/update_request.png
new file mode 100644
index 0000000000000..7181251e3634e
Binary files /dev/null and b/app/code/Magento/Analytics/docs/images/update_request.png differ
diff --git a/app/code/Magento/Analytics/etc/adminhtml/system.xml b/app/code/Magento/Analytics/etc/adminhtml/system.xml
index 32d493451ca61..889517e629e04 100644
--- a/app/code/Magento/Analytics/etc/adminhtml/system.xml
+++ b/app/code/Magento/Analytics/etc/adminhtml/system.xml
@@ -13,10 +13,10 @@
Magento_Analytics::analytics_settings
- For more information, view details or see our
- terms and conditions.]]>
+ For more information, see our
+ terms and conditions.]]>Magento\Config\Model\Config\Source\Enabledisable
@@ -24,21 +24,24 @@
Magento\Analytics\Block\Adminhtml\System\Config\SubscriptionStatusLabelanalytics/subscription/enabled
-
-
- Magento\Analytics\Model\Config\Source\Vertical
- Magento\Analytics\Model\Config\Backend\Vertical
-
-
+ Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabelMagento\Analytics\Model\Config\Backend\CollectionTime
-
+
+ Industry Data
+
+ In order to personalize your Advanced Reporting experience, please select your industry.
+ Magento\Analytics\Model\Config\Source\Vertical
+ Magento\Analytics\Model\Config\Backend\Vertical
+ Magento\Analytics\Block\Adminhtml\System\Config\Vertical
+
+ Learn more about BI Essentials tier.]]>
+ href="https://dashboard.rjmetrics.com/v2/magento/signup/">Magento BI Essentials and BI Pro tiers.]]>
Magento\Analytics\Block\Adminhtml\System\Config\AdditionalComment
diff --git a/app/code/Magento/Analytics/etc/di.xml b/app/code/Magento/Analytics/etc/di.xml
index ccaaadd0856a9..56657b58475d3 100644
--- a/app/code/Magento/Analytics/etc/di.xml
+++ b/app/code/Magento/Analytics/etc/di.xml
@@ -23,11 +23,62 @@
-
+
+
- Magento\Config\Model\ResourceModel\Config\Data
+ Magento\Analytics\ReportXml\Config\Data
+
+
+ Magento\Analytics\ReportXml\Config\Reader
+ Magento_Analytics_ReportXml_CacheId
+
+
+
+
+ urn:magento:module:Magento_Analytics:etc/reports.xsd
+
+
+
+
+ Magento\Analytics\ReportXml\Config\Converter\Xml
+ Magento\Analytics\ReportXml\Config\SchemaLocator
+ reports.xml
+
+ name
+
+ name
+ alias
+
+ name
+ name
+
+ glue
+
+ attribute
+ operator
+
+
+ glue
+
+ attribute
+ operator
+
+
+ glue
+
+ attribute
+ operator
+
+ glue
+
+ attribute
+ operator
+
+
+
+
@@ -35,6 +86,34 @@
+
+
+
+ Magento\Analytics\Model\Config\Data
+
+
+
+
+ Magento\Analytics\Model\Config\Reader
+ Magento_Analytics_CacheId
+
+
+
+
+ urn:magento:module:Magento_Analytics:etc/analytics.xsd
+
+
+
+
+ Magento\Analytics\ReportXml\Config\Converter\Xml
+ Magento\Analytics\Model\Config\SchemaLocator
+ analytics.xml
+
+ name
+
+
+
+
@@ -51,22 +130,6 @@
-
-
- Magento\Analytics\Model\Config\Data
-
-
-
-
- Magento\Analytics\Model\Config\SchemaLocator
- Magento\Analytics\ReportXml\Config\Converter\Xml
-
-
-
-
- Magento\Analytics\Model\Config\Reader
-
-
@@ -113,28 +176,28 @@
- Apps and Games
- Athletic/Sporting Goods
- Art and Design
- Auto Parts
- Baby/Children’s Apparel, Gear and Toys
- Beauty and Cosmetics
- Books, Music and Magazines
- Crafts and Stationery
- Consumer Electronics
- Deal Site
- Fashion Apparel and Accessories
- Food, Beverage and Grocery
- Home Goods and Furniture
- Home Improvement
- Jewelry and Watches
- Mass Merchant
- Office Supplies
- Outdoor and Camping Gear
- Pet Goods
- Pharma and Medical Devices
- Technology B2B
- Other
+ Apps and Games
+ Athletic/Sporting Goods
+ Art and Design
+ Auto Parts
+ Baby/Children’s Apparel, Gear and Toys
+ Beauty and Cosmetics
+ Books, Music and Magazines
+ Crafts and Stationery
+ Consumer Electronics
+ Deal Site
+ Fashion Apparel and Accessories
+ Food, Beverage and Grocery
+ Home Goods and Furniture
+ Home Improvement
+ Jewelry and Watches
+ Mass Merchant
+ Office Supplies
+ Outdoor and Camping Gear
+ Pet Goods
+ Pharma and Medical Devices
+ Technology B2B
+ Other
diff --git a/app/code/Magento/Analytics/i18n/en_US.csv b/app/code/Magento/Analytics/i18n/en_US.csv
new file mode 100644
index 0000000000000..516c388feb823
--- /dev/null
+++ b/app/code/Magento/Analytics/i18n/en_US.csv
@@ -0,0 +1,84 @@
+"Subscription status","Subscription status"
+"Sorry, there has been an error processing your request. Please try again later.","Sorry, there has been an error processing your request. Please try again later."
+"Sorry, there was an error processing your registration request to Magento Analytics. Please try again later.","Sorry, there was an error processing your registration request to Magento Analytics. Please try again later."
+"Error occurred during postponement notification","Error occurred during postponement notification"
+"Time value has an unsupported format","Time value has an unsupported format"
+"Cron settings can't be saved","Cron settings can't be saved"
+"There was an error save new configuration value.","There was an error save new configuration value."
+"Please select a vertical.","Please select a vertical."
+"--Please Select--","--Please Select--"
+"Command was not found.","Command was not found."
+"Input data must be string or convertible into string.","Input data must be string or convertible into string."
+"Input data must be non-empty string.","Input data must be non-empty string."
+"Not valid cipher method.","Not valid cipher method."
+"Encryption key can't be empty.","Encryption key can't be empty."
+"Source ""%1"" is not exist","Source ""%1"" is not exist"
+"These arguments can't be empty ""%1""","These arguments can't be empty ""%1"""
+"Cannot find predefined integration user!","Cannot find predefined integration user!"
+"File is not ready yet.","File is not ready yet."
+"Your Base URL has been changed and your reports are being updated. Advanced Reporting will be available once this change has been processed. Please try again later.","Your Base URL has been changed and your reports are being updated. Advanced Reporting will be available once this change has been processed. Please try again later."
+"Failed to synchronize data to the Magento Business Intelligence service. ","Failed to synchronize data to the Magento Business Intelligence service. "
+"Retry Synchronization","Retry Synchronization"
+TestMessage,TestMessage
+"Error message","Error message"
+"Apps and Games","Apps and Games"
+"Athletic/Sporting Goods","Athletic/Sporting Goods"
+"Art and Design","Art and Design"
+"Advanced Reporting","Advanced Reporting"
+"Gain new insights and take command of your business' performance, using our dynamic product, order, and customer reports tailored to your customer data.","Gain new insights and take command of your business' performance, using our dynamic product, order, and customer reports tailored to your customer data."
+"View details","View details"
+"Go to Advanced Reporting","Go to Advanced Reporting"
+"An error occurred while subscription process.","An error occurred while subscription process."
+Analytics,Analytics
+API,API
+Configuration,Configuration
+"Business Intelligence","Business Intelligence"
+"BI Essentials","BI Essentials"
+"This service provides a dynamic suite of reports with rich insights about your business.
+ Your reports can be accessed securely on a personalized dashboard outside of the admin panel by clicking on the
+ ""Go to Advanced Reporting"" link. For more information, see our
+ terms and conditions.
+ ","This service provides a dynamic suite of reports with rich insights about your business.
+ Your reports can be accessed securely on a personalized dashboard outside of the admin panel by clicking on the
+ ""Go to Advanced Reporting"" link. For more information, see our
+ terms and conditions."
+"Advanced Reporting Service","Advanced Reporting Service"
+Industry,Industry
+"Time of day to send data","Time of day to send data"
+"Get more insights from Magento Business Intelligence","Get more insights from Magento Business Intelligence"
+"Magento Business Intelligence provides you with a simple and clear path to
+ becoming more data driven. Learn more about BI Essentials tier.","Magento Business Intelligence provides you with a simple and clear path to
+ becoming more data driven. Learn more about BI Essentials tier."
+"Auto Parts","Auto Parts"
+"Baby/Children’s Apparel, Gear and Toys","Baby/Children’s Apparel, Gear and Toys"
+"Beauty and Cosmetics","Beauty and Cosmetics"
+"Books, Music and Magazines","Books, Music and Magazines"
+"Crafts and Stationery","Crafts and Stationery"
+"Consumer Electronics","Consumer Electronics"
+"Deal Site","Deal Site"
+"Fashion Apparel and Accessories","Fashion Apparel and Accessories"
+"Food, Beverage and Grocery","Food, Beverage and Grocery"
+"Home Goods and Furniture","Home Goods and Furniture"
+"Home Improvement","Home Improvement"
+"Jewelry and Watches","Jewelry and Watches"
+"Mass Merchant","Mass Merchant"
+"Office Supplies","Office Supplies"
+"Outdoor and Camping Gear","Outdoor and Camping Gear"
+"Pet Goods","Pet Goods"
+"Pharma and Medical Devices","Pharma and Medical Devices"
+"Technology B2B","Technology B2B"
+"Analytics Subscription","Analytics Subscription"
+"powered by Magento Business Intelligence","powered by Magento Business Intelligence"
+"Are you sure you want to opt out?","Are you sure you want to opt out?"
+Cancel,Cancel
+"Opt out","Opt out"
+"
Advanced Reporting in included,
+ free of charge, in your Magento software. When you opt out, we collect no product, order, and
+ customer data to generate our dynamic reports.
To opt in later: You can always turn on Advanced
+ Reporting in you Admin Panel.
","
Advanced Reporting in included,
+ free of charge, in your Magento software. When you opt out, we collect no product, order, and
+ customer data to generate our dynamic reports.
To opt in later: You can always turn on Advanced
+ Reporting in you Admin Panel.
"
+"In order to personalize your Advanced Reporting experience, please select your industry.","In order to personalize your Advanced Reporting experience, please select your industry."
diff --git a/app/code/Magento/Analytics/view/adminhtml/layout/adminhtml_dashboard_index.xml b/app/code/Magento/Analytics/view/adminhtml/layout/adminhtml_dashboard_index.xml
index 42cf4f937958b..545098de52dcc 100644
--- a/app/code/Magento/Analytics/view/adminhtml/layout/adminhtml_dashboard_index.xml
+++ b/app/code/Magento/Analytics/view/adminhtml/layout/adminhtml_dashboard_index.xml
@@ -9,9 +9,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
-
-
-
- escapeHtml(__('Gain new insights and take command of your business\' performance,' .
+ = $block->escapeHtml(__('Gain new insights and take command of your business\' performance,' .
' using our dynamic product, order, and customer reports tailored to your customer data.')) ?>
-
- escapeHtml(__('View details')) ?>
-