-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix - Method remove into ShippingModifiers (#1600)
The ShippingModifiers store modifiers in collection, the method remove tried to remove the key that didn't exist. --------- Co-authored-by: Glenn Jacobs <[email protected]>
- Loading branch information
1 parent
6e0752a
commit 98474d9
Showing
2 changed files
with
62 additions
and
1 deletion.
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
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,61 @@ | ||
<?php | ||
|
||
namespace Lunar\Tests\Unit\Base; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Lunar\Base\ShippingModifier; | ||
use Lunar\Base\ShippingModifiers; | ||
use Lunar\Models\Cart; | ||
use Lunar\Models\Currency; | ||
use Lunar\Tests\TestCase; | ||
|
||
class ShippingModifiersTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
private Cart $cart; | ||
|
||
private ShippingModifiers $shippingModifiers; | ||
|
||
private ShippingModifier $class; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$currency = Currency::factory()->create([ | ||
'decimal_places' => 2, | ||
]); | ||
|
||
$this->cart = Cart::factory()->create([ | ||
'currency_id' => $currency->id, | ||
]); | ||
|
||
$this->class = new class extends ShippingModifier | ||
{ | ||
public function handle(Cart $cart) | ||
{ | ||
// | ||
} | ||
}; | ||
|
||
$this->shippingModifiers = new ShippingModifiers(); | ||
} | ||
|
||
/** @test */ | ||
public function can_add_modifier() | ||
{ | ||
$this->shippingModifiers->add($this->class::class); | ||
|
||
$this->assertCount(1, $this->shippingModifiers->getModifiers()); | ||
} | ||
|
||
|
||
public function can_remove_modifier() | ||
{ | ||
$this->shippingModifiers->remove($this->class::class); | ||
|
||
$this->assertCount(0, $this->shippingModifiers->getModifiers()); | ||
} | ||
|
||
} |