Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin > Advanced Report > Changing link #25412

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/code/Magento/Analytics/Model/ReportUrlProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ class ReportUrlProvider
*/
private $urlReportConfigPath = 'analytics/url/report';

/**
* Path to Advanced Reporting documentation URL.
*
* @var string
*/
private $urlReportDocConfigPath = 'analytics/url/documentation';

/**
* @param AnalyticsToken $analyticsToken
* @param OTPRequest $otpRequest
Expand Down Expand Up @@ -80,13 +87,15 @@ public function getUrl()
));
}

$url = $this->config->getValue($this->urlReportConfigPath);
if ($this->analyticsToken->isTokenExist()) {
$url = $this->config->getValue($this->urlReportConfigPath);
$otp = $this->otpRequest->call();
if ($otp) {
$query = http_build_query(['otp' => $otp], '', '&');
$url .= '?' . $query;
}
} else {
$url = $this->config->getValue($this->urlReportDocConfigPath);
}

return $url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class ReportUrlProviderTest extends TestCase
*/
private $urlReportConfigPath = 'path/url/report';

/**
* @var string
*/
private $urlReportDocConfigPath = 'analytics/url/documentation';

/**
* @return void
*/
Expand All @@ -83,12 +88,24 @@ protected function setUp(): void
'urlReportConfigPath' => $this->urlReportConfigPath,
]
);

$this->reportUrlProvider = $this->objectManagerHelper->getObject(
ReportUrlProvider::class,
[
'config' => $this->configMock,
'analyticsToken' => $this->analyticsTokenMock,
'otpRequest' => $this->otpRequestMock,
'flagManager' => $this->flagManagerMock,
'urlReportDocConfigPath' => $this->urlReportDocConfigPath,
]
);
}

/**
* @param bool $isTokenExist
* @param string|null $otp If null OTP was not received.
*
* @throws SubscriptionUpdateException
* @dataProvider getUrlDataProvider
*/
public function testGetUrl($isTokenExist, $otp)
Expand All @@ -101,6 +118,11 @@ public function testGetUrl($isTokenExist, $otp)
->method('getValue')
->with($this->urlReportConfigPath)
->willReturn($reportUrl);
$this->configMock
->expects($this->once())
->method('getValue')
->with($this->urlReportDocConfigPath)
->willReturn($reportUrl);
$this->analyticsTokenMock
->expects($this->once())
->method('isTokenExist')
Expand Down Expand Up @@ -131,6 +153,7 @@ public function getUrlDataProvider()

/**
* @return void
* @throws SubscriptionUpdateException
*/
public function testGetUrlWhenSubscriptionUpdateRunning()
{
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Analytics/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<otp>https://advancedreporting.rjmetrics.com/otp</otp>
<report>https://advancedreporting.rjmetrics.com/report</report>
<notify_data_changed>https://advancedreporting.rjmetrics.com/report</notify_data_changed>
<documentation>https://docs.magento.com/m2/ce/user_guide/reports/advanced-reporting.html</documentation>
rafaelstz marked this conversation as resolved.
Show resolved Hide resolved
</url>
<integration_name>Magento Analytics user</integration_name>
<general>
Expand Down