public function ProxyItemTest::testSet in Purge 8.3
Tests \Drupal\purge\Plugin\Purge\Queue\ProxyItem::__set.
File
- tests/
src/ Kernel/ Queue/ ProxyItemTest.php, line 92
Class
- ProxyItemTest
- Tests \Drupal\purge\Tests\Queue\ProxyItem.
Namespace
Drupal\Tests\purge\Kernel\QueueCode
public function testSet() : void {
$i = $this
->getInvalidations(1);
$p = new ProxyItem($i, $this->buffer);
$this->buffer
->set($i, TxBuffer::CLAIMED);
// Test setting the 'item_id' and 'created' properties.
$this
->assertNull($this->buffer
->getProperty($i, 'item_id'));
$p->item_id = 5;
$this
->assertEquals(5, $this->buffer
->getProperty($i, 'item_id'));
$p->item_id = 'FOOBAR';
$this
->assertEquals('FOOBAR', $this->buffer
->getProperty($i, 'item_id'));
$this
->assertNull($this->buffer
->getProperty($i, 'created'));
$p->created = FALSE;
$this
->assertFalse($this->buffer
->getProperty($i, 'created'));
$p->created = 0.7;
$this
->assertEquals(0.7, $this->buffer
->getProperty($i, 'created'));
// Test setting 'data' (RO) and other non-existing properties.
foreach ([
'data',
'foo',
'bar',
] as $property) {
$thrown = FALSE;
try {
$p->{$property} = time();
} catch (InvalidPropertyException $e) {
$thrown = TRUE;
}
$this
->assertTrue($thrown);
}
}