@@ -44,7 +44,7 @@ protected function setUp(): void
44
44
/**
45
45
* @test
46
46
*/
47
- public function testCreateTopicImage ()
47
+ public function testCreateTopicImage (): void
48
48
{
49
49
Storage::fake ('local ' );
50
50
@@ -70,7 +70,7 @@ public function testCreateTopicImage()
70
70
]);
71
71
}
72
72
73
- public function testCreateTopicAudio ()
73
+ public function testCreateTopicAudio (): void
74
74
{
75
75
Storage::fake ('local ' );
76
76
@@ -97,7 +97,7 @@ public function testCreateTopicAudio()
97
97
]);
98
98
}
99
99
100
- public function testCreateTopicPdf ()
100
+ public function testCreateTopicPdf (): void
101
101
{
102
102
Storage::fake ();
103
103
@@ -131,40 +131,51 @@ public function testCreateTopicPdf()
131
131
]);
132
132
}
133
133
134
- public function testCreateTopicVideo ()
134
+ public function testCreateTopicVideo (): void
135
135
{
136
136
Storage::fake ('local ' );
137
137
Event::fake (TopicTypeChanged::class);
138
138
139
139
$ file = new UploadedFile (__DIR__ . '/../mocks/video.mp4 ' , 'video.mp4 ' , 'video/mp4 ' , null , true );
140
140
141
- $ this ->response = $ this ->actingAs ($ this ->user , 'api ' )
141
+ $ this ->response = $ this
142
+ ->actingAs ($ this ->user , 'api ' )
142
143
->withHeaders (['Accept ' => 'application/json ' ])
143
144
->post ('/api/admin/topics ' , [
144
145
'title ' => 'Hello World ' ,
145
146
'lesson_id ' => $ this ->lesson ->id ,
146
147
'topicable_type ' => Video::class,
147
148
'value ' => $ file ,
149
+ ])
150
+ ->assertJsonStructure ([
151
+ 'data ' => [
152
+ 'topicable ' => [
153
+ 'id ' ,
154
+ 'value ' ,
155
+ 'url ' ,
156
+ 'poster ' ,
157
+ 'poster_url ' ,
158
+ 'width ' ,
159
+ 'height ' ,
160
+ 'length '
161
+ ]
162
+ ]
148
163
]);
149
164
150
165
$ this ->response ->assertStatus (201 );
151
166
152
167
$ data = $ this ->response ->getData ()->data ;
153
168
$ path = $ data ->topicable ->value ;
154
169
155
-
156
170
Storage::disk ('local ' )->assertExists ('/ ' . $ path );
157
- $ this ->assertDatabaseHas ('topic_videos ' , [
158
- 'value ' => $ path ,
159
- 'width ' => 240 ,
160
- 'height ' => 240 ,
161
- 'length ' => 3667
162
- ]);
171
+ $ this ->assertEquals (240 , $ data ->topicable ->height );
172
+ $ this ->assertEquals (240 , $ data ->topicable ->width );
173
+ $ this ->assertEqualsWithDelta (3666 , $ data ->topicable ->length , 1 );
163
174
164
175
Event::assertDispatched (TopicTypeChanged::class);
165
176
}
166
177
167
- public function testCreateTopicRichtext ()
178
+ public function testCreateTopicRichtext (): void
168
179
{
169
180
$ this ->response = $ this ->actingAs ($ this ->user , 'api ' )
170
181
->withHeaders (['Accept ' => 'application/json ' ])
@@ -185,7 +196,7 @@ public function testCreateTopicRichtext()
185
196
]);
186
197
}
187
198
188
- public function testCreateTopicH5P ()
199
+ public function testCreateTopicH5P (): void
189
200
{
190
201
Event::fake (TopicTypeChanged::class);
191
202
@@ -211,7 +222,7 @@ public function testCreateTopicH5P()
211
222
Event::assertDispatched (TopicTypeChanged::class);
212
223
}
213
224
214
- public function testCreateTopicScormSco ()
225
+ public function testCreateTopicScormSco (): void
215
226
{
216
227
Event::fake (TopicTypeChanged::class);
217
228
$ scormSco = ScormScoHelper::getScormSco ();
@@ -237,7 +248,7 @@ public function testCreateTopicScormSco()
237
248
Event::assertDispatched (TopicTypeChanged::class);
238
249
}
239
250
240
- public function testCreateTopicCmi5Au ()
251
+ public function testCreateTopicCmi5Au (): void
241
252
{
242
253
if (!class_exists (\EscolaLms \Cmi5 \EscolaLmsCmi5ServiceProvider::class)) {
243
254
$ this ->markTestSkipped ('Require cmi5 package ' );
@@ -266,7 +277,7 @@ public function testCreateTopicCmi5Au()
266
277
Event::assertDispatched (TopicTypeChanged::class);
267
278
}
268
279
269
- public function testCreateTopicOEmbed ()
280
+ public function testCreateTopicOEmbed (): void
270
281
{
271
282
Event::fake (TopicTypeChanged::class);
272
283
@@ -291,7 +302,7 @@ public function testCreateTopicOEmbed()
291
302
Event::assertDispatched (TopicTypeChanged::class);
292
303
}
293
304
294
- public function testCreateTopicNoLesson ()
305
+ public function testCreateTopicNoLesson (): void
295
306
{
296
307
$ this ->response = $ this ->withHeaders ([
297
308
'Accept ' => 'application/json ' ,
@@ -307,7 +318,7 @@ public function testCreateTopicNoLesson()
307
318
$ this ->response ->assertStatus (401 );
308
319
}
309
320
310
- public function testCreateTopicImageNoFile ()
321
+ public function testCreateTopicImageNoFile (): void
311
322
{
312
323
$ this ->response = $ this ->actingAs ($ this ->user , 'api ' )->withHeaders ([
313
324
'Accept ' => 'application/json ' ,
@@ -324,7 +335,7 @@ public function testCreateTopicImageNoFile()
324
335
$ this ->response ->assertStatus (422 );
325
336
}
326
337
327
- public function testCreateTopicAudioNoFile ()
338
+ public function testCreateTopicAudioNoFile (): void
328
339
{
329
340
$ this ->response = $ this ->actingAs ($ this ->user , 'api ' )->withHeaders ([
330
341
'Accept ' => 'application/json ' ,
@@ -341,7 +352,7 @@ public function testCreateTopicAudioNoFile()
341
352
$ this ->response ->assertStatus (422 );
342
353
}
343
354
344
- public function testCreateTopicVideoNoFile ()
355
+ public function testCreateTopicVideoNoFile (): void
345
356
{
346
357
$ course = Course::factory ()->create ();
347
358
@@ -360,7 +371,7 @@ public function testCreateTopicVideoNoFile()
360
371
$ this ->response ->assertStatus (422 );
361
372
}
362
373
363
- public function testCreateTopicWrongClass ()
374
+ public function testCreateTopicWrongClass (): void
364
375
{
365
376
$ this ->response = $ this ->actingAs ($ this ->user , 'api ' )->withHeaders ([
366
377
'Accept ' => 'application/json ' ,
0 commit comments