예제 #1
0
 /**
  * @depends test_intercepting_ringphp_stream_handle_request
  */
 public function test_intercepting_guzzle_client_request($streamHandler)
 {
     $filename = 'ignore-guzzle-test';
     Http::persistSaveFile($filename);
     // Force Guzzle to use a PHP stream instead of cURL.
     $httpClient = new Client(['handler' => $streamHandler]);
     $httpClient->get('http://www.example.com/', ['version' => '1.0', 'verify' => FALSE]);
     Http::clearPersistSaveFile();
     $requestIntercepted = \file_exists(FIXTURES_PATH . DIRECTORY_SEPARATOR . $filename . '-1.rsd');
     $this->assertTrue($requestIntercepted);
 }
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     $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'])) {
         Http::clearPersistSaveFile();
     }
 }
예제 #3
0
 public function test_save_file_persist()
 {
     $filename = 'ignore-persist-file-test';
     Http::persistSaveFile($filename);
     \file_get_contents('http://www.example.com/');
     \file_get_contents('http://www.example.com/');
     $actual = Http::getSaveFilename();
     // Turn this off or we break other tests.
     Http::clearPersistSaveFile();
     $file1 = \file_exists(FIXTURES_PATH . DIRECTORY_SEPARATOR . $filename . '-1.rsd');
     $file2 = \file_exists(FIXTURES_PATH . DIRECTORY_SEPARATOR . $filename . '-2.rsd');
     $this->assertContains($filename, $actual);
     $this->assertTrue($file1);
     $this->assertTrue($file2);
 }