/** * @covers \PHP\Manipulator\TokenContainer\Iterator::key * @covers \PHP\Manipulator\TokenContainer\Iterator::<protected> */ public function testKeyThrowsOutOfBoundsExceptionIfIteratorIsNotValid() { $container = $this->getTestContainerWithHoles(); $iterator = new Iterator($container); $iterator->seek(6); $iterator->next(); try { $iterator->key(); $this->fail('Expected exception not thrown'); } catch (\OutOfBoundsException $e) { $this->assertEquals('Position not valid', $e->getMessage(), 'Wrong exception message'); } }