function LinearHistoryTest::testGetParentsException

Same name in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Config/Checkpoint/LinearHistoryTest.php \Drupal\Tests\Core\Config\Checkpoint\LinearHistoryTest::testGetParentsException()

@covers ::getParents

File

core/tests/Drupal/Tests/Core/Config/Checkpoint/LinearHistoryTest.php, line 175

Class

LinearHistoryTest
@coversDefaultClass \Drupal\Core\Config\Checkpoint\LinearHistory @group Config

Namespace

Drupal\Tests\Core\Config\Checkpoint

Code

public function testGetParentsException() : void {
    $state = $this->prophesize(StateInterface::class);
    $test_data = [
        'hash1' => new Checkpoint('hash1', 'One', 1701539510, NULL),
        'hash2' => new Checkpoint('hash2', 'Two', 1701539520, 'hash1'),
    ];
    $state->get(self::CHECKPOINT_KEY, [])
        ->willReturn($test_data);
    $time = $this->prophesize(TimeInterface::class);
    $checkpoints = new LinearHistory($state->reveal(), $time->reveal());
    $this->expectException(UnknownCheckpointException::class);
    $this->expectExceptionMessage('The checkpoint "hash3" does not exist');
    iterator_to_array($checkpoints->getParents('hash3'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.