Skip to content

Commit afb47b1

Browse files
committed
Merge remote-tracking branch 'local/ACP2E-1971' into PR_Jun_06_2023
2 parents 3146de3 + 57a788f commit afb47b1

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
use PHPUnit\Framework\MockObject\MockObject;
2323
use PHPUnit\Framework\TestCase;
2424

25-
/** test Mview functionality
25+
/**
26+
* Test Mview functionality
27+
*
28+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2629
*/
2730
class ViewTest extends TestCase
2831
{
@@ -517,6 +520,41 @@ function () {
517520
$this->model->update();
518521
}
519522

523+
/**
524+
* Test update with no changes in the changelog
525+
*/
526+
public function testUpdateWithNoChanges()
527+
{
528+
$currentVersionId = 3;
529+
$lastVersionId = 3;
530+
531+
$this->stateMock->method('getViewId')
532+
->willReturn(1);
533+
$this->stateMock->method('getMode')
534+
->willReturn(StateInterface::MODE_ENABLED);
535+
$this->stateMock->method('getStatus')
536+
->willReturn(StateInterface::STATUS_IDLE);
537+
$this->stateMock->expects(self::once())
538+
->method('getVersionId')
539+
->willReturn($lastVersionId);
540+
$this->changelogMock->expects(self::once())
541+
->method('getVersion')
542+
->willReturn($currentVersionId);
543+
544+
$this->stateMock->expects(self::never())
545+
->method('setVersionId');
546+
$this->stateMock->expects(self::never())
547+
->method('setStatus');
548+
$this->stateMock->expects(self::never())
549+
->method('save');
550+
$this->actionFactoryMock->expects(self::never())
551+
->method('get');
552+
$this->iteratorMock->expects(self::never())
553+
->method('walk');
554+
555+
$this->model->update();
556+
}
557+
520558
/**
521559
* Test to Suspend view updates and set version ID to changelog's end
522560
*/

lib/internal/Magento/Framework/Mview/View.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,11 @@ public function update()
258258
}
259259

260260
$lastVersionId = (int)$this->getState()->getVersionId();
261-
$action = $this->actionFactory->get($this->getActionClass());
261+
if ($lastVersionId >= $currentVersionId) {
262+
return;
263+
}
262264

265+
$action = $this->actionFactory->get($this->getActionClass());
263266
try {
264267
$this->getState()->setStatus(View\StateInterface::STATUS_WORKING)->save();
265268

0 commit comments

Comments
 (0)