public function ServiceTest::testAddClaim in Purge 8.3
Tests QueueService::add and QueueService::claim.
File
- tests/
src/ Kernel/ Queue/ ServiceTest.php, line 88
Class
Namespace
Drupal\Tests\purge\Kernel\QueueCode
public function testAddClaim() : void {
$this
->assertTrue(empty($this->service
->claim(10, 10)));
$i = $this
->getInvalidations(1);
$this
->assertNull($this->service
->add($this->queuer, [
$i,
]));
$claims = $this->service
->claim(100, 10);
$this
->assertTrue(is_array($claims));
$this
->assertEquals(1, count($claims));
$this
->assertTrue($claims[0] instanceof InvalidationInterface);
$this
->assertTrue($claims[0]
->getId() === $i
->getId());
$this
->assertEquals($claims[0]
->getState(), InvalidationInterface::FRESH);
// Now test with more objects.
$this->service
->emptyQueue();
$this->service
->add($this->queuer, $this
->getInvalidations(50));
$this
->assertEquals(50, $this->service
->numberOfItems());
$this
->assertTrue(37 === count($this->service
->claim(37, 10)));
$this
->assertTrue(13 === count($this->service
->claim(15, 10)));
}