1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/tests/Unit/CompanyDocumentsTest.php
David Bomba 43e57d0117
Fixes for self-update (#3514)
* minor fix for payment notifications

* styleci

* Limit Self updating to self hosters only
:

* Fixes for designs

* Minor fixes for self-update
2020-03-21 16:37:30 +11:00

60 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()
{
$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->assertGreaterThan($original_count, Document::whereCompanyId($this->company->id)->count());
$company_key = $this->company->company_key;
$this->company->delete();
$this->assertEquals(0, Document::whereCompanyId($this->company->id)->count());
$path = sprintf('%s/%s', storage_path('app/public'), $company_key);
$this->assertFalse(file_exists($path));
}
}