Skip to content

Commit

Permalink
Add support for data providers
Browse files Browse the repository at this point in the history
  • Loading branch information
mheap committed Nov 9, 2020
1 parent 93107fd commit eae84d4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Printer7.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ protected function relativePath(string $path)
protected function getReflectionFromTest(string $name)
{
list($klass, $method) = explode('::', $name);

// Handle data providers
$parts = explode(" ", $method, 2);
if (count($parts) > 1) {
$method = $parts[0];
}

$c = new \ReflectionClass($klass);
$m = $c->getMethod($method);

Expand Down
7 changes: 7 additions & 0 deletions src/Trait8.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ protected function relativePath(string $path)
protected function getReflectionFromTest(string $name)
{
list($klass, $method) = explode('::', $name);

// Handle data providers
$parts = explode(" ", $method, 2);
if (count($parts) > 1) {
$method = $parts[0];
}

$c = new \ReflectionClass($klass);
$m = $c->getMethod($method);

Expand Down
15 changes: 15 additions & 0 deletions test/_files/PrinterStatesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,20 @@ public function testIncomplete()
{
$this->markTestIncomplete('Incomplete');
}

/**
* @dataProvider demoProvider
*/
public function testProvider($v)
{
$this->assertTrue($v);
}

public function demoProvider()
{
return [
[false]
];
}
}

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

0 comments on commit eae84d4

Please sign in to comment.