-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hotfix - Fix taxbreakdown state update (#1309)
- Loading branch information
1 parent
80fa3a1
commit f0dd629
Showing
2 changed files
with
85 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/core/tests/Database/State/ConvertTaxBreakdownTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Lunar\Tests\Database\State; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Support\Facades\Storage; | ||
use Lunar\Database\State\ConvertTaxbreakdown; | ||
use Lunar\Facades\DB; | ||
use Lunar\Models\Channel; | ||
use Lunar\Models\Currency; | ||
use Lunar\Models\Language; | ||
use Lunar\Tests\TestCase; | ||
|
||
/** | ||
* @group database.state | ||
*/ | ||
class ConvertTaxBreakdownTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
/** @test */ | ||
public function can_run() | ||
{ | ||
Storage::fake('local'); | ||
|
||
Language::factory()->create([ | ||
'default' => true, | ||
]); | ||
|
||
$channel = Channel::factory()->create([ | ||
'default' => true, | ||
]); | ||
|
||
Currency::factory()->create([ | ||
'code' => 'GBP', | ||
]); | ||
|
||
DB::table('lunar_orders')->insert([ | ||
'channel_id' => $channel->id, | ||
'new_customer' => false, | ||
'user_id' => null, | ||
'status' => 'awaiting-payment', | ||
'reference' => 123123, | ||
'sub_total' => 400, | ||
'discount_total' => 0, | ||
'shipping_total' => 0, | ||
'tax_breakdown' => '[{"total": 333, "identifier": "tax_rate_1", "percentage": 20, "description": "VAT"}]', | ||
'tax_total' => 200, | ||
'total' => 100, | ||
'notes' => null, | ||
'currency_code' => 'GBP', | ||
'compare_currency_code' => 'GBP', | ||
'exchange_rate' => 1, | ||
'meta' => '[]', | ||
]); | ||
|
||
(new ConvertTaxbreakdown)->run(); | ||
|
||
$this->assertDatabaseHas('lunar_orders', [ | ||
'tax_breakdown' => '[{"description":"VAT","identifier":"tax_rate_1","percentage":20,"value":333,"currency_code":"GBP"}]' | ||
]); | ||
|
||
} | ||
} |