mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 04:24:01 +00:00
587234f205
updated jwt kernel from getuserfromtoken to autenticate updated verify response from data.token to token updated user factory changed routes for update user profile to from PUT to PATCH added register with actingAs user added test update freightforwarder user added test update importer user
65 lines
1.4 KiB
PHP
65 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use Tests\TestCase;
|
|
use Illuminate\Foundation\Testing\WithFaker;
|
|
use App\User;
|
|
use Artisan;
|
|
|
|
class RegisterTest extends TestCase
|
|
{
|
|
protected $user;
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
Artisan::call('db:seed');
|
|
$this->user = factory(User::class)->create();
|
|
}
|
|
|
|
public function testVerification()
|
|
{
|
|
$response = $this->json('POST', '/api/send-verification', ['phone' => '0123456789']);
|
|
$response
|
|
->assertStatus(200)
|
|
->assertJson([
|
|
'success' => true,
|
|
]);
|
|
|
|
$response = $this->json('POST', '/api/verify', ['phone' => '0123456789', 'token' => '1234']);
|
|
$response
|
|
->assertStatus(200)
|
|
->assertJson([
|
|
'success' => true,
|
|
]);
|
|
|
|
|
|
$token = $response->json()['token'];
|
|
}
|
|
|
|
public function testUpdateFFUser()
|
|
{
|
|
$this->actingAs($this->user)
|
|
->patchJson('/api/user', [
|
|
'freightforwarder',
|
|
'password' => 'updated',
|
|
'password_confirmation' => 'updated',
|
|
])
|
|
|
|
->assertSuccessful();
|
|
}
|
|
|
|
public function testUpdateImporterUser()
|
|
{
|
|
$this->actingAs($this->user)
|
|
->patchJson('/api/user', [
|
|
'importer',
|
|
'password' => 'updated',
|
|
'password_confirmation' => 'updated',
|
|
])
|
|
->assertSuccessful();
|
|
}
|
|
|
|
|
|
}
|