/** * @interception ignore-annotation-test * @covers ::startTest */ public function test_interception_used_annotation_for_filename() { $listener = new InterceptionListener('Http', $this->fixtureDir, ['http']); $listener->startTestSuite($this->suite); $listener->startTest($this); $this->assertEquals('ignore-annotation-test', Http::getSaveFilename()); }
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); }
/** * @param \PHPUnit_Framework_TestSuite $suite */ public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) { foreach ($this->wrappers as $wrapper) { \stream_wrapper_unregister($wrapper); \stream_register_wrapper($wrapper, self::STREAM_WRAPPER_NAME_SPACE . $this->wrapperClass, \STREAM_IS_URL); } Http::setSaveDir($this->saveDir); }
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); }