Skip to content

Commit

Permalink
Merge pull request #112 from biigle/laravel-10
Browse files Browse the repository at this point in the history
Update tests for Laravel 10
  • Loading branch information
mzur authored Oct 4, 2023
2 parents d947ddd + b8d79ac commit 5b890df
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 74 deletions.
35 changes: 17 additions & 18 deletions tests/Http/Controllers/Api/Projects/LargoControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Biigle\Tests\VideoAnnotationTest;
use Biigle\Tests\VideoTest;
use Biigle\Tests\VolumeTest;
use Queue;

class LargoControllerTest extends ApiTestCase
{
Expand Down Expand Up @@ -133,33 +134,30 @@ public function testErrorsVideoAnnotations()

public function testQueueImageAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beEditor();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_image_annotations' => [
$this->imageAnnotationLabel->label_id => [$this->imageAnnotation->id],
],
'changed_image_annotations' => [],
]);
$this->assertEquals('default', $this->dispatchedJobs[0]->queue);
Queue::assertPushedOn('default', ApplyLargoSession::class);
}

public function testQueueVideoAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beEditor();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_video_annotations' => [
$this->videoAnnotationLabel->label_id => [$this->videoAnnotation->id],
],
'changed_video_annotations' => [],
]);
$this->assertEquals('default', $this->dispatchedJobs[0]->queue);
Queue::assertPushedOn('default', ApplyLargoSession::class);
}

public function testDismissImageAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beEditor();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_image_annotations' => [
Expand All @@ -168,11 +166,11 @@ public function testDismissImageAnnotations()
'changed_image_annotations' => [],
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testDismissVideoAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beEditor();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_video_annotations' => [
Expand All @@ -181,11 +179,11 @@ public function testDismissVideoAnnotations()
'changed_video_annotations' => [],
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testDismissForceDenyImageAnnotations()
{
$this->doesntExpectJobs(ApplyLargoSession::class);
$this->imageAnnotationLabel->user_id = $this->admin()->id;
$this->imageAnnotationLabel->save();
$this->beEditor();
Expand All @@ -197,11 +195,11 @@ public function testDismissForceDenyImageAnnotations()
'force' => true,
])
->assertStatus(403);
Queue::assertNotPushed(ApplyLargoSession::class);
}

public function testDismissForceDenyVideoAnnotations()
{
$this->doesntExpectJobs(ApplyLargoSession::class);
$this->videoAnnotationLabel->user_id = $this->admin()->id;
$this->videoAnnotationLabel->save();
$this->beEditor();
Expand All @@ -213,11 +211,11 @@ public function testDismissForceDenyVideoAnnotations()
'force' => true,
])
->assertStatus(403);
Queue::assertNotPushed(ApplyLargoSession::class);
}

public function testDismissForceImageAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beExpert();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_image_annotations' => [
Expand All @@ -227,11 +225,11 @@ public function testDismissForceImageAnnotations()
'force' => true,
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testDismissForceVideoAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beExpert();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_video_annotations' => [
Expand All @@ -241,11 +239,11 @@ public function testDismissForceVideoAnnotations()
'force' => true,
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testChangeOwnImageAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beEditor();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_image_annotations' => [
Expand All @@ -256,11 +254,11 @@ public function testChangeOwnImageAnnotations()
],
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testChangeOwnVideoAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beEditor();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_video_annotations' => [
Expand All @@ -271,11 +269,11 @@ public function testChangeOwnVideoAnnotations()
],
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testChangeOtherImageAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beAdmin();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_image_annotations' => [
Expand All @@ -286,11 +284,11 @@ public function testChangeOtherImageAnnotations()
],
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testChangeOtherVideoAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beAdmin();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_video_annotations' => [
Expand All @@ -301,11 +299,11 @@ public function testChangeOtherVideoAnnotations()
],
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testChangeOtherForceImageAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beExpert();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_image_annotations' => [
Expand All @@ -317,11 +315,11 @@ public function testChangeOtherForceImageAnnotations()
'force' => true,
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testChangeOtherForceVideoAnnotations()
{
$this->expectsJobs(ApplyLargoSession::class);
$this->beExpert();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_video_annotations' => [
Expand All @@ -333,6 +331,7 @@ public function testChangeOtherForceVideoAnnotations()
'force' => true,
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testChangeMultipleImageAnnotations()
Expand All @@ -342,7 +341,6 @@ public function testChangeMultipleImageAnnotations()
'user_id' => $this->editor()->id,
]);

$this->expectsJobs(ApplyLargoSession::class);
$this->beEditor();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_image_annotations' => [
Expand All @@ -355,6 +353,7 @@ public function testChangeMultipleImageAnnotations()
],
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testChangeMultipleVideoAnnotations()
Expand All @@ -364,7 +363,6 @@ public function testChangeMultipleVideoAnnotations()
'user_id' => $this->editor()->id,
]);

$this->expectsJobs(ApplyLargoSession::class);
$this->beEditor();
$this->postJson("/api/v1/projects/{$this->project()->id}/largo", [
'dismissed_video_annotations' => [
Expand All @@ -377,6 +375,7 @@ public function testChangeMultipleVideoAnnotations()
],
])
->assertStatus(200);
Queue::assertPushed(ApplyLargoSession::class);
}

public function testStoreSetJobIdImageAnnotations()
Expand Down
Loading

0 comments on commit 5b890df

Please sign in to comment.