Skip to content

Commit

Permalink
Merge branch '8.5' into 9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Sep 27, 2020
2 parents b77f2da + 155e5b0 commit b03b938
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
22 changes: 4 additions & 18 deletions src/Framework/TestSuite.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ public function __construct($theClass = '', string $name = '')
continue;
}

if (!TestUtil::isTestMethod($method)) {
continue;
}

$this->addTestMethod($theClass, $method);
}

Expand Down Expand Up @@ -866,26 +870,8 @@ protected function createResult(): TestResult
*/
protected function addTestMethod(ReflectionClass $class, ReflectionMethod $method): void
{
if (!TestUtil::isTestMethod($method)) {
return;
}

$methodName = $method->getName();

if (!$method->isPublic()) {
$this->addTest(
new WarningTestCase(
sprintf(
'Test method "%s" in test class "%s" is not public.',
$methodName,
$class->getName()
)
)
);

return;
}

$test = (new TestBuilder)->build($class, $methodName);

if ($test instanceof TestCase || $test instanceof DataProviderTestSuite) {
Expand Down
4 changes: 4 additions & 0 deletions src/Util/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ public static function getHookMethods(string $className): array

public static function isTestMethod(ReflectionMethod $method): bool
{
if (!$method->isPublic()) {
return false;
}

if (strpos($method->getName(), 'test') === 0) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Framework/TestSuiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function testNotPublicTestCase(): void
{
$suite = new TestSuite(NotPublicTestCase::class);

$this->assertCount(2, $suite);
$this->assertCount(1, $suite);
}

public function testNotVoidTestCase(): void
Expand Down

0 comments on commit b03b938

Please sign in to comment.