Files
jack c64c526d98 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"
2018-05-28 17:14:09 +08:00

75 lines
1.9 KiB
PHP

<?php
namespace Tests\Unit;
use Tests\TestCase;
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
{
protected $company;
protected $user;
public function setUp()
{
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 testUpdateCompany()
{
$response = $this->actingAs($this->user)
->patchJson('/api/company', [
'company_name'=>'changed 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(200);
}
public function testUploadCompanyProfile()
{
Storage::fake('company_profile');
$response = $this->actingAs($this->user)
->json('POST', '/api/company/company_profile/', [
'company_profile' => UploadedFile::fake()->image('comp.jpg')
]);
// dd($response->getContent());
$response->assertStatus(200);
}
public function testUploadRegCert()
{
Storage::fake('reg_cert');
$response = $this->actingAs($this->user)
->json('POST', '/api/company/reg_cert/', [
'reg_cert' => UploadedFile::fake()->create('document.pdf')//, $sizeInKilobytes)
]);
$response->assertStatus(200);
}
}