Skip to content

Commit 08c9f33

Browse files
fix tests
1 parent 1e8b12e commit 08c9f33

File tree

3 files changed

+16
-47
lines changed

3 files changed

+16
-47
lines changed

app/code/Magento/Analytics/Test/Mftf/ActionGroup/AssertAdminAdvancedReportingPageUrlActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
<switchToNextTab stepKey="switchToNewTab"/>
1717
<waitForPageLoad stepKey="waitForAdvancedReportingPageLoad"/>
18-
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
18+
<seeInCurrentUrl url="reports/advanced-reporting" stepKey="seeAssertAdvancedReportingPageUrl"/>
1919
</actionGroup>
2020
</actionGroups>

app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,10 @@ class ReportUrlProviderTest extends TestCase
4343
*/
4444
private $flagManagerMock;
4545

46-
/**
47-
* @var ObjectManagerHelper
48-
*/
49-
private $objectManagerHelper;
50-
5146
/**
5247
* @var ReportUrlProvider
5348
*/
54-
private $reportUrlProvider;
55-
56-
/**
57-
* @var string
58-
*/
59-
private $urlReportConfigPath = 'path/url/report';
60-
61-
/**
62-
* @var string
63-
*/
64-
private $urlReportDocConfigPath = 'analytics/url/documentation';
49+
private $model;
6550

6651
/**
6752
* @return void
@@ -76,52 +61,36 @@ protected function setUp(): void
7661

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

79-
$this->objectManagerHelper = new ObjectManagerHelper($this);
80-
81-
$this->reportUrlProvider = $this->objectManagerHelper->getObject(
82-
ReportUrlProvider::class,
83-
[
84-
'config' => $this->configMock,
85-
'analyticsToken' => $this->analyticsTokenMock,
86-
'otpRequest' => $this->otpRequestMock,
87-
'flagManager' => $this->flagManagerMock,
88-
'urlReportConfigPath' => $this->urlReportConfigPath,
89-
]
90-
);
64+
$objectManagerHelper = new ObjectManagerHelper($this);
9165

92-
$this->reportUrlProvider = $this->objectManagerHelper->getObject(
66+
$this->model = $objectManagerHelper->getObject(
9367
ReportUrlProvider::class,
9468
[
9569
'config' => $this->configMock,
9670
'analyticsToken' => $this->analyticsTokenMock,
9771
'otpRequest' => $this->otpRequestMock,
9872
'flagManager' => $this->flagManagerMock,
99-
'urlReportDocConfigPath' => $this->urlReportDocConfigPath,
10073
]
10174
);
10275
}
10376

10477
/**
10578
* @param bool $isTokenExist
10679
* @param string|null $otp If null OTP was not received.
80+
* @param string $configPath
81+
* @return void
10782
*
108-
* @throws SubscriptionUpdateException
10983
* @dataProvider getUrlDataProvider
11084
*/
111-
public function testGetUrl($isTokenExist, $otp)
85+
public function testGetUrl(bool $isTokenExist, ?string $otp, string $configPath): void
11286
{
11387
$reportUrl = 'https://example.com/report';
11488
$url = '';
11589

11690
$this->configMock
11791
->expects($this->once())
11892
->method('getValue')
119-
->with($this->urlReportConfigPath)
120-
->willReturn($reportUrl);
121-
$this->configMock
122-
->expects($this->once())
123-
->method('getValue')
124-
->with($this->urlReportDocConfigPath)
93+
->with($configPath)
12594
->willReturn($reportUrl);
12695
$this->analyticsTokenMock
12796
->expects($this->once())
@@ -136,24 +105,24 @@ public function testGetUrl($isTokenExist, $otp)
136105
if ($isTokenExist && $otp) {
137106
$url = $reportUrl . '?' . http_build_query(['otp' => $otp], '', '&');
138107
}
139-
$this->assertSame($url ?: $reportUrl, $this->reportUrlProvider->getUrl());
108+
109+
$this->assertSame($url ?: $reportUrl, $this->model->getUrl());
140110
}
141111

142112
/**
143113
* @return array
144114
*/
145-
public function getUrlDataProvider()
115+
public function getUrlDataProvider(): array
146116
{
147117
return [
148-
'TokenDoesNotExist' => [false, null],
149-
'TokenExistAndOtpEmpty' => [true, null],
150-
'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab'],
118+
'TokenDoesNotExist' => [false, null, 'analytics/url/documentation'],
119+
'TokenExistAndOtpEmpty' => [true, null, 'analytics/url/report'],
120+
'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab', 'analytics/url/report'],
151121
];
152122
}
153123

154124
/**
155125
* @return void
156-
* @throws SubscriptionUpdateException
157126
*/
158127
public function testGetUrlWhenSubscriptionUpdateRunning()
159128
{
@@ -163,6 +132,6 @@ public function testGetUrlWhenSubscriptionUpdateRunning()
163132
->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)
164133
->willReturn('http://store.com');
165134
$this->expectException(SubscriptionUpdateException::class);
166-
$this->reportUrlProvider->getUrl();
135+
$this->model->getUrl();
167136
}
168137
}

dev/tests/integration/testsuite/Magento/Analytics/Controller/Adminhtml/Reports/ShowTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
class ShowTest extends AbstractBackendController
1616
{
17-
private const REPORT_HOST = 'advancedreporting.rjmetrics.com';
17+
private const REPORT_HOST = 'docs.magento.com';
1818
/**
1919
* @inheritDoc
2020
*/

0 commit comments

Comments
 (0)