2020-03-12 11:50:40 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature;
|
|
|
|
|
|
|
|
use App\Designs\Designer;
|
|
|
|
use App\Jobs\Account\CreateAccount;
|
|
|
|
use App\Models\Account;
|
|
|
|
use App\Models\Client;
|
|
|
|
use App\Models\Design;
|
|
|
|
use App\Models\User;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
use App\Utils\Traits\UserSessionAttributes;
|
|
|
|
use Faker\Factory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
use Illuminate\Foundation\Testing\WithFaker;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
use Tests\MockAccountData;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @covers App\Http\Controllers\PreviewController
|
|
|
|
*/
|
|
|
|
|
|
|
|
class PreviewTest extends TestCase
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
use DatabaseTransactions;
|
|
|
|
use MockAccountData;
|
|
|
|
|
|
|
|
public function setUp() :void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->makeTestData();
|
|
|
|
|
|
|
|
Session::start();
|
|
|
|
|
|
|
|
$this->faker = \Faker\Factory::create();
|
|
|
|
|
|
|
|
Model::reguard();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testPreviewDesign()
|
|
|
|
{
|
|
|
|
$design = Design::find(3);
|
|
|
|
|
|
|
|
// $designer = new Designer($this->invoice, $design, $this->company->settings->pdf_variables, 'invoice');
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
'entity' => 'invoice',
|
|
|
|
'entity_id' => $this->invoice->hashed_id,
|
2020-03-12 12:04:53 +01:00
|
|
|
'design' => $design,
|
|
|
|
|
2020-03-12 11:50:40 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token
|
|
|
|
])->post('/api/v1/preview', $data);
|
|
|
|
|
|
|
|
|
|
|
|
$response->assertStatus(200);
|
|
|
|
|
|
|
|
// $arr = $response->json();
|
|
|
|
|
|
|
|
// \Log::error($arr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testBlankEntityPreviewDesign()
|
|
|
|
{
|
|
|
|
$design = Design::find(3);
|
|
|
|
|
|
|
|
$data = [
|
2020-03-12 12:04:53 +01:00
|
|
|
'design' => $design,
|
2020-03-12 11:50:40 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token
|
|
|
|
])->post('/api/v1/preview', $data);
|
|
|
|
|
|
|
|
|
|
|
|
$response->assertStatus(200);
|
|
|
|
|
|
|
|
// $arr = $response->json();
|
|
|
|
|
|
|
|
// \Log::error($arr);
|
|
|
|
}
|
|
|
|
}
|