|
18 | 18 | use GraphQL\Type\Definition\ObjectType; |
19 | 19 | use GraphQL\Type\Definition\StringType; |
20 | 20 | use GraphQL\Type\Definition\Type; |
| 21 | +use Overblog\GraphQLGenerator\Generator\TypeGenerator; |
21 | 22 |
|
22 | 23 | class TypeGeneratorTest extends AbstractTypeGeneratorTest |
23 | 24 | { |
24 | | - /** |
25 | | - * @expectedException \InvalidArgumentException |
26 | | - * @expectedExceptionMessage Skeleton dir "fake" not found. |
27 | | - */ |
28 | 25 | public function testWrongSetSkeletonDirs(): void |
29 | 26 | { |
| 27 | + $this->expectException(\InvalidArgumentException::class); |
| 28 | + $this->expectExceptionMessage('Skeleton dir "fake" not found.'); |
30 | 29 | $this->typeGenerator->setSkeletonDirs(['fake']); |
31 | 30 | } |
32 | 31 |
|
33 | | - /** |
34 | | - * @expectedException \InvalidArgumentException |
35 | | - * @expectedExceptionMessage Skeleton dir must be string or object implementing __toString, "array" given. |
36 | | - */ |
37 | 32 | public function testWrongAddSkeletonDir(): void |
38 | 33 | { |
| 34 | + $this->expectException(\InvalidArgumentException::class); |
| 35 | + $this->expectExceptionMessage('Skeleton dir must be string or object implementing __toString, "array" given.'); |
39 | 36 | $this->typeGenerator->addSkeletonDir([]); |
40 | 37 | } |
41 | 38 |
|
42 | | - /** |
43 | | - * @expectedException \InvalidArgumentException |
44 | | - * @expectedExceptionMessage Skeleton dirs must be array or object implementing \Traversable interface, "object" given. |
45 | | - */ |
46 | 39 | public function testWrongObjectSetSkeletonDir(): void |
47 | 40 | { |
| 41 | + $this->expectException(\InvalidArgumentException::class); |
| 42 | + $this->expectExceptionMessage('Skeleton dirs must be array or object implementing \Traversable interface, "object" given.'); |
48 | 43 | $this->typeGenerator->setSkeletonDirs(new \stdClass()); |
49 | 44 | } |
50 | 45 |
|
51 | | - |
52 | | - /** |
53 | | - * @expectedException \InvalidArgumentException |
54 | | - * @expectedExceptionMessageRegExp /Skeleton "fake" could not be found in .*\/skeleton./ |
55 | | - */ |
56 | 46 | public function testWrongGetSkeletonDirs(): void |
57 | 47 | { |
| 48 | + $this->expectException(\InvalidArgumentException::class); |
| 49 | + $this->expectExceptionMessageRegExp('/Skeleton "fake" could not be found in .*\/skeleton./'); |
58 | 50 | $this->typeGenerator->getSkeletonContent('fake'); |
59 | 51 | } |
60 | 52 |
|
@@ -88,12 +80,10 @@ public function testTypeAlias2String(): void |
88 | 80 | ); |
89 | 81 | } |
90 | 82 |
|
91 | | - /** |
92 | | - * @expectedException \RuntimeException |
93 | | - * @expectedExceptionMessage Malformed ListOf wrapper type "[String" expected "]" but got "g". |
94 | | - */ |
95 | 83 | public function testTypeAlias2StringInvalidListOf(): void |
96 | 84 | { |
| 85 | + $this->expectException(\RuntimeException::class); |
| 86 | + $this->expectExceptionMessage('Malformed ListOf wrapper type "[String" expected "]" but got "g".'); |
97 | 87 | $this->generateClasses([ |
98 | 88 | 'T' => [ |
99 | 89 | 'type' => 'object', |
@@ -158,12 +148,13 @@ public function testCallbackEntryDoesNotTreatObject(): void |
158 | 148 | $this->assertEquals(['result' => 1], $resolveFn()); |
159 | 149 | } |
160 | 150 |
|
161 | | - /** |
162 | | - * @expectedException \RuntimeException |
163 | | - * @expectedExceptionMessage Generator [Overblog\GraphQLGenerator\Generator\TypeGenerator::generateFake] for placeholder "fake" is not callable. |
164 | | - */ |
165 | 151 | public function testProcessInvalidPlaceHoldersReplacements(): void |
166 | 152 | { |
| 153 | + $this->expectException(\RuntimeException::class); |
| 154 | + $this->expectExceptionMessage(\sprintf( |
| 155 | + 'Generator [%s::generateFake] for placeholder "fake" is not callable.', |
| 156 | + TypeGenerator::class |
| 157 | + )); |
167 | 158 | $this->typeGenerator->setSkeletonDirs(__DIR__.'/../Resources/Skeleton'); |
168 | 159 |
|
169 | 160 | $this->generateClasses($this->getConfigs()); |
|
0 commit comments