function LinearHistoryTest::testDeleteAll
@covers ::delete
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ Checkpoint/ LinearHistoryTest.php, line 97
Class
- LinearHistoryTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Config%21Checkpoint%21LinearHistory.php/class/LinearHistory/11.x" title="A chronological list of Checkpoint objects." class="local">\Drupal\Core\Config\Checkpoint\LinearHistory</a> @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.