Exemplo n.º 1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->spider = new Spider('http://php-spider.org/A');
     $this->requestHandler = $this->getMock('VDB\\Spider\\RequestHandler\\RequestHandler');
     $this->hrefA = 'http://php-spider.org/A';
     $this->hrefB = 'http://php-spider.org/B';
     $this->hrefC = 'http://php-spider.org/C';
     $this->hrefD = 'http://php-spider.org/D';
     $this->hrefE = 'http://php-spider.org/E';
     $this->hrefF = 'http://php-spider.org/F';
     $this->hrefG = 'http://php-spider.org/G';
     $this->linkA = new Uri($this->hrefA);
     $this->linkB = new Uri($this->hrefB);
     $this->linkC = new Uri($this->hrefC);
     $this->linkD = new Uri($this->hrefD);
     $this->linkE = new Uri($this->hrefE);
     $this->linkF = new Uri($this->hrefF);
     $this->linkG = new Uri($this->hrefG);
     $htmlA = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceA.html');
     $this->responseA = new Response(200, null, $htmlA);
     $htmlB = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceB.html');
     $this->responseB = new Response(200, null, $htmlB);
     $htmlC = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceC.html');
     $this->responseC = new Response(200, null, $htmlC);
     $htmlD = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceD.html');
     $this->responseD = new Response(200, null, $htmlD);
     $htmlE = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceE.html');
     $this->responseE = new Response(200, null, $htmlE);
     $htmlF = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceF.html');
     $this->responseF = new Response(200, null, $htmlF);
     $htmlG = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceG.html');
     $this->responseG = new Response(200, null, $htmlG);
     $this->requestHandler->expects($this->any())->method('request')->will($this->returnCallback(array($this, 'doTestRequest')));
     $this->spider->setRequestHandler($this->requestHandler);
     $this->spider->addDiscoverer(new XPathExpressionDiscoverer('//a'));
 }