public function testRunsActionsOnResults() { $this->skipTestIfTestingWithPHP53(); $crawler = new Crawler(new HttpClient(DemoServer::URL)); $crawler->addAction(new CssTextAction('header .title')); ob_start(); $crawler->go(0); $output = trim(ob_get_clean()); $this->assertEquals('mike-on-a-bike', $output); }
/** * NOTE: Actions that persist the result should be registered last. * NOTE: Order matters. * * @param InputInterface $input * @param Crawler $crawler */ private function addActions(InputInterface $input, Crawler $crawler) { if ($input->getOption('minify-html')) { $crawler->addAction(new MinifyHtmlAction()); } if ($input->getOption('save-hashed')) { $crawler->addAction(new SaveHashedResultAction($input->getOption('save-hashed'))); } if ($input->getOption('mirror')) { $crawler->addAction(new MirrorResultAction($input->getOption('mirror'))); } if ($input->getOption('xpath')) { $crawler->addAction(new XPathTextAction($input->getOption('xpath'))); } if ($input->getOption('css')) { $crawler->addAction(new CssTextAction($input->getOption('css'))); } }