1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 15:42:51 +01:00
invoiceninja/tests/Unit/Tax/TaxConfigTest.php

77 lines
1.7 KiB
PHP
Raw Normal View History

2023-05-15 13:40:57 +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
*/
namespace Tests\Unit\Tax;
2023-05-15 13:49:38 +02:00
use App\DataProviders\USStates;
2023-05-15 13:40:57 +02:00
use App\Models\Client;
use App\Services\Tax\Providers\TaxProvider;
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-05-15 13:40:57 +02:00
/**
* @test App\Services\Tax\Providers\EuTax
*/
class TaxConfigTest extends TestCase
{
use MockAccountData;
use DatabaseTransactions;
protected function setUp() :void
{
parent::setUp();
$this->withoutMiddleware(
ThrottleRequests::class
);
$this->withoutExceptionHandling();
$this->makeTestData();
2023-11-26 08:41:42 +01:00
if(!config('services.tax.zip_tax.key')) {
2023-05-15 13:40:57 +02:00
$this->markTestSkipped('No API keys to test with.');
2023-11-26 08:41:42 +01:00
}
2023-05-15 13:40:57 +02:00
}
public TaxProvider $tp;
private function bootApi(Client $client)
{
$this->tp = new TaxProvider($this->company, $client);
}
public function testStateResolution()
{
//infer state from zip
$client = Client::factory()->create([
'company_id' => $this->company->id,
'user_id' => $this->user->id,
'address1' => '400 Evelyn Pl',
2023-05-15 13:49:38 +02:00
'city' => 'Beverley Hills',
'state' => '',
'postal_code' => '',
2023-05-15 13:40:57 +02:00
'country_id' => 840,
]);
// $this->assertEquals('CA', USStates::getState('90210'));
2023-05-15 13:49:38 +02:00
$this->bootApi($client);
2023-05-15 13:49:38 +02:00
$this->tp->updateClientTaxData();
2023-05-15 13:40:57 +02:00
}
2023-11-26 08:41:42 +01:00
}