updated docker to fix faker image error

updated on user phone verification, create a company profile
removed company store function
updated company with user relationship
added company factory
moved company routes into authenticated routes
updated company test
renamed "verify" routes to "verify-phone"
This commit is contained in:
jack
2018-05-28 17:14:09 +08:00
parent ff4e7764d5
commit c64c526d98
10 changed files with 114 additions and 78 deletions
@@ -7,40 +7,31 @@ use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Artisan;
use App\User;
use App\Company;
class CompanyTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
protected $company;
protected $user;
public function setUp()
{
$this->assertTrue(true);
parent::setUp();
Artisan::call('db:seed');
$this->user = factory(User::class)->create();
$this->company = $this->user->each(function ($u) {
factory(Company::class)->create([
'user_id' => $u->id,
]);
});
}
public function testPOST()
public function testUpdateCompany()
{
$response = $this->json('POST', '/api/company', [
'company_name'=>'testing',
'registration_no'=>'testing',
'tax_no'=>'testing',
'tel_no'=>'12345',
'fax'=>'12345',
'address'=>'testing',
'city'=>'testing',
'postcode'=>'testing',
'state'=>'testing',
'country'=>'testing',
'contact_person'=>'testing',
]);
$response->assertStatus(201);
}
public function testPUT()
{
$response = $this->json('PUT', '/api/company/2', [
$response = $this->actingAs($this->user)
->patchJson('/api/company', [
'company_name'=>'changed testing',
'registration_no'=>'testing',
'tax_no'=>'testing',
@@ -52,29 +43,32 @@ class CompanyTest extends TestCase
'state'=>'testing',
'country'=>'testing',
'contact_person'=>'testing',
]);
$response->assertStatus(200);
}
public function testcompanyProfile()
{
public function testUploadCompanyProfile()
{
Storage::fake('company_profile');
$response = $this->json('POST', '/api/company/company_profile/2', [
$response = $this->actingAs($this->user)
->json('POST', '/api/company/company_profile/', [
'company_profile' => UploadedFile::fake()->image('comp.jpg')
]);
dd($response->getContent());
// dd($response->getContent());
$response->assertStatus(200);
}
public function testregCert()
public function testUploadRegCert()
{
Storage::fake('reg_cert');
$response = $this->json('POST', '/api/company/reg_cert/2', [
$response = $this->actingAs($this->user)
->json('POST', '/api/company/reg_cert/', [
'reg_cert' => UploadedFile::fake()->create('document.pdf')//, $sizeInKilobytes)
]);
dd($response->getContent());
$response->assertStatus(200);
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ class LoginTest extends TestCase
*
* @return void
*/
public function testExample()
public function testLogin()
{
$response = $this->json('POST', '/api/login', ['phone' => '0123456789','password' => 'secret']);
$response
+1 -1
View File
@@ -26,7 +26,7 @@ class RegisterTest extends TestCase
'success' => true,
]);
$response = $this->json('POST', '/api/verify', ['phone' => '0123456789', 'token' => '1234']);
$response = $this->json('POST', '/api/verify-phone', ['phone' => '0123456789', 'token' => '1234']);
$response
->assertStatus(200)
->assertJson([
-19
View File
@@ -1,19 +0,0 @@
<?php
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$this->assertTrue(true);
}
}