Skip to content

Commit 9d2a89f

Browse files
committed
Merge pull request php-vcr#15 from php-vcr/CurlRewriteTransformationError
Fixed: error when transforming curl method names to local method name.
2 parents 84604a7 + d016bc9 commit 9d2a89f

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/VCR/LibraryHooks/CurlRewrite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ protected static function buildLocalMethodName($method)
225225
$localMethod = preg_replace_callback(
226226
'/_(.?)/',
227227
function($matches) {
228-
return strtoupper($matches[0]);
228+
return strtoupper($matches[1]);
229229
},
230230
$localMethod
231231
);

tests/VCR/LibraryHooks/CurlRewriteTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,23 @@ public function testShouldNotThrowErrorWhenEnabledTwice()
174174
$this->curlHook->disable();
175175
}
176176

177+
/**
178+
* @dataProvider curlMethodsProvider
179+
*/
180+
public function testBuildLocalMethodName($expected, $method)
181+
{
182+
$this->assertEquals($expected, CurlRewriteProxy::buildLocalMethodName($method));
183+
}
184+
public function curlMethodsProvider()
185+
{
186+
return array(
187+
'curl_multi_add_handler' => array('multiAddHandler', 'curl_multi_add_handler'),
188+
'curl_add_handler' => array('addHandler', 'curl_add_handler'),
189+
'not a curl function' => array('exec', 'curl_exec'),
190+
);
191+
}
192+
193+
177194
/**
178195
* @return \callable
179196
*/
@@ -185,3 +202,12 @@ protected function getTestCallback($handleRequestCallback = null)
185202
};
186203
}
187204
}
205+
206+
207+
class CurlRewriteProxy extends CurlRewrite
208+
{
209+
public static function buildLocalMethodName($method)
210+
{
211+
return parent::buildLocalMethodName($method);
212+
}
213+
}

0 commit comments

Comments
 (0)