mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fact1 tests
This commit is contained in:
parent
edb219a361
commit
e627c09ef0
73
tests/Integration/Einvoice/FACT1Test.php
Normal file
73
tests/Integration/Einvoice/FACT1Test.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?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
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\Integration\Einvoice;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
use Invoiceninja\Einvoice\Models\FACT1\Invoice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
class FACT1Test extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testValidationFact1()
|
||||||
|
{
|
||||||
|
|
||||||
|
$files = [
|
||||||
|
'tests/Integration/Einvoice/samples/fact1.xml',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($files as $f) {
|
||||||
|
|
||||||
|
$xmlstring = file_get_contents($f);
|
||||||
|
|
||||||
|
// nlog($xmlstring);
|
||||||
|
|
||||||
|
$xml = simplexml_load_string($xmlstring, "SimpleXMLElement");
|
||||||
|
$json = json_encode($xml);
|
||||||
|
$payload = json_decode($json, true);
|
||||||
|
|
||||||
|
nlog($xml);
|
||||||
|
nlog($payload);
|
||||||
|
$validation_array = false;
|
||||||
|
try {
|
||||||
|
$rules = Invoice::getValidationRules($payload);
|
||||||
|
nlog($rules);
|
||||||
|
|
||||||
|
$this->assertIsArray($rules);
|
||||||
|
|
||||||
|
$payload = Invoice::from($payload)->toArray();
|
||||||
|
nlog($payload);
|
||||||
|
$this->assertIsArray($payload);
|
||||||
|
|
||||||
|
$validation_array = Invoice::validate($payload);
|
||||||
|
|
||||||
|
$this->assertIsArray($validation_array);
|
||||||
|
|
||||||
|
} catch(\Illuminate\Validation\ValidationException $e) {
|
||||||
|
|
||||||
|
nlog($e->errors());
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertIsArray($validation_array);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user