Tests for PDF mime
This commit is contained in:
parent
49a7fa43e2
commit
43626c92a2
|
|
@ -33,7 +33,7 @@ class SystemLogger implements ShouldQueue
|
|||
|
||||
protected $client;
|
||||
|
||||
public function __construct($log, $category_id, $event_id, $type_id, Client $client)
|
||||
public function __construct($log, $category_id, $event_id, $type_id, ?Client $client)
|
||||
{
|
||||
$this->log = $log;
|
||||
$this->category_id = $category_id;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@
|
|||
*/
|
||||
namespace App\Jobs\Util;
|
||||
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\SystemLog;
|
||||
use App\Models\Webhook;
|
||||
use App\Transformers\ArraySerializer;
|
||||
use GuzzleHttp\Client;
|
||||
|
|
@ -113,6 +115,15 @@ class WebhookHandler implements ShouldQueue
|
|||
if ($response->getStatusCode() == 410 || $response->getStatusCode() == 200) {
|
||||
$subscription->delete();
|
||||
}
|
||||
|
||||
SystemLogger::dispatch(
|
||||
$e->getMessage(),
|
||||
SystemLog::CATEGORY_WEBHOOK,
|
||||
SystemLog::EVENT_WEBHOOK_RESPONSE,
|
||||
SystemLog::TYPE_WEBHOOK_RESPONSE,
|
||||
$this->company->clients->first(),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function failed($exception)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class SystemLog extends Model
|
|||
/* Category IDs */
|
||||
const CATEGORY_GATEWAY_RESPONSE = 1;
|
||||
const CATEGORY_MAIL = 2;
|
||||
const CATEGORY_WEBHOOK = 3;
|
||||
|
||||
/* Event IDs*/
|
||||
const EVENT_PAYMENT_RECONCILIATION_FAILURE = 10;
|
||||
|
|
@ -45,6 +46,8 @@ class SystemLog extends Model
|
|||
const EVENT_MAIL_SEND = 30;
|
||||
const EVENT_MAIL_RETRY_QUEUE = 31; //we use this to queue emails that are spooled and not sent due to the email queue quota being exceeded.
|
||||
|
||||
const EVENT_WEBHOOK_RESPONSE = 40;
|
||||
|
||||
/*Type IDs*/
|
||||
const TYPE_PAYPAL = 300;
|
||||
const TYPE_STRIPE = 301;
|
||||
|
|
@ -56,6 +59,8 @@ class SystemLog extends Model
|
|||
const TYPE_QUOTA_EXCEEDED = 400;
|
||||
const TYPE_UPSTREAM_FAILURE = 401;
|
||||
|
||||
const TYPE_WEBHOOK_RESPONSE = 500;
|
||||
|
||||
protected $fillable = [
|
||||
'client_id',
|
||||
'company_id',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
namespace Tests\Unit\Phantom;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers App\Utils\PhantomJS\Phantom
|
||||
*/
|
||||
class PhantomJsTest extends TestCase
|
||||
{
|
||||
public function setUp() :void
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function testValidPdfMime()
|
||||
{
|
||||
$pdf = file_get_contents(base_path('/tests/Unit/Phantom/valid.pdf'));
|
||||
|
||||
$finfo = new \finfo(FILEINFO_MIME);
|
||||
|
||||
$this->assertEquals('application/pdf; charset=binary', $finfo->buffer($pdf));
|
||||
|
||||
}
|
||||
|
||||
public function testInValidPdfMime()
|
||||
{
|
||||
$pdf = file_get_contents(base_path('/tests/Unit/Phantom/invalid.pdf'));
|
||||
|
||||
$finfo = new \finfo(FILEINFO_MIME);
|
||||
|
||||
$this->assertNotEquals('application/pdf; charset=binary', $finfo->buffer($pdf));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue