Skip to content

Commit

Permalink
FRW-8773 Added PHPUnit 11 support. (#11131)
Browse files Browse the repository at this point in the history
FRW-8773 Added PHP Unit 11 support.
  • Loading branch information
olhalivitchuk authored Nov 4, 2024
1 parent 20abe8c commit a903bfd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,17 @@ public function testCreateProcessShouldWriteToCacheIfCacheIsEnabled(
->onlyMethods(['cacheProcess'])
->getMock();

$invocationCount = 0;

// Assert
$processCacheReaderMock
->expects($this->exactly($expectedReaderCalls))
->method('hasProcess')
->withConsecutive(['process-a'], ['process-a'])
->willReturnOnConsecutiveCalls(false, true);
->willReturnCallback(function () use (&$invocationCount) {
$invocationCount++;

return $invocationCount === 2;
});

$processCacheWriterMock
->expects($this->exactly($expectedWriterCalls))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,27 @@ public function testCheckTimeouts(): void

$orderStateMachine = $this->createOrderStateMachineMock(['triggerEvent']);

//Check with grouping by event + order
$expectedCalls = [
[static::EVENT_PAY, [$salesOrderItem1, $salesOrderItem2]],
[static::EVENT_PAY, [$salesOrderItem3]],
[static::EVENT_SHIP, [$salesOrderItem4]],
];

$orderStateMachine
->expects($this->exactly(3))
->expects($this->exactly(count($expectedCalls)))
->method('triggerEvent')
->withConsecutive(
[$this->equalTo(static::EVENT_PAY), $this->equalTo([$salesOrderItem1, $salesOrderItem2])],
[$this->equalTo(static::EVENT_PAY), $this->equalTo([$salesOrderItem3])],
[$this->equalTo(static::EVENT_SHIP), $this->equalTo([$salesOrderItem4])],
)
->willReturn([]);
->willReturnCallback(function ($event, $items) use ($expectedCalls) {
static $invocationCount = 0;

[$expectedEvent, $expectedItems] = $expectedCalls[$invocationCount];

$invocationCount++;

$this->assertEquals($expectedEvent, $event);
$this->assertEquals($expectedItems, $items);

return [];
});

$timeout = $this->createOmsTimeoutMock();
$timeout
Expand Down Expand Up @@ -327,7 +338,7 @@ private function createOmsTimeoutMock(): TimeoutInterface
{
return $this->getMockBuilder(Timeout::class)
->disableOriginalConstructor()
->setMethods([
->onlyMethods([
'findItemsWithExpiredTimeouts',
])
->getMock();
Expand Down

0 comments on commit a903bfd

Please sign in to comment.