Skip to content

Commit eae84d4

Browse files
committed
Add support for data providers
1 parent 93107fd commit eae84d4

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

src/Printer7.php

+7
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ protected function relativePath(string $path)
9494
protected function getReflectionFromTest(string $name)
9595
{
9696
list($klass, $method) = explode('::', $name);
97+
98+
// Handle data providers
99+
$parts = explode(" ", $method, 2);
100+
if (count($parts) > 1) {
101+
$method = $parts[0];
102+
}
103+
97104
$c = new \ReflectionClass($klass);
98105
$m = $c->getMethod($method);
99106

src/Trait8.php

+7
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ protected function relativePath(string $path)
9393
protected function getReflectionFromTest(string $name)
9494
{
9595
list($klass, $method) = explode('::', $name);
96+
97+
// Handle data providers
98+
$parts = explode(" ", $method, 2);
99+
if (count($parts) > 1) {
100+
$method = $parts[0];
101+
}
102+
96103
$c = new \ReflectionClass($klass);
97104
$m = $c->getMethod($method);
98105

test/_files/PrinterStatesTest.php

+15
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,20 @@ public function testIncomplete()
4545
{
4646
$this->markTestIncomplete('Incomplete');
4747
}
48+
49+
/**
50+
* @dataProvider demoProvider
51+
*/
52+
public function testProvider($v)
53+
{
54+
$this->assertTrue($v);
55+
}
56+
57+
public function demoProvider()
58+
{
59+
return [
60+
[false]
61+
];
62+
}
4863
}
4964

test/states-test.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ PHPUnit\TextUI\Command::main();
1919
::error file=test/_files/PrinterStatesTest.php,line=22::Error: Call to undefined method PrinterStatesTest::isMissing()
2020
::warning file=test/_files/PrinterStatesTest.php,line=32::This is a test warning
2121
::error file=test/_files/PrinterStatesTest.php,line=12::Failed asserting that false is true.
22+
::error file=test/_files/PrinterStatesTest.php,line=54::Failed asserting that false is true.
2223
::warning file=test/_files/PrinterStatesTest.php,line=37::This is a risky test
2324
::warning file=test/_files/PrinterStatesTest.php,line=40::This test did not perform any assertions%0A%0Atest/_files/PrinterStatesTest.php:40

0 commit comments

Comments
 (0)