Skip to content

Commit cc1e9f6

Browse files
committed
Ensure annotations work on tests that use dataProviders
By default $test->getName() appends the name of the data set (e.g. testInterceptsWithAnnotationsWhenUsingDataProvider with data set #0). This means that the reflection to get the doc block doesn't work.
1 parent e29c11d commit cc1e9f6

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

PHPUnit/Util/Log/VCR.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
122122
public function startTest(PHPUnit_Framework_Test $test)
123123
{
124124
$class = get_class($test);
125-
$method = $test->getName();
125+
$method = $test->getName(FALSE);
126126

127127
if (!method_exists($class, $method)) {
128128
return;

tests/PHPUnit/Util/Log/VCRTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,22 @@ public function testInterceptsWithAnnotations()
2323
$result = file_get_contents('http://google.com');
2424
$this->assertEquals('This is a annotation test dummy.', $result, 'Call was not intercepted (using annotations).');
2525
}
26+
27+
/**
28+
* @vcr unittest_annotation_test
29+
* @dataProvider aDataProvider
30+
*/
31+
public function testInterceptsWithAnnotationsWhenUsingDataProvider($dummyValue)
32+
{
33+
// Content of tests/fixtures/unittest_annotation_test: "This is a annotation test dummy".
34+
$result = file_get_contents('http://google.com');
35+
$this->assertEquals('This is a annotation test dummy.', $result, 'Call was not intercepted (using annotations with data provider).');
36+
}
37+
38+
public function aDataProvider()
39+
{
40+
return array(
41+
array(null)
42+
);
43+
}
2644
}

0 commit comments

Comments
 (0)