We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 17819bc commit 7e43819Copy full SHA for 7e43819
app/Models/Order.php
@@ -21,4 +21,9 @@ public function addProducts($products)
21
]);
22
}
23
24
+
25
+ public function totalPrice()
26
+ {
27
+ return number_format($this->total / 100, 2);
28
+ }
29
tests/Unit/OrderTest.php
@@ -21,6 +21,18 @@ public function it_can_add_products_to_the_order()
$order->addProducts($products);
- $this->assertEquals(3, $order->products()->count());
+ $this->assertEquals(3, $order->products->count());
+ /**
+ * @test
+ */
30
+ public function it_has_a_total_price_for_the_order()
31
32
+ $order = factory(Order::class)->create([
33
+ 'total' => 3000,
34
+ ]);
35
36
+ $this->assertEquals('30.00', $order->totalPrice());
37
38
0 commit comments