Skip to content

Commit

Permalink
Fixed User factory
Browse files Browse the repository at this point in the history
  • Loading branch information
PavlosIsaris committed Oct 4, 2024
1 parent ca6a5bf commit bc3efd7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 5 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use Random\RandomException;

class UserFactory extends Factory {
protected $model = User::class;

/**
* @throws RandomException
*/
public function definition() {
return [
'id' => $this->faker->unique()->numberBetween(1, 10000),
'nickname' => $this->faker->name,
'avatar' => $this->faker->imageUrl(),
'email' => $this->faker->unique()->safeEmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@
use App\Models\UserRole;
use App\Repository\CrowdSourcingProject\CrowdSourcingProjectRepository;
use Faker\Factory as Faker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class CrowdSourcingProjectControllerTest extends TestCase {
use RefreshDatabase;

protected $seed = true;
protected CrowdSourcingProjectRepository $crowdSourcingProjectRepository;

protected function setUp(): void {
Expand Down Expand Up @@ -299,9 +295,9 @@ public function guestCannotStoreProject() {
/**
* @test
*/
public function authenticatedUserCannotStoreProject() {
public function nonAdminUserCannotStoreProject() {
$user = User::factory()->create();
$this->actingAs($user);
$this->be($user);

$response = $this->withoutMiddleware(VerifyCsrfToken::class) // Disable CSRF only
->post(route('projects.store'), [
Expand Down

0 comments on commit bc3efd7

Please sign in to comment.