phpvms/tests/RegistrationTest.php

44 lines
1.1 KiB
PHP
Raw Normal View History

<?php
use App\Events\UserRegistered;
2018-02-21 12:33:09 +08:00
use App\Models\Enums\UserState;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Notification;
class RegistrationTest extends TestCase
{
/**
* A basic test example.
*
2018-08-27 02:50:08 +08:00
* @throws Exception
2018-08-27 02:51:47 +08:00
*
* @return void
*/
public function testRegistration()
{
Event::fake();
Notification::fake();
$userSvc = app('App\Services\UserService');
setting('pilots.auto_accept', true);
$attrs = factory(App\Models\User::class)->make()->toArray();
$attrs['password'] = Hash::make('secret');
$user = $userSvc->createUser($attrs);
2017-12-31 10:40:32 +08:00
$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
);*/
}
}