Skip to content

Commit c15c1a9

Browse files
Add tests
1 parent ac83781 commit c15c1a9

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/_files/NoTestCase.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture;
11+
12+
final class NoTestCase
13+
{
14+
}

tests/unit/Framework/TestSuiteTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111

1212
use PHPUnit\Framework\Attributes\CoversClass;
1313
use PHPUnit\Framework\Attributes\Small;
14+
use PHPUnit\TestFixture\AbstractTestCase;
1415
use PHPUnit\TestFixture\DependencyFailureTest;
1516
use PHPUnit\TestFixture\DependencyOnClassTest;
1617
use PHPUnit\TestFixture\DependencySuccessTest;
1718
use PHPUnit\TestFixture\MultiDependencyTest;
19+
use PHPUnit\TestFixture\NoTestCase;
1820
use PHPUnit\TestFixture\NotPublicTestCase;
1921
use ReflectionClass;
2022

@@ -111,4 +113,22 @@ public function testResolverOnlyUsesSuitesAndCases(): void
111113
DependencyFailureTest::class . '::class',
112114
], $suite->requires(), 'Required test names incorrect');
113115
}
116+
117+
public function testRejectsAbstractTestClass(): void
118+
{
119+
$suite = TestSuite::empty('the-test-suite');
120+
121+
$this->expectException(Exception::class);
122+
123+
$suite->addTestSuite(new ReflectionClass(AbstractTestCase::class));
124+
}
125+
126+
public function testRejectsClassThatDoesNotExtendTestClass(): void
127+
{
128+
$suite = TestSuite::empty('the-test-suite');
129+
130+
$this->expectException(Exception::class);
131+
132+
$suite->addTestSuite(new ReflectionClass(NoTestCase::class));
133+
}
114134
}

0 commit comments

Comments
 (0)