/**
  * Assert whether the client was redirected to a given URI.
  *
  * @param  string  $uri
  * @param  array   $with
  * @return void
  */
 public function assertRedirectedTo($uri, $with = array())
 {
     $response = $this->client->getResponse();
     $this->assertInstanceOf('Illuminate\\Http\\RedirectResponse', $response);
     $this->assertEquals($this->app['url']->to($uri), $response->headers->get('Location'));
     $this->assertSessionHasAll($with);
 }
Exemple #2
0
 /**
  * Call the given URI and return the Response.
  *
  * @param string $url
  *
  * @return null|DomCrawler
  */
 protected function getPage($url)
 {
     $url = str_replace($this->root, null, $url);
     // Call page
     $this->client->request('GET', $url);
     $response = $this->client->getResponse();
     if (!$response->isOk()) {
         return $this->error('Page at "' . $url . '" could not be reached');
     }
     // Format content
     $content = $response->getContent();
     $content = preg_replace('#(href|src)=([\'"])/([^/])#', '$1=$2' . $this->root . '/$3', $content);
     $content = str_replace($this->app['url']->to('/'), $this->root, $content);
     $content = utf8_decode($content);
     // Build message
     $status = $this->app['flatten.context']->shouldCachePage() ? 'Cached' : 'Left uncached';
     $current = count($this->queue) - $this->current;
     $padding = str_repeat(' ', 70 - strlen($url) - strlen($status));
     // Display message
     $message = $status . ' <info>%s</info>%s<comment>(%s in queue)</comment>';
     $this->output->writeln(sprintf($message, $url, $padding, $current));
     // Cache page
     if ($this->app['flatten.context']->shouldCachePage()) {
         $this->app['flatten.cache']->storeCache($content);
     }
     return new DomCrawler($content);
 }
 protected function doRequest($request)
 {
     $headers = $request->headers;
     $this->fireBootedCallbacks();
     $response = parent::doRequest($request);
     // saving referer for redirecting back
     if (!$this->getHistory()->isEmpty()) {
         $headers->set('referer', $this->getHistory()->current()->getUri());
     }
     return $response;
 }
Exemple #4
0
 protected function doRequest($request)
 {
     $this->rebootKernel();
     $this->kernel->setRequestForConsoleEnvironment();
     $headers = $request->headers;
     $response = parent::doRequest($request);
     // saving referer for redirecting back
     if (!$this->getHistory()->isEmpty()) {
         $headers->set('referer', $this->getHistory()->current()->getUri());
     }
     return $response;
 }
 /**
  * Inspect a route.
  *
  * @param Client $client
  * @param string $route
  */
 protected function inspect(Client $client, $route)
 {
     try {
         $this->info('Inspecting ' . $route);
         $client->request('GET', $route);
     } catch (Exception $exception) {
         $this->error('Error inspecting ' . $route);
     }
     // Format and sort queries
     $routeQueries = DB::getQueryLog();
     $routeQueries = array_pluck($routeQueries, 'query');
     sort($routeQueries);
     // Cancel if no queries on this page
     if (empty($routeQueries)) {
         return;
     }
     // Store and flush
     $this->queries[$route]['response'] = $client->getResponse()->getContent();
     $this->queries[$route]['queries'] = $routeQueries;
     DB::flushQueryLog();
 }
 /**
  * Call the given URI and return the Response.
  *
  * @param  string  $method
  * @param  string  $uri
  * @param  array   $parameters
  * @param  array   $files
  * @param  array   $server
  * @param  string  $content
  * @param  bool	$changeHistory
  * @return \Illuminate\Http\Response
  */
 public function call($method, $uri, $parameters = [], $files = [], $server = [], $content = null, $changeHistory = true)
 {
     $this->client->request($method, $uri, $parameters, $files, $server, $content, $changeHistory);
     return $this->client->getResponse();
 }