phpvms/tests/RegistrationTest.php

40 lines
1009 B
PHP
Raw Normal View History

<?php
2018-02-21 12:33:09 +08:00
use App\Models\Enums\UserState;
use Illuminate\Support\Facades\Mail;
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();
Mail::fake();
$userSvc = app('App\Services\UserService');
setting('pilots.auto_accept', true);
$user = factory(App\Models\User::class)->create();
$user = $userSvc->createUser($user);
2017-12-31 10:40:32 +08:00
$this->assertEquals(UserState::ACTIVE, $user->state);
Event::assertDispatched(\App\Events\UserRegistered::class, function ($e) use ($user) {
return $e->user->id === $user->id
&& $e->user->state === $user->state;
});
/*Mail::assertSent(\App\Mail\UserRegistered::class, function ($mail) use ($user) {
return $mail->user->id === $user->id
&& $mail->user->state === $user->state;
});*/
}
}