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