mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
e5a230e0c7
* Adjustments for tests * Implement handling of temp downloading resources * Refactor paths * Refactors for file paths * Refactor paths * Add in S3 adapter * Refactor company Documment URL * Refactor for entity pdf performance * Refactors for invoice generation * Enhancements for emails invoices * Emails * Fixes for client portal queries
61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Jobs\Util\UploadFile;
|
|
use App\Models\Document;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
use Illuminate\Http\UploadedFile;
|
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Tests\MockAccountData;
|
|
use Tests\TestCase;
|
|
|
|
class CompanyDocumentsTest extends TestCase
|
|
{
|
|
use MockAccountData;
|
|
use DatabaseTransactions;
|
|
|
|
public function setUp() :void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->makeTestData();
|
|
|
|
$this->withoutMiddleware(
|
|
ThrottleRequests::class
|
|
);
|
|
}
|
|
|
|
|
|
public function testCompanyDocumentExists()
|
|
{
|
|
$company_key = $this->company->company_key;
|
|
|
|
|
|
$original_count = Document::whereCompanyId($this->company->id)->count();
|
|
|
|
$image = UploadedFile::fake()->image('avatar.jpg');
|
|
|
|
$document = UploadFile::dispatchNow(
|
|
$image,
|
|
UploadFile::IMAGE,
|
|
$this->user,
|
|
$this->company,
|
|
$this->invoice
|
|
);
|
|
|
|
$this->assertNotNull($document);
|
|
|
|
$this->assertTrue(Storage::exists($document->path));
|
|
|
|
$this->assertGreaterThan($original_count, Document::whereCompanyId($this->company->id)->count());
|
|
|
|
$this->company->delete();
|
|
|
|
$this->assertEquals(0, Document::whereCompanyId($this->company->id)->count());
|
|
|
|
$this->assertFalse(Storage::exists($document->path));
|
|
}
|
|
}
|