-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70db0e0
commit fb6ef43
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
...re/Controllers/CrowdSourcingProject/Problem/CrowdSourcingProjectProblemControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
namespace Feature\Controllers\CrowdSourcingProject\Problem; | ||
|
||
use App\BusinessLogicLayer\lkp\UserRolesLkp; | ||
use App\Models\User; | ||
use App\Models\UserRole; | ||
use Faker\Factory as Faker; | ||
use Tests\TestCase; | ||
|
||
class CrowdSourcingProjectProblemControllerTest extends TestCase { | ||
/** | ||
* @test A guest cannot access the create page | ||
*/ | ||
public function guestCannotAccessCreatePage() { | ||
$response = $this->get(route('problems.create')); | ||
|
||
// 302 is the status code for a redirect (to the login page) | ||
$response->assertStatus(302); | ||
$response->assertRedirect(route('login', ['locale' => 'en'])); | ||
} | ||
|
||
/** | ||
* @test An authenticated non-admin user cannot access the create page | ||
*/ | ||
public function authenticatedNonAdminUserCannotAccessCreatePage() { | ||
$user = User::factory()->make(); | ||
$this->be($user); | ||
|
||
$response = $this->get(route('problems.create')); | ||
|
||
$response->assertStatus(403); | ||
} | ||
|
||
/** | ||
* @test An admin user can access the create page | ||
*/ | ||
public function adminCanAccessCreatePage() { | ||
$user = User::factory() | ||
->has(UserRole::factory()->state(['role_id' => UserRolesLkp::ADMIN])) | ||
->create(); | ||
$this->be($user); | ||
|
||
$response = $this->get(route('problems.create')); | ||
|
||
$response->assertStatus(200); | ||
$response->assertViewIs('loggedin-environment.management.problem.create-edit.form-page'); | ||
} | ||
|
||
/** | ||
* @test An admin user can access the create page | ||
*/ | ||
public function contentManagerCanAccessCreatePage() { | ||
// TODO: Implement | ||
} | ||
|
||
/** | ||
* @test A non-admin user cannot store a project | ||
*/ | ||
public function nonAdminUserCannotStoreProject() { | ||
// TODO: Implement | ||
} | ||
|
||
/** | ||
* @test A content manager can store a project with valid data in the form (no extra translations) | ||
*/ | ||
public function contentManagerCanStoreProjectWithValidDataWithNoExtraTranslations() { | ||
$user = User::factory() | ||
->has(UserRole::factory()->state(['role_id' => UserRolesLkp::CONTENT_MANAGER])) | ||
->create(); | ||
$this->be($user); | ||
|
||
$faker = Faker::create(); | ||
|
||
// TODO: Implement | ||
} | ||
|
||
/** | ||
* @test A content manager can store a project with valid data in the form, with extra translations as well | ||
*/ | ||
public function contentManagerCanStoreProjectWithValidDataWithExtraTranslations() { | ||
$user = User::factory() | ||
->has(UserRole::factory()->state(['role_id' => UserRolesLkp::CONTENT_MANAGER])) | ||
->create(); | ||
$this->be($user); | ||
|
||
$faker = Faker::create(); | ||
|
||
// TODO: Implement | ||
} | ||
|
||
/** | ||
* @test A content manager cannot store a project with invalid data in the form | ||
*/ | ||
public function contentManagerCanotStoreProjectWithInvalidData() { | ||
$user = User::factory() | ||
->has(UserRole::factory()->state(['role_id' => UserRolesLkp::CONTENT_MANAGER])) | ||
->create(); | ||
$this->be($user); | ||
|
||
$faker = Faker::create(); | ||
|
||
// TODO: Implement | ||
} | ||
} |