feat: add ability to upload documents (#1912)

This commit is contained in:
Régis Freyd
2018-10-27 20:42:46 -04:00
committed by GitHub
parent 080b2c5bb3
commit fd9b28537e
47 changed files with 1514 additions and 40 deletions
@@ -0,0 +1,55 @@
<?php
namespace Tests\Unit\Controllers;
use Tests\FeatureTestCase;
use App\Models\Contact\Contact;
use App\Models\Contact\Document;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class DocumentsControllerTest extends FeatureTestCase
{
use DatabaseTransactions;
protected $jsonStructure = [
'id',
'object',
'original_filename',
'new_filename',
'filesize',
'type',
'number_of_downloads',
'contact',
'created_at',
'updated_at',
];
public function test_it_gets_the_list_of_documents()
{
$user = $this->signin();
$contact = factory(Contact::class)->create([
'account_id' => $user->account_id,
]);
factory(Document::class, 100)->create([
'account_id' => $user->account_id,
'contact_id' => $contact->id,
]);
$response = $this->json('GET', '/people/'.$contact->hashID().'/documents');
$response->assertStatus(200);
$response->assertJsonStructure([
'data' => [
'*' => $this->jsonStructure,
],
]);
$this->assertCount(
100,
$response->decodeResponseJson()['data']
);
}
}