/**
  * @param \PHPUnit_Framework_Test $test
  */
 public function startTest(\PHPUnit_Framework_Test $test)
 {
     $annotations = $test->getAnnotations();
     // Intercept a single request per test.
     if (\array_key_exists($this->singleIntercept, $annotations['method'])) {
         $filename = $annotations['method'][$this->singleIntercept][0];
         Http::setSaveFilename($filename);
     }
     // Intercept multiple request per test.
     if (\array_key_exists($this->multiIntercept, $annotations['method'])) {
         $filename = $annotations['method'][$this->multiIntercept][0];
         Http::persistSaveFile($filename);
     }
 }
Ejemplo n.º 2
0
 public function test_intercepting_guzzle_client_request_for_rss_xml()
 {
     $filename = 'rss-xml';
     $streamHandler = new GuzzleHandler();
     // Set the file to save to.
     Http::setSaveFilename($filename);
     // Have Guzzle use the Interception stream handler, so request can be intercepted.
     $httpClient = new Client(['handler' => $streamHandler]);
     // Have Guzzle load some XML from an RSS feed.
     $httpClient->get('http://www.quickenloans.com/blog/category/mortgage/mortgage-basics/feed');
     // cleanup for the next test.
     Http::clearSaveFile();
     // Verify that the RSS feed request was save to a file.
     $filename = $this->fixtureDir . $filename . '.rsd';
     $this->assertFileExists($filename);
 }
Ejemplo n.º 3
0
 public function test_https_protocol_1_1_with_connection_close()
 {
     Http::setSaveFilename('ignore-https-protocol-1-1-close-connection-header');
     $context = \stream_context_create(['http' => ['header' => 'Connection: close', 'method' => 'GET', 'protocol_version' => '1.1'], 'ssl' => ['verify_peer_name' => FALSE]]);
     $connection = \fopen('https://www.example.com/', 'r', FALSE, $context);
     $metaData = \stream_get_meta_data($connection);
     \fclose($connection);
     $this->assertContains('HTTP/1.1 200 OK', $metaData['wrapper_data'][0]);
 }