add() public method

public add ( Order $order )
$order Order
コード例 #1
0
ファイル: NewOrderListener.php プロジェクト: dumplie/dumplie
 /**
  * @param string $eventJson
  * @throws UnknownEventException
  */
 public function on(string $eventJson)
 {
     $data = json_decode($eventJson, true);
     if (!array_key_exists('name', $data) || $data['name'] !== Events::CUSTOMER_PLACED_ORDER) {
         throw UnknownEventException::unexpected(Events::CUSTOMER_PLACED_ORDER, $data['name']);
     }
     $this->orders->add(new Order(new OrderId($data['order_id']), new \DateTimeImmutable($data['date'])));
 }
コード例 #2
0
 function it_creates_new_customer_service_order_when_customer_place_order(Orders $orders)
 {
     $orders->add(Argument::type(Order::class))->shouldBeCalled();
     $this->on(json_encode(['name' => Events::CUSTOMER_PLACED_ORDER, 'order_id' => (string) OrderId::generate(), 'date' => '2015-01-01 12:12:12']));
 }