Files
exchange/tests/Feature/SettingsTest.php
Jack Goh 5df307a165 make all test pass
updated seeder to be informative
fix seeder error on test
2018-08-01 15:30:19 +08:00

55 lines
1.3 KiB
PHP

<?php
namespace Tests\Feature;
use App\User;
use Tests\TestCase;
use App\Role;
use Illuminate\Support\Facades\Hash;
class SettingsTest extends TestCase
{
/** @var \App\User */
protected $user;
public function setUp()
{
parent::setUp();
$this->user = factory(User::class)->create();
$this->user->attachRole(Role::Where('name','member')->first());
}
/** @test */
public function update_profile_info()
{
$response = $this->actingAs($this->user)
->patchJson('/api/settings/profile', [
'name' => 'Test User',
'email' => 'test@test.app',
])
->assertSuccessful()
->assertJsonStructure(['id', 'name', 'email']);
$this->assertDatabaseHas('users', [
'id' => $this->user->id,
'name' => 'Test User',
'email' => 'test@test.app',
]);
}
/** @test */
public function update_password()
{
$this->actingAs($this->user)
->patchJson('/api/settings/password', [
'password' => 'updated',
'password_confirmation' => 'updated',
])
->assertSuccessful();
$this->assertTrue(Hash::check('updated', $this->user->password));
}
}