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 all 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 @@ -15,6 +15,6 @@

<switchToNextTab stepKey="switchToNewTab"/>
<waitForPageLoad stepKey="waitForAdvancedReportingPageLoad"/>
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
<seeInCurrentUrl url="reports/advanced-reporting" stepKey="seeAssertAdvancedReportingPageUrl"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,10 @@ class ReportUrlProviderTest extends TestCase
*/
private $flagManagerMock;

/**
* @var ObjectManagerHelper
*/
private $objectManagerHelper;

/**
* @var ReportUrlProvider
*/
private $reportUrlProvider;

/**
* @var string
*/
private $urlReportConfigPath = 'path/url/report';
private $model;

/**
* @return void
Expand All @@ -71,35 +61,36 @@ protected function setUp(): void

$this->flagManagerMock = $this->createMock(FlagManager::class);

$this->objectManagerHelper = new ObjectManagerHelper($this);
$objectManagerHelper = new ObjectManagerHelper($this);

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

/**
* @param bool $isTokenExist
* @param string|null $otp If null OTP was not received.
* @param string $configPath
* @return void
*
* @dataProvider getUrlDataProvider
*/
public function testGetUrl($isTokenExist, $otp)
public function testGetUrl(bool $isTokenExist, ?string $otp, string $configPath): void
{
$reportUrl = 'https://example.com/report';
$url = '';

$this->configMock
->expects($this->once())
->method('getValue')
->with($this->urlReportConfigPath)
->with($configPath)
->willReturn($reportUrl);
$this->analyticsTokenMock
->expects($this->once())
Expand All @@ -114,18 +105,19 @@ public function testGetUrl($isTokenExist, $otp)
if ($isTokenExist && $otp) {
$url = $reportUrl . '?' . http_build_query(['otp' => $otp], '', '&');
}
$this->assertSame($url ?: $reportUrl, $this->reportUrlProvider->getUrl());

$this->assertSame($url ?: $reportUrl, $this->model->getUrl());
}

/**
* @return array
*/
public function getUrlDataProvider()
public function getUrlDataProvider(): array
{
return [
'TokenDoesNotExist' => [false, null],
'TokenExistAndOtpEmpty' => [true, null],
'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab'],
'TokenDoesNotExist' => [false, null, 'analytics/url/documentation'],
'TokenExistAndOtpEmpty' => [true, null, 'analytics/url/report'],
'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab', 'analytics/url/report'],
];
}

Expand All @@ -140,6 +132,6 @@ public function testGetUrlWhenSubscriptionUpdateRunning()
->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)
->willReturn('http://store.com');
$this->expectException(SubscriptionUpdateException::class);
$this->reportUrlProvider->getUrl();
$this->model->getUrl();
}
}
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/user-guide/reports/advanced-reporting.html</documentation>
</url>
<integration_name>Magento Analytics user</integration_name>
<general>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class ShowTest extends AbstractBackendController
{
private const REPORT_HOST = 'advancedreporting.rjmetrics.com';
private const REPORT_HOST = 'docs.magento.com';
/**
* @inheritDoc
*/
Expand Down