Added test for toArray()

This commit is contained in:
Rob Gloudemans
2016-06-15 10:19:24 +02:00
parent 6c82e21626
commit c981572626

View File

@@ -457,6 +457,42 @@ class CartTest extends Orchestra\Testbench\TestCase
$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 */
public function it_can_destroy_a_cart()
{