mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 04:24:01 +00:00
Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/izyim-api into Aqeeb/company
# Conflicts: # routes/web.php
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicTest()
|
||||
{
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,8 @@ class LoginTest extends TestCase
|
||||
*/
|
||||
public function testExample()
|
||||
{
|
||||
$response = $this->json('POST', '/api/login', ['phone' => '01234567890','password' => 'secret']);
|
||||
|
||||
$response = $this->json('POST', '/api/login', ['phone' => '0123456789','password' => 'secret']);
|
||||
$response
|
||||
->assertStatus(200)
|
||||
->assertJsonStructure(['data']);
|
||||
->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,23 +4,61 @@ namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\User;
|
||||
use Artisan;
|
||||
|
||||
class RegisterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
// public function testRegister()
|
||||
// {
|
||||
// $response = $this->json('POST', '/api/register', ['name' => 'Sally']);
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
// $response
|
||||
// ->assertStatus(201)
|
||||
// ->assertJson([
|
||||
// 'created' => true,
|
||||
// ]);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -3,8 +3,28 @@
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
||||
use App\User;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
use CreatesApplication;
|
||||
protected $user;
|
||||
|
||||
public function actingAs(UserContract $user, $driver = null)
|
||||
{
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function call($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
|
||||
{
|
||||
if ($this->user) {
|
||||
$server['HTTP_AUTHORIZATION'] = 'Bearer ' . \JWTAuth::fromUser($this->user);
|
||||
}
|
||||
$server['HTTP_ACCEPT'] = 'application/json';
|
||||
return parent::call($method, $uri, $parameters, $cookies, $files, $server, $content);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user