コード例 #1
0
 public function testGetById()
 {
     $client = $this->createAuthenticatedClient();
     $client->request('GET', '/api/shippings/' . $this->shipping->getId());
     $response = json_decode($client->getResponse()->getContent());
     // shipping
     $this->assertEquals(200, $client->getResponse()->getStatusCode());
     $this->assertEquals('00001', $response->number);
     $this->assertEquals('432', $response->shippingNumber);
     $this->assertEquals('shipping-commission', $response->commission);
     $this->assertEquals(101, $response->height);
     $this->assertEquals(102, $response->width);
     $this->assertEquals(103, $response->length);
     $this->assertEquals(10, $response->weight);
     $this->assertEquals('abcd1234', $response->trackingId);
     $this->assertEquals('http://www.tracking.url?token=abcd1234', $response->trackingUrl);
     $this->assertEquals('simple shipping note', $response->note);
     $this->assertEquals((new DateTime('2015-01-01'))->getTimestamp(), (new DateTime($response->expectedDeliveryDate))->getTimestamp());
     $this->assertEquals('Tiny internal note', $response->internalNote);
     // shipping status
     $this->assertEquals($this->shipping->getStatus()->getId(), $response->status->id);
     // order
     $this->assertEquals($this->data->order->getId(), $response->order->id);
     // shipping item
     $this->assertEquals(1, count($response->items));
     $item = $response->items[0];
     $this->assertEquals($this->shippingItem->getId(), $item->id);
     $this->assertEquals(1, $item->quantity);
     $this->assertEquals('shipping-item-note', $item->note);
     // order address
     $this->assertEquals($this->shippingAddress->getId(), $response->deliveryAddress->id);
     $this->assertEquals('John', $response->deliveryAddress->firstName);
     $this->assertEquals('Doe', $response->deliveryAddress->lastName);
     $this->assertEquals('Company', $response->deliveryAddress->accountName);
     $this->assertEquals('Dr', $response->deliveryAddress->title);
     $this->assertEquals('Sample-Street', $response->deliveryAddress->street);
     $this->assertEquals('Entrance 2', $response->deliveryAddress->addition);
     $this->assertEquals('12', $response->deliveryAddress->number);
     $this->assertEquals('Sample-City', $response->deliveryAddress->city);
     $this->assertEquals('12345', $response->deliveryAddress->zip);
     $this->assertEquals('State', $response->deliveryAddress->state);
     $this->assertEquals('Country', $response->deliveryAddress->country);
     $this->assertEquals('postboxPostcode', $response->deliveryAddress->postboxPostcode);
     $this->assertEquals('postboxNumber', $response->deliveryAddress->postboxNumber);
     $this->assertEquals('postboxCity', $response->deliveryAddress->postboxCity);
     $this->assertEquals('uid-123', $response->deliveryAddress->uid);
     $this->assertEquals('+43 123 / 456 789', $response->deliveryAddress->phone);
     $this->assertEquals('+43 123 / 456', $response->deliveryAddress->phoneMobile);
     // terms
     $this->assertEquals($this->data->termsOfDelivery->getTerms(), $response->termsOfDeliveryContent);
     $this->assertEquals($this->data->termsOfPayment->getTerms(), $response->termsOfPaymentContent);
 }
コード例 #2
0
ファイル: ShippingManager.php プロジェクト: sulu/sulu-sales
 /**
  * creates a ShippingItem Entity by a given (shipping-)data array
  * @param $data
  * @return ShippingItemEntity
  * @throws Exception\ShippingDependencyNotFoundException
  * @throws Exception\MissingShippingAttributeException
  */
 private function createShippingItemEntity($data)
 {
     // check if necessary item data is set
     if (array_key_exists('item', $data) && array_key_exists('id', $data['item'])) {
         $itemId = $data['item']['id'];
         $item = $this->itemManager->findEntityById($itemId);
         if (!$item) {
             throw new ShippingDependencyNotFoundException('SuluSalesCoreBundle:Items', $itemId);
         }
         $shippingItem = new ShippingItemEntity();
         $shippingItem->setItem($item);
         $this->em->persist($shippingItem);
     } else {
         throw new MissingShippingAttributeException('ShippingItems.item.id');
     }
     return $shippingItem;
 }