/** * @param array $parserOptions * @param ParserContext $context * * @return NodeTraverser * @throws \GrumPHP\Exception\RuntimeException */ public function createForTaskContext(array $parserOptions, ParserContext $context) { $this->configurator->registerOptions($parserOptions); $this->configurator->registerContext($context); $traverser = new NodeTraverser(); $this->configurator->configure($traverser); return $traverser; }
function it_can_create_a_task_and_context_specific_traverser(TraverserConfigurator $configurator, ParserContext $context) { $taskOptions = ['visitors' => []]; $configurator->registerOptions($taskOptions)->shouldBeCalled(); $configurator->registerContext($context)->shouldBeCalled(); $configurator->configure(Argument::type(NodeTraverser::class))->shouldBeCalled(); $this->createForTaskContext($taskOptions, $context)->shouldBeAnInstanceOf(NodeTraverser::class); }