Upload function testing

This commit is contained in:
Aqeeb Imtiaz Harun
2018-05-15 15:23:18 +08:00
parent 5a7066969a
commit 3d1509d784
+43 -30
View File
@@ -5,6 +5,8 @@ namespace Tests\Unit;
use Tests\TestCase; use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
class CompanyTest extends TestCase class CompanyTest extends TestCase
{ {
@@ -18,39 +20,50 @@ class CompanyTest extends TestCase
$this->assertTrue(true); $this->assertTrue(true);
} }
public function testPOST() // public function testPOST()
{ // {
$response = $this->json('POST', '/api/company', [ // $response = $this->json('POST', '/api/company', [
'company_name'=>'testing', // 'company_name'=>'testing',
'registration_no'=>'testing', // 'registration_no'=>'testing',
'tax_no'=>'testing', // 'tax_no'=>'testing',
'tel_no'=>'testing', // 'tel_no'=>'12345',
'fax'=>'testing', // 'fax'=>'12345',
'address'=>'testing', // 'address'=>'testing',
'city'=>'testing', // 'city'=>'testing',
'postcode'=>'testing', // 'postcode'=>'testing',
'state'=>'testing', // 'state'=>'testing',
'country'=>'testing', // 'country'=>'testing',
'contact_person'=>'testing', // 'contact_person'=>'testing',
]); // ]);
$response->assertStatus(201); // var_dump($response);
} // $response->assertStatus(302);
// }
public function testPUT() // public function testPUT()
// {
// $response = $this->json('PUT', '/api/company/4', [
// '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 testcompanyProfile()
{ {
$response = $this->json('PUT', '/api/company/1', [ Storage::fake('company_profile');
'company_name'=>'testing',
'registration_no'=>'testing', $response = $this->json('POST', '/company/company_profile/4', [
'tax_no'=>'testing', 'company_profile' => UploadedFile::fake()->image('comp.jpg')
'tel_no'=>'testing',
'fax'=>'testing',
'address'=>'testing',
'city'=>'testing',
'postcode'=>'testing',
'state'=>'testing',
'country'=>'testing',
'contact_person'=>'testing',
]); ]);
var_dump($response);
$response->assertStatus(200); $response->assertStatus(200);
} }
} }