Skip to content

Commit

Permalink
Cleanup: Removes curl library hook using the runkit extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
adri committed Jan 28, 2014
1 parent 2a9c3fc commit e0145eb
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 513 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -9,7 +9,7 @@ before_script:

script:
- mkdir -p build/logs
- phpunit --exclude-group runkit --coverage-clover build/logs/clover.xml tests
- phpunit --coverage-clover build/logs/clover.xml tests

after_script:
- php vendor/bin/coveralls
6 changes: 3 additions & 3 deletions Readme.md
Expand Up @@ -16,7 +16,7 @@ Disclaimer: Doing this in PHP is not as easy as in programming languages which s
* Supports common http functions and extensions
* everyting using [streamWrapper](http://php.net/manual/en/class.streamwrapper.php): fopen(), fread(), file_get_contents(), ... without any modification
* [SoapClient](http://www.php.net/manual/en/soapclient.soapclient.php) by adding `\VCR\VCR\turnOn();` in your `tests/boostrap.php`
* curl(), either using [runkit extension](http://www.php.net/manual/en/book.runkit.php) and `runkit.internal_override=1` in your php.ini or by adding `\VCR\VCR\turnOn();` in your `tests/boostrap.php`
* curl(), by adding `\VCR\VCR::turnOn();` in your `tests/boostrap.php`
* The same request can receive different responses in different tests--just use different cassettes.
* Disables all HTTP requests that you don't explicitly allow (except SoapClient if not configured).
* Request matching is configurable based on HTTP method, URI, host, path, body and headers, or you can easily
Expand Down Expand Up @@ -108,9 +108,8 @@ PHP-VCR depends on:
* HTTP library [Guzzle](http://guzzlephp.org)
* [symfony/yaml](https://github.com/symfony/yaml)
* [beberlei/assert](https://github.com/beberlei/assert)
* (optional) runkit extension with `runkit.internal_override=1` in php.ini if you want to intercept curl

Composer installs all dependencies except extensions like curl or runkit.
Composer installs all dependencies except extensions like curl.

## Run tests

Expand All @@ -123,6 +122,7 @@ phpunit ./tests

## Changelog

* 2014-01-28 Release 1.1.0: Removes curl runkit library hook.
* 2014-01-12 Release 1.0.6: Updates dependencies.
* 2013-10-13 Release 1.0.5: Fixed SOAP support, refactorings.
* 2013-07-22 Release 1.0.4: Updates dependencies.
Expand Down
4 changes: 0 additions & 4 deletions composer.json
Expand Up @@ -25,10 +25,6 @@
"lapistano/proxy-object": "dev-master"
},

"suggest": {
"ext-runkit": "*"
},

"autoload": {
"classmap": ["src/"]
}
Expand Down
5 changes: 2 additions & 3 deletions src/VCR/Configuration.php
Expand Up @@ -10,11 +10,10 @@ class Configuration
private $cassettePath = 'tests/fixtures';

// All are enabled by default
private $enabledLibraryHooks = array('stream_wrapper', 'curl_rewrite', 'soap');
private $enabledLibraryHooks;
private $availableLibraryHooks = array(
'stream_wrapper' => 'VCR\LibraryHooks\StreamWrapper',
'curl_runkit' => 'VCR\LibraryHooks\CurlRunkit',
'curl_rewrite' => 'VCR\LibraryHooks\CurlRewrite',
'curl' => 'VCR\LibraryHooks\Curl',
'soap' => 'VCR\LibraryHooks\Soap',
);

Expand Down
Expand Up @@ -11,7 +11,7 @@
/**
* Library hook for curl functions using include-overwrite.
*/
class CurlRewrite implements LibraryHookInterface
class Curl implements LibraryHookInterface
{

/**
Expand Down
@@ -1,23 +1,23 @@
<?php

namespace VCR\LibraryHooks\CurlRewrite;
namespace VCR\LibraryHooks\Curl;

use VCR\LibraryHooks\AbstractFilter;

class Filter extends AbstractFilter
{
const NAME = 'vcr_curl_rewrite';
const NAME = 'vcr_curl';

private static $replacements = array(
'\VCR\LibraryHooks\CurlRewrite::curl_init(',
'\VCR\LibraryHooks\CurlRewrite::curl_exec(',
'\VCR\LibraryHooks\CurlRewrite::curl_getinfo(',
'\VCR\LibraryHooks\CurlRewrite::curl_setopt(',
'\VCR\LibraryHooks\CurlRewrite::curl_setopt_array(',
'\VCR\LibraryHooks\CurlRewrite::curl_multi_add_handle(',
'\VCR\LibraryHooks\CurlRewrite::curl_multi_remove_handle(',
'\VCR\LibraryHooks\CurlRewrite::curl_multi_exec(',
'\VCR\LibraryHooks\CurlRewrite::curl_multi_info_read('
'\VCR\LibraryHooks\Curl::curl_init(',
'\VCR\LibraryHooks\Curl::curl_exec(',
'\VCR\LibraryHooks\Curl::curl_getinfo(',
'\VCR\LibraryHooks\Curl::curl_setopt(',
'\VCR\LibraryHooks\Curl::curl_setopt_array(',
'\VCR\LibraryHooks\Curl::curl_multi_add_handle(',
'\VCR\LibraryHooks\Curl::curl_multi_remove_handle(',
'\VCR\LibraryHooks\Curl::curl_multi_exec(',
'\VCR\LibraryHooks\Curl::curl_multi_info_read('
);

private static $patterns = array(
Expand Down
214 changes: 0 additions & 214 deletions src/VCR/LibraryHooks/CurlRunkit.php

This file was deleted.

8 changes: 4 additions & 4 deletions src/VCR/VCRFactory.php
Expand Up @@ -2,7 +2,7 @@

namespace VCR;

use VCR\LibraryHooks\CurlRewrite;
use VCR\LibraryHooks\Curl;
use VCR\LibraryHooks\Soap;
use VCR\Util\StreamProcessor;

Expand Down Expand Up @@ -68,10 +68,10 @@ protected function createVCRLibraryHooksSoap()
);
}

protected function createVCRLibraryHooksCurlRewrite()
protected function createVCRLibraryHooksCurl()
{
return new CurlRewrite(
$this->getOrCreate('VCR\\LibraryHooks\\CurlRewrite\\Filter'),
return new Curl(
$this->getOrCreate('VCR\\LibraryHooks\\Curl\\Filter'),
$this->getOrCreate('Util\\StreamProcessor')
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/VCR/ConfigurationTest.php
Expand Up @@ -17,7 +17,7 @@ public function testGetLibraryHooks()
$this->assertEquals(
array(
'VCR\LibraryHooks\StreamWrapper',
'VCR\LibraryHooks\CurlRewrite',
'VCR\LibraryHooks\Curl',
'VCR\LibraryHooks\Soap',
),
$this->config->getLibraryHooks()
Expand Down
@@ -1,6 +1,6 @@
<?php

namespace VCR\LibraryHooks\CurlRewrite;
namespace VCR\LibraryHooks\Curl;


use VCR\VCR_TestCase;
Expand All @@ -13,7 +13,7 @@ class FilterTest extends VCR_TestCase
*/
public function testTransformCode($expected, $code)
{
$filter = $this->getProxyBuilder('\VCR\LibraryHooks\CurlRewrite\Filter')
$filter = $this->getProxyBuilder('\VCR\LibraryHooks\Curl\Filter')
->setMethods(array('transformCode'))
->getProxy();

Expand All @@ -23,14 +23,14 @@ public function testTransformCode($expected, $code)
public function codeSnippetProvider()
{
return array(
'curl_init(' => array('\VCR\LibraryHooks\CurlRewrite::curl_init(', 'CURL_INIT ('),
'curl_exec(' => array('\VCR\LibraryHooks\CurlRewrite::curl_exec(', 'curl_exec('),
'curl_getinfo(' => array('\VCR\LibraryHooks\CurlRewrite::curl_getinfo(', 'curl_getinfo('),
'curl_setopt(' => array('\VCR\LibraryHooks\CurlRewrite::curl_setopt(', 'curl_setopt('),
'curl_multi_add_handle(' => array('\VCR\LibraryHooks\CurlRewrite::curl_multi_add_handle(', 'curl_multi_add_handle('),
'curl_multi_remove_handle(' => array('\VCR\LibraryHooks\CurlRewrite::curl_multi_remove_handle(', 'curl_multi_remove_handle('),
'curl_multi_exec(' => array('\VCR\LibraryHooks\CurlRewrite::curl_multi_exec(', 'curl_multi_exec('),
'curl_multi_info_read(' => array('\VCR\LibraryHooks\CurlRewrite::curl_multi_info_read(', 'curl_multi_info_read('),
'curl_init(' => array('\VCR\LibraryHooks\Curl::curl_init(', 'CURL_INIT ('),
'curl_exec(' => array('\VCR\LibraryHooks\Curl::curl_exec(', 'curl_exec('),
'curl_getinfo(' => array('\VCR\LibraryHooks\Curl::curl_getinfo(', 'curl_getinfo('),
'curl_setopt(' => array('\VCR\LibraryHooks\Curl::curl_setopt(', 'curl_setopt('),
'curl_multi_add_handle(' => array('\VCR\LibraryHooks\Curl::curl_multi_add_handle(', 'curl_multi_add_handle('),
'curl_multi_remove_handle(' => array('\VCR\LibraryHooks\Curl::curl_multi_remove_handle(', 'curl_multi_remove_handle('),
'curl_multi_exec(' => array('\VCR\LibraryHooks\Curl::curl_multi_exec(', 'curl_multi_exec('),
'curl_multi_info_read(' => array('\VCR\LibraryHooks\Curl::curl_multi_info_read(', 'curl_multi_info_read('),
);
}
}

0 comments on commit e0145eb

Please sign in to comment.