@@ -134,10 +134,10 @@ public function testStringRepresentationIsReturned() : void
134
134
public function testFactoryMethod () : void
135
135
{
136
136
$ descriptionFactory = m::mock (DescriptionFactory::class);
137
- $ resolver = new TypeResolver ();
138
- $ context = new Context ('' );
137
+ $ resolver = new TypeResolver ();
138
+ $ context = new Context ('' );
139
139
140
- $ type = new String_ ();
140
+ $ type = new String_ ();
141
141
$ description = new Description ('My Description ' );
142
142
$ descriptionFactory ->shouldReceive ('create ' )->with ('My Description ' , $ context )->andReturn ($ description );
143
143
@@ -148,6 +148,96 @@ public function testFactoryMethod() : void
148
148
$ this ->assertSame ($ description , $ fixture ->getDescription ());
149
149
}
150
150
151
+ /**
152
+ * This test checks whether a braces in a Type are allowed.
153
+ *
154
+ * The advent of generics poses a few issues, one of them is that spaces can now be part of a type. In the past we
155
+ * could purely rely on spaces to split the individual parts of the body of a tag; but when there is a type in play
156
+ * we now need to check for braces.
157
+ *
158
+ * This test tests whether an error occurs demonstrating that the braces were taken into account; this test is still
159
+ * expected to produce an exception because the TypeResolver does not support generics.
160
+ *
161
+ * @covers ::create
162
+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::<public>
163
+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
164
+ * @uses \phpDocumentor\Reflection\TypeResolver
165
+ * @uses \phpDocumentor\Reflection\DocBlock\Description
166
+ * @uses \phpDocumentor\Reflection\Types\String_
167
+ * @uses \phpDocumentor\Reflection\Types\Context
168
+ */
169
+ public function testFactoryMethodWithGenericWithSpace ()
170
+ {
171
+ $ this ->expectException (\InvalidArgumentException::class);
172
+ $ this ->expectExceptionMessage ('"\array<string, string>" is not a valid Fqsen. ' );
173
+
174
+ $ descriptionFactory = m::mock (DescriptionFactory::class);
175
+ $ resolver = new TypeResolver ();
176
+ $ context = new Context ('' );
177
+
178
+ $ description = new Description ('My Description ' );
179
+ $ descriptionFactory ->shouldReceive ('create ' )
180
+ ->with ('My Description ' , $ context )
181
+ ->andReturn ($ description );
182
+
183
+ Throws::create ('array<string, string> My Description ' , $ resolver , $ descriptionFactory , $ context );
184
+ }
185
+
186
+ /**
187
+ * @see self::testFactoryMethodWithGenericWithSpace()
188
+ *
189
+ * @covers ::create
190
+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::<public>
191
+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
192
+ * @uses \phpDocumentor\Reflection\TypeResolver
193
+ * @uses \phpDocumentor\Reflection\DocBlock\Description
194
+ * @uses \phpDocumentor\Reflection\Types\String_
195
+ * @uses \phpDocumentor\Reflection\Types\Context
196
+ */
197
+ public function testFactoryMethodWithGenericWithSpaceAndAddedEmojisToVerifyMultiByteBehaviour ()
198
+ {
199
+ $ this ->expectException (\InvalidArgumentException::class);
200
+ $ this ->expectExceptionMessage ('"\array😁<string,😁 😁string>" is not a valid Fqsen. ' );
201
+
202
+ $ descriptionFactory = m::mock (DescriptionFactory::class);
203
+ $ resolver = new TypeResolver ();
204
+ $ context = new Context ('' );
205
+
206
+ $ description = new Description ('My Description ' );
207
+ $ descriptionFactory ->shouldReceive ('create ' )
208
+ ->with ('My Description ' , $ context )
209
+ ->andReturn ($ description );
210
+
211
+ Throws::create ('array😁<string,😁 😁string> My Description ' , $ resolver , $ descriptionFactory , $ context );
212
+ }
213
+
214
+ /**
215
+ * @covers ::create
216
+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::<public>
217
+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
218
+ * @uses \phpDocumentor\Reflection\TypeResolver
219
+ * @uses \phpDocumentor\Reflection\DocBlock\Description
220
+ * @uses \phpDocumentor\Reflection\Types\String_
221
+ * @uses \phpDocumentor\Reflection\Types\Context
222
+ */
223
+ public function testFactoryMethodWithEmojisToVerifyMultiByteBehaviour ()
224
+ {
225
+ $ descriptionFactory = m::mock (DescriptionFactory::class);
226
+ $ resolver = new TypeResolver ();
227
+ $ context = new Context ('' );
228
+
229
+ $ description = new Description ('My Description ' );
230
+ $ descriptionFactory ->shouldReceive ('create ' )
231
+ ->with ('My Description ' , $ context )
232
+ ->andReturn ($ description );
233
+
234
+ $ fixture = Throws::create ('\My😁Class My Description ' , $ resolver , $ descriptionFactory , $ context );
235
+
236
+ $ this ->assertSame ('\My😁Class My Description ' , (string ) $ fixture );
237
+ $ this ->assertEquals ('\My😁Class ' , $ fixture ->getType ());
238
+ $ this ->assertSame ($ description , $ fixture ->getDescription ());
239
+ }
240
+
151
241
/**
152
242
* @covers ::create
153
243
*/
0 commit comments