|
9 | 9 | */
|
10 | 10 | namespace PHPUnit\Framework;
|
11 | 11 |
|
12 |
| -use function assert; |
13 | 12 | use EmptyDataProviderTest;
|
14 | 13 | use ModifiedConstructorTestCase;
|
15 |
| -use PHPUnit\Framework\MockObject\MockObject; |
16 | 14 | use ReflectionClass;
|
17 | 15 | use TestWithAnnotations;
|
18 | 16 |
|
|
21 | 19 | */
|
22 | 20 | final class TestBuilderTest extends TestCase
|
23 | 21 | {
|
24 |
| - public function testCreateTestForConstructorlessTestClass(): void |
25 |
| - { |
26 |
| - $reflector = $this->getMockBuilder(ReflectionClass::class) |
27 |
| - ->setConstructorArgs([$this]) |
28 |
| - ->getMock(); |
29 |
| - |
30 |
| - assert($reflector instanceof MockObject); |
31 |
| - assert($reflector instanceof ReflectionClass); |
32 |
| - |
33 |
| - $reflector->expects($this->once()) |
34 |
| - ->method('getConstructor') |
35 |
| - ->willReturn(null); |
36 |
| - |
37 |
| - $reflector->expects($this->once()) |
38 |
| - ->method('isInstantiable') |
39 |
| - ->willReturn(true); |
40 |
| - |
41 |
| - $reflector->expects($this->once()) |
42 |
| - ->method('getName') |
43 |
| - ->willReturn(__CLASS__); |
44 |
| - |
45 |
| - $this->expectException(Exception::class); |
46 |
| - $this->expectExceptionMessage('No valid test provided.'); |
47 |
| - |
48 |
| - (new TestBuilder)->build($reflector, 'TestForConstructorlessTestClass'); |
49 |
| - } |
50 |
| - |
51 |
| - public function testCreateTestForNotInstantiableTestClass(): void |
52 |
| - { |
53 |
| - $reflector = $this->getMockBuilder(ReflectionClass::class) |
54 |
| - ->setConstructorArgs([$this]) |
55 |
| - ->getMock(); |
56 |
| - |
57 |
| - assert($reflector instanceof MockObject); |
58 |
| - assert($reflector instanceof ReflectionClass); |
59 |
| - |
60 |
| - $reflector->expects($this->once()) |
61 |
| - ->method('isInstantiable') |
62 |
| - ->willReturn(false); |
63 |
| - |
64 |
| - $reflector->expects($this->once()) |
65 |
| - ->method('getName') |
66 |
| - ->willReturn('foo'); |
67 |
| - |
68 |
| - $test = (new TestBuilder)->build($reflector, 'TestForNonInstantiableTestClass'); |
69 |
| - $this->assertInstanceOf(WarningTestCase::class, $test); |
70 |
| - /* @var WarningTestCase $test */ |
71 |
| - $this->assertSame('Cannot instantiate class "foo".', $test->getMessage()); |
72 |
| - } |
73 |
| - |
74 | 22 | public function testCreateTestForTestClassWithModifiedConstructor(): void
|
75 | 23 | {
|
76 | 24 | $test = (new TestBuilder)->build(new ReflectionClass(ModifiedConstructorTestCase::class), 'testCase');
|
|
0 commit comments