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