mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 12:24:09 +00:00
5df307a165
updated seeder to be informative fix seeder error on test
58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\User;
|
|
use Tests\TestCase;
|
|
use App\Role;
|
|
|
|
class LoginTest extends TestCase
|
|
{
|
|
/** @var \App\User */
|
|
protected $user;
|
|
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
$this->user = factory(User::class)->create();
|
|
$this->withoutExceptionHandling();
|
|
}
|
|
|
|
/** @test */
|
|
// public function authenticate()
|
|
// {
|
|
// $this->postJson('/api/login', [
|
|
// 'email' => $this->user->email,
|
|
// 'password' => 'secret',
|
|
// ])
|
|
// ->assertSuccessful()
|
|
// ->assertJsonStructure(['token', 'expires_in'])
|
|
// ->assertJson(['token_type' => 'bearer']);
|
|
// }
|
|
|
|
/** @test */
|
|
public function fetch_the_current_user()
|
|
{
|
|
$this->user->attachRole(Role::Where('name','member')->first());
|
|
$response = $this->actingAs($this->user)
|
|
->getJson('/api/user')
|
|
->assertSuccessful()
|
|
->assertJsonStructure(['id', 'name', 'email', 'marking']);
|
|
}
|
|
|
|
/** @test */
|
|
// public function log_out()
|
|
// {
|
|
// $token = $this->postJson('/api/login', [
|
|
// 'email' => $this->user->email,
|
|
// 'password' => 'secret',
|
|
// ])->json()['token'];
|
|
|
|
// $this->postJson("/api/logout?token=$token")
|
|
// ->assertSuccessful();
|
|
|
|
// $this->getJson("/api/user?token=$token")
|
|
// ->assertStatus(401);
|
|
// }
|
|
}
|