9b2e466b7e
* Discord notifications for events #433 * Style fixes * Check for blank webhook urls and disable * Cleanup items after review * Changes and fixes * Style fixes * Don't load env for testing * Fix status text * Refactor saving fields/fares so events get the latest data * Cleanup * Style fixes
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use App\Events\UserRegistered;
|
|
use App\Models\Enums\UserState;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Notification;
|
|
|
|
class RegistrationTest extends TestCase
|
|
{
|
|
/**
|
|
* A basic test example.
|
|
*
|
|
* @throws \Exception
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testRegistration()
|
|
{
|
|
Event::fake();
|
|
Notification::fake();
|
|
|
|
$userSvc = app('App\Services\UserService');
|
|
|
|
setting('pilots.auto_accept', true);
|
|
|
|
$attrs = factory(User::class)->make()->toArray();
|
|
$attrs['password'] = Hash::make('secret');
|
|
$user = $userSvc->createUser($attrs);
|
|
|
|
$this->assertEquals(UserState::ACTIVE, $user->state);
|
|
|
|
Event::assertDispatched(UserRegistered::class, function ($e) use ($user) {
|
|
return $e->user->id === $user->id
|
|
&& $e->user->state === $user->state;
|
|
});
|
|
|
|
/*Notification::assertSentTo(
|
|
[$user],
|
|
\App\Notifications\Messages\UserRegistered::class
|
|
);*/
|
|
}
|
|
}
|