示例#1
0
 /**
  * Return DOMNodeList from CSS selector
  *
  * @param $string
  * @return \DOMNodeList
  */
 public function query($string)
 {
     CssSelector::disableHtmlExtension();
     $xpathQuery = CssSelector::toXPath($string);
     $xpath = new \DOMXPath($this->data);
     return $xpath->query($xpathQuery);
 }
 /**
  * @dataProvider provideUrls
  * @param $url
  */
 public function testPageIsSuccessful($url)
 {
     $client = static::createClient();
     CssSelector::disableHtmlExtension();
     $crawler = $client->request('GET', $url);
     $this->assertTrue($client->getResponse()->isSuccessful());
     $this->assertGreaterThan(0, $crawler->filter('pre:contains("ck>Success</")')->count());
 }
 /**
  * @param Crawler $crawler
  *
  * @return \JakubZapletal\Component\BankStatement\Statement\Statement
  */
 protected function parseCrawler(Crawler $crawler)
 {
     $this->statement = $this->getStatementClass();
     CssSelector::disableHtmlExtension();
     $crawler = $crawler->filter('FINSTA > FINSTA03');
     if ($crawler !== null) {
         $this->parseStatementNode($crawler);
         $parser = $this;
         $crawler->filter('FINSTA05')->each(function (Crawler $node) use($parser) {
             $parser->parseAndAddTransaction($node);
         });
     }
     return $this->statement;
 }
示例#4
0
 public function __construct(UrlBuilder $u, LoggerInterface $logger)
 {
     $pages = array();
     // Disable `HTML` extension of CssSelector.
     CssSelector::disableHtmlExtension();
     $client = new Client();
     $crawler = $client->request('GET', (string) $u);
     $status = $client->getResponse()->getStatus();
     if ($status > 399) {
         $logger->emergency('Status ' . $status . ' getting ' . (string) $u);
     }
     $sitemap_crawler = $crawler->filter('urlset > url > loc');
     foreach ($sitemap_crawler as $url_loc) {
         $url = $url_loc->nodeValue;
         $pages[$url] = $url;
     }
     parent::__construct($pages);
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function __construct(atoum\adapter $adapter = null, atoum\annotations\extractor $annotationExtractor = null, atoum\asserter\generator $asserterGenerator = null, atoum\test\assertion\manager $assertionManager = null, \closure $reflectionClassFactory = null)
 {
     parent::__construct($adapter, $annotationExtractor, $asserterGenerator, $assertionManager, $reflectionClassFactory);
     $generator = $this->getAsserterGenerator();
     $test = $this;
     $crawler = null;
     $client = null;
     $this->getAssertionManager()->setHandler('request', function (array $options = array(), array $server = array(), array $cookies = array()) use(&$client, $test) {
         $client = $test->createClient($options, $server, $cookies);
         return $test;
     })->setHandler('get', $get = $this->getSendRequestHandler($client, $crawler, 'GET'))->setHandler('GET', $get)->setHandler('head', $head = $this->getSendRequestHandler($client, $crawler, 'HEAD'))->setHandler('HEAD', $head)->setHandler('post', $post = $this->getSendRequestHandler($client, $crawler, 'POST'))->setHandler('POST', $post)->setHandler('put', $put = $this->getSendRequestHandler($client, $crawler, 'PUT'))->setHandler('PUT', $put)->setHandler('patch', $patch = $this->getSendRequestHandler($client, $crawler, 'PATCH'))->setHandler('PATCH', $patch)->setHandler('delete', $delete = $this->getSendRequestHandler($client, $crawler, 'DELETE'))->setHandler('DELETE', $delete)->setHandler('options', $options = $this->getSendRequestHandler($client, $crawler, 'OPTIONS'))->setHandler('OPTIONS', $options)->setHandler('crawler', function ($strict = false) use(&$crawler, $generator, $test) {
         if ($strict) {
             CssSelector::enableHtmlExtension();
         } else {
             CssSelector::disableHtmlExtension();
         }
         return $generator->getAsserterInstance('\\atoum\\AtoumBundle\\Test\\Asserters\\Crawler', array($crawler), $test);
     });
 }
示例#6
0
 public function testFilterWithMultipleNamespaces()
 {
     CssSelector::disableHtmlExtension();
     $crawler = $this->createTestXmlCrawler()->filter('media|group yt|aspectRatio');
     $this->assertCount(1, $crawler, '->filter() automatically registers namespaces');
     $this->assertSame('widescreen', $crawler->text());
 }