public function DatabaseQueueTest::testClaimPayment in Payment 8.2
@covers ::claimPayment
File
- tests/
src/ Unit/ DatabaseQueueTest.php, line 94
Class
- DatabaseQueueTest
- @coversDefaultClass \Drupal\payment\DatabaseQueue
Namespace
Drupal\Tests\payment\UnitCode
public function testClaimPayment() {
$payment_id = mt_rand();
$acquisition_code = $this
->randomMachineName();
/** @var \Drupal\payment\DatabaseQueue|\PHPUnit\Framework\MockObject\MockObject $queue */
$queue = $this
->getMockBuilder(DatabaseQueue::class)
->setConstructorArgs(array(
$this->queueId,
$this->database,
$this->eventDispatcher,
$this->paymentStatusManager,
))
->setMethods(array(
'tryClaimPaymentOnce',
))
->getMock();
$queue
->expects($this
->at(0))
->method('tryClaimPaymentOnce')
->with($payment_id)
->willReturn(FALSE);
$queue
->expects($this
->at(1))
->method('tryClaimPaymentOnce')
->with($payment_id)
->willReturn($acquisition_code);
$this
->assertSame($acquisition_code, $queue
->claimPayment($payment_id));
}