test_config

This commit is contained in:
KNaveenraj-ladybird
2023-10-25 16:41:51 +05:30
parent 7408c05646
commit 5cbec3fd86
4 changed files with 108 additions and 30 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace Tests\Unit;
use App\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Tests\TestCase;
use Faker\Factory as FakerFactory;
class ExampleTest extends TestCase
{
/**
* A basic unit test example.
*
* @return void
*/
public function test_example()
{
$this->assertTrue(true);
}
public function test_store_user()
{
$faker = FakerFactory::create();
//Create User -> Agent
$str = Str::random(10);
$password = Hash::make($str);
$email = $faker->unique()->email();
$user = new User([
'first_name' => $faker->firstName(),
'last_name' => $faker->lastName(),
'email' => $email,
'user_name' => $faker->unique()->userName(),
'password' => $password,
'active' => 1,
'role' => 'user',
]);
$user->save();
// Check if data is inserted
$this->assertDatabaseHas('users', ['email' => $email]);
// Authenticate as the created user
$this->actingAs($user);
$this->assertAuthenticated();
}
}