createArray = [ 'registration_code' => auditionSetting('registrationCode'), 'first_name' => fake()->firstName(), 'last_name' => fake()->lastName(), 'judging_preference' => 'Sarrousaphone', 'cell_phone' => fake()->phoneNumber(), 'email' => fake()->safeEmail(), 'password' => '', 'password_confirmation' => '', ]; }); it('creates a new user', function () { $creator = app(CreateNewUser::class); $newUser = $creator->create($this->createArray); expect(User::where('email', $this->createArray['email'])->exists())->toBeTrue(); }); it('fails when an invalid registration code is used', function () { $creator = app(CreateNewUser::class); $this->createArray['registration_code'] = 'invalid'; $newUser = $creator->create($this->createArray); })->throws(ValidationException::class, 'Incorrect registration code provided'); it('logs user creation', function () { $creator = app(CreateNewUser::class); $newUser = $creator->create($this->createArray); $logEntry = \App\Models\AuditLogEntry::first(); expect($logEntry->message)->toStartWith('Added User '.$newUser->full_name()) ->and($logEntry->affected['users'])->toEqual([$newUser->id]); });