phpvms/tests/RegistrationTest.php
Nabeel S 12848091a2
Laravel 9 Update (#1413)
Update to Laravel 9 and PHP 8+

Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
2022-03-14 11:45:18 -04:00

40 lines
1.0 KiB
PHP

<?php
namespace Tests;
use App\Models\Enums\UserState;
use App\Models\User;
use App\Notifications\Messages\AdminUserRegistered;
use App\Services\UserService;
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()
{
$admin = $this->createAdminUser(['name' => 'testRegistration Admin']);
/** @var UserService $userSvc */
$userSvc = app(UserService::class);
$this->updateSetting('pilots.auto_accept', true);
$attrs = User::factory()->make()->makeVisible(['api_key', 'name', 'email'])->toArray();
$attrs['password'] = Hash::make('secret');
$user = $userSvc->createUser($attrs);
$this->assertEquals(UserState::ACTIVE, $user->state);
Notification::assertSentTo([$admin], AdminUserRegistered::class);
Notification::assertNotSentTo([$user], AdminUserRegistered::class);
}
}