2020-02-19 21:44:12 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Integration;
|
|
|
|
|
|
|
|
use App\Designs\Designer;
|
|
|
|
use App\Designs\Modern;
|
|
|
|
use App\Jobs\Invoice\CreateInvoicePdf;
|
|
|
|
use App\Jobs\Quote\CreateQuotePdf;
|
2020-02-26 05:11:17 +01:00
|
|
|
use App\Utils\Traits\GeneratesCounter;
|
2020-02-19 21:44:12 +01:00
|
|
|
use Tests\MockAccountData;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @covers App\Designs\Designer
|
|
|
|
*/
|
|
|
|
class DesignTest extends TestCase
|
|
|
|
{
|
|
|
|
use MockAccountData;
|
2020-02-26 05:11:17 +01:00
|
|
|
use GeneratesCounter;
|
2020-02-19 21:44:12 +01:00
|
|
|
|
|
|
|
public function setUp() :void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->makeTestData();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testInvoiceDesignExists()
|
|
|
|
{
|
|
|
|
|
|
|
|
$modern = new Modern();
|
|
|
|
|
|
|
|
$designer = new Designer($modern, $this->company->settings->pdf_variables, 'quote');
|
|
|
|
|
|
|
|
$html = $designer->build($this->invoice)->getHtml();
|
|
|
|
|
|
|
|
$this->assertNotNull($html);
|
|
|
|
|
2020-02-22 03:25:49 +01:00
|
|
|
|
|
|
|
$this->invoice = factory(\App\Models\Invoice::class)->create([
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
'client_id' => $this->client->id,
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->invoice->uses_inclusive_taxes = false;
|
2020-02-19 21:44:12 +01:00
|
|
|
|
|
|
|
$settings = $this->invoice->client->settings;
|
2020-02-26 05:11:17 +01:00
|
|
|
$settings->invoice_design_id = "5";
|
2020-02-19 21:44:12 +01:00
|
|
|
|
|
|
|
$this->client->settings = $settings;
|
|
|
|
$this->client->save();
|
|
|
|
|
|
|
|
CreateInvoicePdf::dispatchNow($this->invoice, $this->invoice->company, $this->invoice->client->primary_contact()->first());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testQuoteDesignExists()
|
|
|
|
{
|
|
|
|
|
|
|
|
$modern = new Modern();
|
|
|
|
|
|
|
|
$designer = new Designer($modern, $this->company->settings->pdf_variables, 'quote');
|
|
|
|
|
|
|
|
$html = $designer->build($this->quote)->getHtml();
|
|
|
|
|
|
|
|
$this->assertNotNull($html);
|
|
|
|
|
|
|
|
//\Log::error($html);
|
|
|
|
|
|
|
|
$settings = $this->invoice->client->settings;
|
2020-02-22 03:25:49 +01:00
|
|
|
$settings->quote_design_id = "6";
|
2020-02-19 21:44:12 +01:00
|
|
|
|
|
|
|
$this->client->settings = $settings;
|
|
|
|
$this->client->save();
|
|
|
|
|
|
|
|
CreateQuotePdf::dispatchNow($this->quote, $this->quote->company, $this->quote->client->primary_contact()->first());
|
|
|
|
}
|
2020-02-26 05:11:17 +01:00
|
|
|
|
|
|
|
public function testAllDesigns()
|
|
|
|
{
|
|
|
|
|
|
|
|
for($x=1; $x<=10; $x++)
|
|
|
|
{
|
|
|
|
|
|
|
|
$settings = $this->invoice->client->settings;
|
|
|
|
$settings->quote_design_id = (string)$x;
|
|
|
|
|
|
|
|
$this->client->settings = $settings;
|
|
|
|
$this->client->save();
|
|
|
|
|
|
|
|
CreateQuotePdf::dispatchNow($this->quote, $this->quote->company, $this->quote->client->primary_contact()->first());
|
|
|
|
|
|
|
|
$this->quote->number = $this->getNextQuoteNumber($this->quote->client);
|
|
|
|
$this->quote->save();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertTrue(true);
|
|
|
|
|
|
|
|
}
|
2020-02-19 21:44:12 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|