function LinearHistoryTest::testAddException
Same name in other branches
- 11.x core/tests/Drupal/Tests/Core/Config/Checkpoint/LinearHistoryTest.php \Drupal\Tests\Core\Config\Checkpoint\LinearHistoryTest::testAddException()
@covers ::add
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ Checkpoint/ LinearHistoryTest.php, line 79
Class
- LinearHistoryTest
- @coversDefaultClass \Drupal\Core\Config\Checkpoint\LinearHistory @group Config
Namespace
Drupal\Tests\Core\Config\CheckpointCode
public function testAddException() : void {
$state = $this->prophesize(StateInterface::class);
$state->get(self::CHECKPOINT_KEY, [])
->willReturn([]);
$state->set(self::CHECKPOINT_KEY, Argument::any())
->willReturn(NULL);
$time = $this->prophesize(TimeInterface::class);
$time->getCurrentTime()
->willReturn(1701539520, 1701539994);
$checkpoints = new LinearHistory($state->reveal(), $time->reveal());
$checkpoints->add('hash1', 'Label');
// Add another checkpoint with the same ID and an exception should be
// triggered.
$this->expectException(CheckpointExistsException::class);
$this->expectExceptionMessage('Cannot create a checkpoint with the ID "hash1" as it already exists');
$checkpoints->add('hash1', 'Label');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.