create()->addTickets(5); $this->assertEquals(5, $concert->ticketsRemaining()); $order = Order::forTickets($concert->findTickets(3), 'john@example.com', 3600); $this->assertEquals('john@example.com', $order->email); $this->assertEquals(3, $order->ticketQuantity()); $this->assertEquals(3600, $order->amount); $this->assertEquals(2, $concert->ticketsRemaining()); } /** @test */ function creating_an_order_from_a_reservation() { $concert = factory(Concert::class)->create(['ticket_price' => 1200]); $tickets = factory(Ticket::class, 3)->create(['concert_id' => $concert->id]); $reservation = new Reservation($tickets, 'john@example.com'); $order = Order::fromReservation($reservation); $this->assertEquals('john@example.com', $order->email); $this->assertEquals(3, $order->ticketQuantity()); $this->assertEquals(3600, $order->amount); } /** @test */ function converting_to_an_array() { $concert = factory(Concert::class)->create(['ticket_price' => 1200])->addTickets(5); $order = $concert->orderTickets('jane@example.com', 5); $result = $order->toArray(); $this->assertEquals([ 'email' => 'jane@example.com', 'ticket_quantity' => 5, 'amount' => 6000, ], $result); } }