Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #2922 - incorrect "No tests found in class PHPUnit\Framework\*" which happens when there is a test class with @group and provider throwing exception in it, plus tests are ran with --exclude-group for that group, plus there is another class called later (after handing the class from above), and finally when the name of that another class does not match it's file name #2924

Merged
merged 2 commits into from Dec 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Framework/TestSuite.php
Expand Up @@ -348,7 +348,7 @@ public function addTestFile($filename)
}

foreach ($newClasses as $className) {
if ($className === 'PHPUnit_Framework_TestSuite_DataProvider') {
if (strpos($className, 'PHPUnit_Framework') === 0) {
continue;
}

Expand Down
18 changes: 18 additions & 0 deletions tests/TextUI/dataprovider-issue-2922.phpt
@@ -0,0 +1,18 @@
--TEST--
phpunit --exclude-group=foo ../_files/DataProviderIssue2922
--FILE--
<?php
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--exclude-group=foo';
$_SERVER['argv'][3] = __DIR__ . '/../_files/DataProviderIssue2922';

require __DIR__ . '/../bootstrap.php';
PHPUnit_TextUI_Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

. 1 / 1 (100%)

Time: %s, Memory: %s

OK (1 test, 1 assertion)
24 changes: 24 additions & 0 deletions tests/_files/DataProviderIssue2922/FirstTest.php
@@ -0,0 +1,24 @@
<?php

namespace Foo\DataProviderIssue2922;

use PHPUnit\Framework\TestCase;

/**
* @group foo
*/
class FirstTest extends TestCase
{
/**
* @dataProvider provide
*/
public function testFirst($x)
{
$this->assertTrue(true);
}

public function provide()
{
throw new \Exception();
}
}
14 changes: 14 additions & 0 deletions tests/_files/DataProviderIssue2922/SecondTest.php
@@ -0,0 +1,14 @@
<?php

namespace Foo\DataProviderIssue2922;

use PHPUnit\Framework\TestCase;

// the name of the class cannot match file name - if they match all is fine
class SecondHelloWorldTest extends TestCase
{
public function testSecond()
{
$this->assertTrue(true);
}
}