Skip to content

Commit 1b6184e

Browse files
committed
MC-34039: Merge 2.4-develop into 2.4-develop-php74
-- fix merge confict
1 parent d059461 commit 1b6184e

File tree

9 files changed

+357
-43
lines changed

9 files changed

+357
-43
lines changed

app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Action/FullTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class FullTest extends TestCase
4141

4242
protected function setUp(): void
4343
{
44+
$this->markTestSkipped("MC-18332: Mysql Search Engine is deprecated and will be removed");
4445
$resource = $this->getMockBuilder(ResourceConnection::class)
4546
->disableOriginalConstructor()
4647
->getMock();

app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/Fulltext/CollectionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class CollectionTest extends BaseCollection
9595
*/
9696
protected function setUp(): void
9797
{
98+
$this->markTestSkipped("MC-18332: Mysql Search Engine is deprecated and will be removed");
9899
$this->objectManager = new ObjectManager($this);
99100
$this->storeManager = $this->getStoreManager();
100101
$this->universalFactory = $this->getUniversalFactory();

app/code/Magento/Cron/Test/Unit/Model/ScheduleTest.php

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
use Magento\Cron\Model\ResourceModel\Schedule as SchoduleResourceModel;
1111
use Magento\Cron\Model\Schedule;
12+
use Magento\Cron\Model\DeadlockRetrierInterface;
1213
use Magento\Framework\Exception\CronException;
1314
use Magento\Framework\Intl\DateTimeFactory;
1415
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
15-
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
16+
use Magento\Framework\DB\Adapter\AdapterInterface;
1617
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1718
use PHPUnit\Framework\MockObject\MockObject;
1819
use PHPUnit\Framework\TestCase;
@@ -42,16 +43,30 @@ class ScheduleTest extends TestCase
4243
*/
4344
private $dateTimeFactoryMock;
4445

46+
/**
47+
* @var DeadlockRetrierInterface|MockObject
48+
*/
49+
private $retrierMock;
50+
4551
/**
4652
* @inheritdoc
4753
*/
4854
protected function setUp(): void
4955
{
50-
$this->objectManagerHelper = new ObjectManager($this);
56+
$this->objectManagerHelper = new ObjectManagerHelper($this);
5157

5258
$this->resourceJobMock = $this->getMockBuilder(SchoduleResourceModel::class)
5359
->disableOriginalConstructor()
54-
->setMethods(['trySetJobUniqueStatusAtomic', '__wakeup', 'getIdFieldName'])
60+
->setMethods(
61+
[
62+
'trySetJobStatusAtomic',
63+
'__wakeup',
64+
'getIdFieldName',
65+
'trySetJobStatuses',
66+
'getConnection',
67+
'getTable'
68+
]
69+
)
5570
->getMockForAbstractClass();
5671

5772
$this->resourceJobMock->expects($this->any())
@@ -65,6 +80,8 @@ protected function setUp(): void
6580
$this->dateTimeFactoryMock = $this->getMockBuilder(DateTimeFactory::class)
6681
->setMethods(['create'])
6782
->getMock();
83+
84+
$this->retrierMock = $this->createMock(DeadlockRetrierInterface::class);
6885
}
6986

7087
/**
@@ -457,20 +474,49 @@ public function getNumericDataProvider(): array
457474
public function testTryLockJobSuccess(): void
458475
{
459476
$scheduleId = 1;
477+
$jobCode = 'test_job';
478+
$tableName = 'cron_schedule';
479+
480+
$connectionMock = $this->createMock(AdapterInterface::class);
481+
$connectionMock->expects($this->once())
482+
->method('update')
483+
->with(
484+
$tableName,
485+
['status' => Schedule::STATUS_ERROR],
486+
['job_code = ?' => $jobCode, 'status = ?' => Schedule::STATUS_RUNNING]
487+
)
488+
->willReturn(1);
460489

461490
$this->resourceJobMock->expects($this->once())
462-
->method('trySetJobUniqueStatusAtomic')
491+
->method('trySetJobStatusAtomic')
463492
->with($scheduleId, Schedule::STATUS_RUNNING, Schedule::STATUS_PENDING)
464493
->willReturn(true);
494+
$this->resourceJobMock->expects($this->once())
495+
->method('getTable')
496+
->with($tableName)
497+
->willReturn($tableName);
498+
$this->resourceJobMock->expects($this->exactly(3))
499+
->method('getConnection')
500+
->willReturn($connectionMock);
501+
502+
$this->retrierMock->expects($this->exactly(2))
503+
->method('execute')
504+
->willReturnCallback(
505+
function ($callback) {
506+
return $callback();
507+
}
508+
);
465509

466510
/** @var Schedule $model */
467511
$model = $this->objectManagerHelper->getObject(
468512
Schedule::class,
469513
[
470-
'resource' => $this->resourceJobMock
514+
'resource' => $this->resourceJobMock,
515+
'retrier' => $this->retrierMock,
471516
]
472517
);
473518
$model->setId($scheduleId);
519+
$model->setJobCode($jobCode);
474520
$this->assertEquals(0, $model->getStatus());
475521

476522
$model->tryLockJob();
@@ -486,20 +532,49 @@ public function testTryLockJobSuccess(): void
486532
public function testTryLockJobFailure(): void
487533
{
488534
$scheduleId = 1;
535+
$jobCode = 'test_job';
536+
$tableName = 'cron_schedule';
537+
538+
$connectionMock = $this->createMock(AdapterInterface::class);
539+
$connectionMock->expects($this->once())
540+
->method('update')
541+
->with(
542+
$tableName,
543+
['status' => Schedule::STATUS_ERROR],
544+
['job_code = ?' => $jobCode, 'status = ?' => Schedule::STATUS_RUNNING]
545+
)
546+
->willReturn(1);
489547

490548
$this->resourceJobMock->expects($this->once())
491-
->method('trySetJobUniqueStatusAtomic')
549+
->method('trySetJobStatusAtomic')
492550
->with($scheduleId, Schedule::STATUS_RUNNING, Schedule::STATUS_PENDING)
493551
->willReturn(false);
552+
$this->resourceJobMock->expects($this->once())
553+
->method('getTable')
554+
->with($tableName)
555+
->willReturn($tableName);
556+
$this->resourceJobMock->expects($this->exactly(3))
557+
->method('getConnection')
558+
->willReturn($connectionMock);
559+
560+
$this->retrierMock->expects($this->exactly(2))
561+
->method('execute')
562+
->willReturnCallback(
563+
function ($callback) {
564+
return $callback();
565+
}
566+
);
494567

495568
/** @var Schedule $model */
496569
$model = $this->objectManagerHelper->getObject(
497570
Schedule::class,
498571
[
499-
'resource' => $this->resourceJobMock
572+
'resource' => $this->resourceJobMock,
573+
'retrier' => $this->retrierMock,
500574
]
501575
);
502576
$model->setId($scheduleId);
577+
$model->setJobCode($jobCode);
503578
$this->assertEquals(0, $model->getStatus());
504579

505580
$model->tryLockJob();

0 commit comments

Comments
 (0)