-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31b9e6c
commit 5ee37a5
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Tests\Unit; | ||
|
||
use App\User; | ||
use Faker\Factory as FakerFactory; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Str; | ||
use Tests\TestCase; | ||
|
||
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(); | ||
} | ||
} |