Пример #1
0
 /**
  * POST /order
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function createOrder(Request $request)
 {
     $postData = $request->request->all();
     unset($postData['id']);
     $order = Order::createFromArray($postData);
     $this->orderRepository->save($order);
     return new JsonResponse($order, 201);
 }
 /**
  * @test
  */
 public function insertAnOrder()
 {
     $orderData = ['status' => 'placed'];
     $this->db->expects(self::once())->method('insert')->with('order', $orderData);
     $this->db->expects(self::once())->method('lastInsertId')->willReturn(1);
     $order = new Order();
     $order->setStatus('placed');
     $this->repository->save($order);
     self::assertEquals(1, $order->getId());
 }
 /**
  * @param \HsBremen\WebApi\Order\OrderEvent $event
  *
  * @throws \HsBremen\WebApi\Database\DatabaseException
  */
 public function getOrderDetails(OrderEvent $event)
 {
     $order = $this->orderRepository->getById($event->getOrderId());
     $event->setOrder($order);
 }