/**
  * Test execution.
  *
  * @param Document $htmlDocument the HTML dokument to test
  */
 public function runTest(Document $htmlDocument)
 {
     static $requestedDependecies = array();
     $failedUrls = array();
     $files = $htmlDocument->getExternalDependencies();
     $requestUri = new Uri($this->getRequest()->getUri());
     $domain = $requestUri->getDomain();
     foreach ($files as $file) {
         $absoluteFile = $domain->concatUri($file);
         if (!$this->isIgnored($absoluteFile->toString())) {
             if (array_key_exists($absoluteFile->toString(), $requestedDependecies)) {
                 $status = $requestedDependecies[$absoluteFile->toString()];
             } else {
                 $request = Symfony::create($absoluteFile, Request::GET);
                 $client = new Zend();
                 $response = $client->request($request);
                 $status = $response->getStatus();
                 $requestedDependecies[$absoluteFile->toString()] = $response->getStatus();
             }
             if ($status >= 400) {
                 $failedUrls[] = $absoluteFile->toString();
             }
         }
     }
     if (count($failedUrls) > 0) {
         $this->handleFailures($failedUrls);
     }
 }
Example #2
0
 /**
  * @Event("LiveTest.Run.PostRun")
  *
  * @param Information $information
  */
 public function postRun(Information $information)
 {
     try {
         $postData = array('urls' => $this->urls, 'tests' => $this->tests);
         $request = Symfony::create(new Uri(self::PHM_API), Request::GET, $postData);
         $client = new Zend();
         $response = $client->request($request);
     } catch (\Exception $e) {
     }
 }
Example #3
0
 private function getClients($sessions)
 {
     $clients = array();
     foreach ($sessions as $sessionName => $session) {
         $client = new Zend();
         if ($session->areCookiesAllowed()) {
             $client->setCookieJar(new CookieJar());
         }
         $client->setAdapter(new Curl());
         $this->eventDispatcher->simpleNotify('LiveTest.Runner.InitHttpClient', array('client' => $client, 'sessionName' => $sessionName));
         $clients[$sessionName] = $client;
     }
     return $clients;
 }