1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00
invoiceninja/tests/Unit/EInvoiceTest.php

74 lines
2.3 KiB
PHP
Raw Normal View History

2023-04-06 11:08:59 +02:00
<?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://www.elastic.co/licensing/elastic-license
*/
2023-10-26 03:25:56 +02:00
use App\Jobs\Entity\CreateRawPdf;
2023-04-21 07:44:11 +02:00
use App\Jobs\Invoice\CreateEInvoice;
2023-04-06 11:08:59 +02:00
use horstoeko\zugferd\ZugferdDocumentReader;
2023-04-17 10:23:07 +02:00
use Illuminate\Foundation\Testing\DatabaseTransactions;
2023-11-26 08:41:42 +01:00
use Illuminate\Routing\Middleware\ThrottleRequests;
use Tests\MockAccountData;
use Tests\TestCase;
2023-04-06 11:08:59 +02:00
/**
* @test
2023-04-17 09:24:16 +02:00
* @covers App\Jobs\Invoice\CreateXInvoice
2023-04-06 11:08:59 +02:00
*/
2023-04-17 09:24:16 +02:00
class EInvoiceTest extends TestCase
2023-04-06 11:08:59 +02:00
{
use MockAccountData;
use DatabaseTransactions;
protected function setUp() :void
{
parent::setUp();
$this->withoutMiddleware(
ThrottleRequests::class
);
$this->makeTestData();
}
2023-04-17 09:24:16 +02:00
public function testEInvoiceGenerates()
2023-04-06 11:08:59 +02:00
{
2023-04-17 11:55:38 +02:00
$this->company->e_invoice_type = "EN16931";
2023-04-17 10:23:07 +02:00
$this->invoice->client->routing_id = 'DE123456789';
$this->invoice->client->save();
$e_invoice = (new CreateEInvoice($this->invoice))->handle();
2023-08-16 12:59:42 +02:00
$this->assertIsString($e_invoice);
2023-04-06 11:08:59 +02:00
}
2023-11-26 08:41:42 +01:00
/**
* @throws Exception
*/
public function testValidityofXMLFile()
{
$this->company->e_invoice_type = "EN16931";
$this->invoice->client->routing_id = 'DE123456789';
$this->invoice->client->save();
2023-04-17 10:23:07 +02:00
2023-11-26 08:41:42 +01:00
$e_invoice = (new CreateEInvoice($this->invoice))->handle();
$document = ZugferdDocumentReader::readAndGuessFromContent($e_invoice);
$document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest);
$this->assertEquals($this->invoice->number, $documentno);
}
2023-04-17 09:24:16 +02:00
2023-11-26 08:41:42 +01:00
/**
* @throws Exception
*/
public function checkEmbededPDFFile()
{
$pdf = (new CreateRawPdf($this->invoice->invitations()->first()))->handle();
$document = ZugferdDocumentReader::readAndGuessFromContent($pdf);
$document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest);
$this->assertEquals($this->invoice->number, $documentno);
}
2023-04-06 11:08:59 +02:00
}