Skip to content

Commit

Permalink
Merge branch 'master' of github.com:scify/Crowdsourcing-Platform
Browse files Browse the repository at this point in the history
  • Loading branch information
PavlosIsaris committed Nov 20, 2024
2 parents d7cd6d9 + 41c7649 commit 1a65e0a
Showing 1 changed file with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,41 @@ public function adminCanAccessCreatePage() {
}

/**
* @test An admin user can access the create page
* @test A contentManager user can access the create page
*/
public function contentManagerCanAccessCreatePage() {
// TODO: Implement
$user = User::factory()
->has(UserRole::factory()->state(['role_id' => UserRolesLkp::CONTENT_MANAGER]))
->create();
$this->be($user);

$response = $this->get(route('problems.create'));

$response->assertStatus(200);
$response->assertViewIs('loggedin-environment.management.problem.create-edit.form-page');
}

/**
* @test A non-admin user cannot store a project
*/
public function nonAdminUserCannotStoreProject() {
// TODO: Implement
$user = User::factory()->create();
$this->be($user);
$faker = Faker::create();
// we need a title with no special characters
$title = $faker->title;
$description = $title . ' description';
$response = $this->withoutMiddleware(VerifyCsrfToken::class) // Disable CSRF only
->post(route('projects.store'), [
'problem-title' => $title,
'problem-description' => $description,
'problem-status' => 1,
'problem-default-language' => 6,
'problem-image' => null,
'problem-owner-project' => 4,
]);

$response->assertStatus(403);
}

/**
Expand Down Expand Up @@ -92,7 +116,7 @@ public function contentManagerCanStoreProjectWithValidDataWithExtraTranslations(
/**
* @test A content manager cannot store a project with invalid data in the form
*/
public function contentManagerCanotStoreProjectWithInvalidData() {
public function contentManagerCannotStoreProjectWithInvalidData() {
$user = User::factory()
->has(UserRole::factory()->state(['role_id' => UserRolesLkp::CONTENT_MANAGER]))
->create();
Expand Down

0 comments on commit 1a65e0a

Please sign in to comment.