Skip to content

Commit d68fbc0

Browse files
committed
Add invalid shape tests to update tests
1 parent 0a10289 commit d68fbc0

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

tests/php/Http/Controllers/Api/ImageAnnotationControllerTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,25 @@ public function update($url)
354354
$this->assertEquals(25, $this->annotation->points[1]);
355355
}
356356

357+
public function testUpdateInvalidPoints()
358+
{
359+
$this->beAdmin();
360+
361+
$this->annotation->points = [0, 1, 2, 3, 4, 5, 6, 7];
362+
$this->annotation->shape_id = Shape::rectangleId();
363+
$this->annotation->save();
364+
365+
$response = $this->json('PUT',"api/v1/image-annotations/{$this->annotation->id}", ['points' => [844.69, 1028.44, 844.69, 1028.44, 844.69, 1028.44, 844.69, 1028.44]]);
366+
$response->assertStatus(422);
367+
368+
$this->annotation->points = [0, 1, 2, 3, 4, 5, 6, 7];
369+
$this->annotation->shape_id = Shape::lineId();
370+
$this->annotation->save();
371+
372+
$response = $this->json('PUT',"api/v1/image-annotations/{$this->annotation->id}", ['points' => [844.69, 1028.44, 844.69, 1028.44, 844.69, 1028.44, 844.69, 1028.44]]);
373+
$response->assertStatus(422);
374+
}
375+
357376
public function testUpdateValidatePoints()
358377
{
359378
$this->updateValidatePoints('api/v1/image-annotations');

tests/php/Http/Controllers/Api/VideoAnnotationControllerTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,28 @@ public function testUpdateValidatePoints()
706706
->assertStatus(422);
707707
}
708708

709+
public function testUpdateInvalidPoints(){
710+
$annotation = VideoAnnotationTest::create([
711+
'shape_id' => Shape::rectangleId(),
712+
'video_id' => $this->video->id,
713+
'frames' => [0],
714+
'points' => [[0,1,2,3,4,5,6,7]],
715+
]);
716+
717+
$this->beAdmin();
718+
719+
$this->putJson("api/v1/video-annotations/{$annotation->id}", ['points' => [[844.69, 1028.44, 844.69, 1028.44, 844.69, 1028.44, 844.69, 1028.44]]])
720+
->assertStatus(422);
721+
722+
$annotation->points = [[0,1,2,3,4,5,6,7]];
723+
$annotation->shape_id = Shape::lineId();
724+
$annotation->save();
725+
726+
$this->putJson("api/v1/video-annotations/{$annotation->id}", ['points' => [[844.69, 1028.44, 844.69, 1028.44, 844.69, 1028.44, 844.69, 1028.44]]])
727+
->assertStatus(422);
728+
729+
}
730+
709731
public function testUpdateWholeFrameAnnotation()
710732
{
711733
$annotation = VideoAnnotationTest::create([

0 commit comments

Comments
 (0)