public function TxBufferTest::testKeyAndNext in Purge 8.3
Tests TxBuffer::key and TxBuffer::next.
File
- tests/
src/ Kernel/ Queue/ TxBufferTest.php, line 179
Class
- TxBufferTest
- Tests \Drupal\purge\Tests\Queue\TxBufferTest.
Namespace
Drupal\Tests\purge\Kernel\QueueCode
public function testKeyAndNext() : void {
$objects = $this
->getInvalidations(5);
$this
->assertNull($this->purgeQueueTxbuffer
->key());
$this->purgeQueueTxbuffer
->set($objects, TxBufferInterface::CLAIMED);
// Test that objects got added to the buffer in equal order as offered.
foreach ($objects as $i) {
$this
->assertEquals($i
->getId(), $this->purgeQueueTxbuffer
->key());
$this->purgeQueueTxbuffer
->next();
}
// Test that iterating the buffer works as expected.
foreach ($this->purgeQueueTxbuffer as $id => $i) {
$this
->assertTrue($i instanceof InvalidationInterface);
$found = FALSE;
foreach ($objects as $i) {
if ($i
->getId() === $id) {
$found = TRUE;
break;
}
}
$this
->assertTrue($found);
}
}