Skip to content

Commit aa5ba8c

Browse files
committed
MC-31766: [AR] Report account is unavailable after URL change
1 parent 6298ab7 commit aa5ba8c

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

app/code/Magento/Analytics/Cron/Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function execute()
7676
$attemptsCount = (int)$this->flagManager
7777
->getFlagData(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
7878

79-
if (($attemptsCount >= 0) && $this->analyticsToken->isTokenExist()) {
79+
if (($attemptsCount > 0) && $this->analyticsToken->isTokenExist()) {
8080
$attemptsCount--;
8181
$this->flagManager
8282
->saveFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $attemptsCount);

app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Analytics\Model\Connector;
1212
use Magento\Framework\App\Config\ReinitableConfigInterface;
1313
use Magento\Framework\App\Config\Storage\WriterInterface;
14+
use Magento\Framework\Exception\NotFoundException;
1415
use Magento\Framework\FlagManager;
1516

1617
class UpdateTest extends \PHPUnit\Framework\TestCase
@@ -45,6 +46,9 @@ class UpdateTest extends \PHPUnit\Framework\TestCase
4546
*/
4647
private $update;
4748

49+
/**
50+
* @inheritDoc
51+
*/
4852
protected function setUp()
4953
{
5054
$this->connectorMock = $this->getMockBuilder(Connector::class)
@@ -74,6 +78,7 @@ protected function setUp()
7478

7579
/**
7680
* @return void
81+
* @throws NotFoundException
7782
*/
7883
public function testExecuteWithoutToken()
7984
{
@@ -82,12 +87,12 @@ public function testExecuteWithoutToken()
8287
->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE)
8388
->willReturn(10);
8489
$this->connectorMock
85-
->expects($this->once())
90+
->expects($this->never())
8691
->method('execute')
8792
->with('update')
8893
->willReturn(false);
8994
$this->analyticsTokenMock
90-
->expects($this->once())
95+
->expects($this->any())
9196
->method('isTokenExist')
9297
->willReturn(false);
9398
$this->addFinalOutputAsserts();
@@ -120,6 +125,7 @@ private function addFinalOutputAsserts(bool $isExecuted = true)
120125
* @param $counterData
121126
* @return void
122127
* @dataProvider executeWithEmptyReverseCounterDataProvider
128+
* @throws NotFoundException
123129
*/
124130
public function testExecuteWithEmptyReverseCounter($counterData)
125131
{
@@ -159,6 +165,7 @@ public function executeWithEmptyReverseCounterDataProvider()
159165
* @param bool $functionResult
160166
* @return void
161167
* @dataProvider executeRegularScenarioDataProvider
168+
* @throws NotFoundException
162169
*/
163170
public function testExecuteRegularScenario(
164171
int $reverseCount,
@@ -170,6 +177,10 @@ public function testExecuteRegularScenario(
170177
->method('getFlagData')
171178
->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE)
172179
->willReturn($reverseCount);
180+
$this->flagManagerMock
181+
->expects($this->once())
182+
->method('saveFlag')
183+
->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $reverseCount - 1);
173184
$this->connectorMock
174185
->expects($this->once())
175186
->method('execute')

dev/tests/integration/testsuite/Magento/Analytics/Cron/UpdateTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
/**
2323
* @magentoAppArea adminhtml
24+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2425
*/
2526
class UpdateTest extends \PHPUnit\Framework\TestCase
2627
{

0 commit comments

Comments
 (0)