Skip to content

Commit

Permalink
Fix unit tests to match the updated routes
Browse files Browse the repository at this point in the history
  • Loading branch information
v-stamenova committed Sep 25, 2024
1 parent 6a4bfad commit 80e08b8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
4 changes: 2 additions & 2 deletions tests/Feature/BoothControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function approve_updates_booth_and_redirects_to_crew()
}))->create();

$response = $this->actingAs($user)
->post(route('moderator.booths.approve', [$company->booth, 'approved' => true]));
->post(route('moderator.booths.approve', [$company->booth, 'isApproved' => true]));

$response->assertRedirect(route('moderator.booths.show', ['booth' => $company->booth]));
$company->refresh();
Expand All @@ -171,7 +171,7 @@ public function approve_denies_action_to_participant()
$company = Company::factory()->has(Booth::factory(1))->create();

$response = $this->actingAs($user)
->post(route('moderator.booths.approve', [$company->booth, 'approved' => true]));
->post(route('moderator.booths.approve', [$company->booth, 'isApproved' => true]));

$response->assertStatus(403);
$this->assertEquals(0, $company->booth->is_approved);
Expand Down
15 changes: 6 additions & 9 deletions tests/Feature/CompanyControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,8 @@ public function event_organizer_can_approve_company()
$user->assignRole($role);
}))->create();

$response = $this->actingAs($user)->post(route('moderator.companies.approve', $company), [
'approved' => true
]);
$response = $this->actingAs($user)
->post(route('moderator.companies.approve', ['company' => $company, 'isApproved' => 1]));

$response->assertRedirect(route('moderator.companies.show', $company));
$this->assertDatabaseHas('companies', [
Expand All @@ -228,9 +227,8 @@ public function event_organizer_can_reject_company()
$user->assignRole($role);
}))->create();

$response = $this->actingAs($user)->post(route('moderator.companies.approve', $company), [
'approved' => false
]);
$response = $this->actingAs($user)
->post(route('moderator.companies.approve', ['company' => $company, 'isApproved' => 0]));

$response->assertRedirect(route('moderator.companies.index'));
$this->assertDatabaseMissing('companies', ['name' => $company->name]);
Expand All @@ -244,9 +242,8 @@ public function participant_cannot_approve_or_reject_company()
$company->is_approved = false;
$company->save();

$response = $this->actingAs($user)->post(route('moderator.companies.approve', $company), [
'approved' => true
]);
$response = $this->actingAs($user)
->post(route('moderator.companies.approve', ['company' => $company, 'isApproved' => true]));

$response->assertStatus(403);
$this->assertEquals(0, $company->is_approved);
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/PresentationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function event_organizer_can_approve_presentation()
$presentation = Presentation::factory()->create(['is_approved' => false]);

$response = $this->actingAs($user)
->post(route('moderator.presentations.approve', $presentation), ['approved' => true]);
->post(route('moderator.presentations.approve', ['presentation' => $presentation, 'isApproved' => 1]));

$response->assertRedirect(route('moderator.presentations.show', $presentation));
$this->assertDatabaseHas('presentations', ['id' => $presentation->id, 'is_approved' => true]);
Expand All @@ -184,7 +184,7 @@ public function event_organizer_can_reject_presentation()
$presentation = Presentation::factory()->create(['is_approved' => true]);

$response = $this->actingAs($user)
->post(route('moderator.presentations.approve', $presentation), ['approved' => false]);
->post(route('moderator.presentations.approve', ['presentation' => $presentation, 'isApproved' => 0]));

$response->assertRedirect(route('moderator.presentations.index'));
$this->assertDatabaseMissing('presentations', ['id' => $presentation->id, 'is_approved' => false]);
Expand All @@ -199,7 +199,7 @@ public function participant_cannot_approve_or_reject_presentation()
$presentation->save();

$response = $this->actingAs($user)
->post(route('moderator.presentations.approve', $presentation), ['approved' => true]);
->post(route('moderator.presentations.approve', ['presentation' => $presentation, 'isApproved' => 1]));

$response->assertStatus(403);
$this->assertDatabaseHas('presentations', ['id' => $presentation->id, 'is_approved' => false]);
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/SponsorshipControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function event_organizer_can_approve_sponsorship()
}))->create(['is_approved' => 1,'sponsorship_id' => 1]);

$response = $this->actingAs($user)
->post(route('moderator.sponsorships.approve', $company), ['approved' => true]);
->post(route('moderator.sponsorships.approve', ['company' => $company, 'isApproved' => 1]));

$response->assertRedirect(route('moderator.sponsorships.show', $company));
$this->assertEquals(1, $company->refresh()->is_sponsorship_approved);
Expand All @@ -145,7 +145,7 @@ public function event_organizer_can_reject_sponsorship()
}))->create(['sponsorship_id' => 1]);

$response = $this->actingAs($user)
->post(route('moderator.sponsorships.approve', $company), ['approved' => false]);
->post(route('moderator.sponsorships.approve', ['company' => $company, 'isApproved' => 0]));

$response->assertRedirect(route('moderator.sponsorships.index'));
$this->assertNull($company->refresh()->is_sponsorship_approved);
Expand All @@ -158,7 +158,7 @@ public function user_cannot_approve_or_reject_sponsorship_without_permission()
$company = Company::factory()->create(['sponsorship_id' => 1]);

$response = $this->actingAs($user)
->post(route('moderator.sponsorships.approve', $company), ['approved' => true]);
->post(route('moderator.sponsorships.approve', ['company' => $company, 'isApproved' => 1]));

$response->assertStatus(403);
$this->assertDatabaseHas('companies', ['id' => $company->id]);
Expand Down

0 comments on commit 80e08b8

Please sign in to comment.