mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-24 07:55:35 +00:00
Added test for toArray()
This commit is contained in:
@@ -457,6 +457,42 @@ class CartTest extends Orchestra\Testbench\TestCase
|
|||||||
$this->assertCount(0, $content);
|
$this->assertCount(0, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function it_will_include_the_tax_and_subtotal_when_converted_to_an_array()
|
||||||
|
{
|
||||||
|
$cart = $this->getCart();
|
||||||
|
|
||||||
|
$item = $this->getBuyableMock();
|
||||||
|
$item2 = $this->getBuyableMock(2);
|
||||||
|
|
||||||
|
$cart->add($item);
|
||||||
|
$cart->add($item2);
|
||||||
|
|
||||||
|
$content = $cart->content();
|
||||||
|
|
||||||
|
$this->assertInstanceOf(\Illuminate\Support\Collection::class, $content);
|
||||||
|
$this->assertEquals([
|
||||||
|
'027c91341fd5cf4d2579b49c4b6a90da' => [
|
||||||
|
'rowId' => '027c91341fd5cf4d2579b49c4b6a90da',
|
||||||
|
'id' => 1,
|
||||||
|
'name' => 'Item name',
|
||||||
|
'qty' => 1,
|
||||||
|
'price' => 10.00,
|
||||||
|
'tax' => 2.10,
|
||||||
|
'subtotal' => 10.0,
|
||||||
|
],
|
||||||
|
'370d08585360f5c568b18d1f2e4ca1df' => [
|
||||||
|
'rowId' => '370d08585360f5c568b18d1f2e4ca1df',
|
||||||
|
'id' => 2,
|
||||||
|
'name' => 'Item name',
|
||||||
|
'qty' => 1,
|
||||||
|
'price' => 10.00,
|
||||||
|
'tax' => 2.10,
|
||||||
|
'subtotal' => 10.0,
|
||||||
|
]
|
||||||
|
], $content->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function it_can_destroy_a_cart()
|
public function it_can_destroy_a_cart()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user