function LinearHistoryTest::testDelete
Same name in other branches
- 11.x core/tests/Drupal/Tests/Core/Config/Checkpoint/LinearHistoryTest.php \Drupal\Tests\Core\Config\Checkpoint\LinearHistoryTest::testDelete()
@covers ::delete
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ Checkpoint/ LinearHistoryTest.php, line 118
Class
- LinearHistoryTest
- @coversDefaultClass \Drupal\Core\Config\Checkpoint\LinearHistory @group Config
Namespace
Drupal\Tests\Core\Config\CheckpointCode
public function testDelete() : void {
$state = $this->prophesize(StateInterface::class);
$test_data = [
'hash1' => new Checkpoint('hash1', 'One', 1701539510, NULL),
'hash2' => new Checkpoint('hash2', 'Two', 1701539520, 'hash1'),
'hash3' => new Checkpoint('hash3', 'Three', 1701539530, 'hash2'),
];
$state->get(self::CHECKPOINT_KEY, [])
->willReturn($test_data);
unset($test_data['hash1'], $test_data['hash2']);
$state->set(self::CHECKPOINT_KEY, $test_data)
->willReturn();
$time = $this->prophesize(TimeInterface::class);
$checkpoints = new LinearHistory($state->reveal(), $time->reveal());
$this->assertCount(3, $checkpoints);
$this->assertSame('hash3', $checkpoints->getActiveCheckpoint()?->id);
$checkpoints->delete('hash2');
$this->assertCount(1, $checkpoints);
$this->assertSame('hash3', $checkpoints->getActiveCheckpoint()?->id);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.