Skip to content

Commit 904b6e7

Browse files
Merge branch '9.3'
2 parents c9f25ee + b03b938 commit 904b6e7

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

src/Framework/TestSuite.php

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ public function __construct($theClass = '', string $name = '')
228228
continue;
229229
}
230230

231+
if (!TestUtil::isTestMethod($method)) {
232+
continue;
233+
}
234+
231235
$this->addTestMethod($theClass, $method);
232236
}
233237

@@ -866,26 +870,8 @@ protected function createResult(): TestResult
866870
*/
867871
protected function addTestMethod(ReflectionClass $class, ReflectionMethod $method): void
868872
{
869-
if (!TestUtil::isTestMethod($method)) {
870-
return;
871-
}
872-
873873
$methodName = $method->getName();
874874

875-
if (!$method->isPublic()) {
876-
$this->addTest(
877-
new WarningTestCase(
878-
sprintf(
879-
'Test method "%s" in test class "%s" is not public.',
880-
$methodName,
881-
$class->getName()
882-
)
883-
)
884-
);
885-
886-
return;
887-
}
888-
889875
$test = (new TestBuilder)->build($class, $methodName);
890876

891877
if ($test instanceof TestCase || $test instanceof DataProviderTestSuite) {

src/Util/Test.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,10 @@ public static function getHookMethods(string $className): array
576576

577577
public static function isTestMethod(ReflectionMethod $method): bool
578578
{
579+
if (!$method->isPublic()) {
580+
return false;
581+
}
582+
579583
if (strpos($method->getName(), 'test') === 0) {
580584
return true;
581585
}

tests/unit/Framework/TestSuiteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function testNotPublicTestCase(): void
103103
{
104104
$suite = new TestSuite(NotPublicTestCase::class);
105105

106-
$this->assertCount(2, $suite);
106+
$this->assertCount(1, $suite);
107107
}
108108

109109
public function testNotVoidTestCase(): void

0 commit comments

Comments
 (0)