public function testGetClass()
 {
     $osRenderer = new OrderStatusRenderer();
     $order = $this->getMock('Sonata\\Component\\Order\\OrderInterface');
     $order->expects($this->once())->method('getStatus')->will($this->returnValue(array_rand(BaseOrder::getStatusList())));
     $order->expects($this->once())->method('getDeliveryStatus')->will($this->returnValue(array_rand(BaseServiceDelivery::getStatusList())));
     $order->expects($this->once())->method('getPaymentStatus')->will($this->returnValue(array_rand(BaseTransaction::getStatusList())));
     $this->assertContains($osRenderer->getStatusClass($order, "", "error"), array('success', 'info', 'error'));
     $this->assertContains($osRenderer->getStatusClass($order, "payment", "error"), array('success', 'info', 'error'));
     $this->assertContains($osRenderer->getStatusClass($order, "delivery", "error"), array('success', 'info', 'error'));
 }
Пример #2
0
 /**
  * @return string
  */
 public function getPaymentStatusName()
 {
     $statusList = BaseTransaction::getStatusList();
     return $statusList[$this->getPaymentStatus()];
 }
Пример #3
0
 /**
  * Creates a fake Order.
  *
  * @param BasketInterface $basket
  * @param Customer        $customer
  * @param array           $products
  * @param ObjectManager   $manager
  * @param int             $pos
  *
  * @return OrderInterface
  */
 protected function createOrder(BasketInterface $basket, Customer $customer, array $products, ObjectManager $manager, $pos)
 {
     $orderElements = array();
     $totalExcl = 0;
     $totalInc = 0;
     $order = new Order();
     // customer
     $order->setCustomer($customer);
     $order->setLocale($customer->getLocale());
     $order->setUsername($customer->getFullname());
     $order->setReference(sprintf('%02d%02d%02d%06d', 2013, 7, 1, $pos));
     // Billing
     $customerBillingAddressAddresses = $customer->getAddressesByType(BaseAddress::TYPE_BILLING);
     $customerBillingAddressAddresses = $customerBillingAddressAddresses->current();
     $order->setBillingAddress1($customerBillingAddressAddresses->getAddress1());
     $order->setBillingAddress2($customerBillingAddressAddresses->getAddress2());
     $order->setBillingAddress3($customerBillingAddressAddresses->getAddress3());
     $order->setBillingCity($customerBillingAddressAddresses->getCity());
     $order->setBillingCountryCode($customerBillingAddressAddresses->getCountryCode());
     $order->setBillingEmail($customer->getEmail());
     $order->setBillingName($customer->getFullname());
     $order->setBillingPhone($customerBillingAddressAddresses->getPhone());
     $order->setBillingFax($customer->getFaxNumber());
     $order->setBillingMobile($customer->getMobileNumber());
     $order->setBillingPostcode($customerBillingAddressAddresses->getPostcode());
     // Shipping
     $customerDeliveryAddressAddresses = $customer->getAddressesByType(BaseAddress::TYPE_DELIVERY);
     $customerDeliveryAddressAddresses = $customerDeliveryAddressAddresses->current();
     $order->setShippingAddress1($customerDeliveryAddressAddresses->getAddress1());
     $order->setShippingAddress2($customerDeliveryAddressAddresses->getAddress2());
     $order->setShippingAddress3($customerDeliveryAddressAddresses->getAddress3());
     $order->setShippingCity($customerDeliveryAddressAddresses->getCity());
     $order->setShippingCountryCode($customerDeliveryAddressAddresses->getCountryCode());
     $order->setShippingEmail($customer->getEmail());
     $order->setShippingName($customer->getFullname());
     $order->setShippingPhone($customerDeliveryAddressAddresses->getPhone());
     $order->setShippingFax($customer->getFaxNumber());
     $order->setShippingMobile($customer->getMobileNumber());
     $order->setShippingPostcode($customerDeliveryAddressAddresses->getPostcode());
     // Delivery
     $order->setDeliveryMethod('free');
     // @todo : change Delivery method integration
     $order->setDeliveryCost(rand(5, 40));
     $order->setDeliveryVat(20);
     $order->setDeliveryStatus(array_rand(Delivery::getStatusList()));
     $currency = new Currency();
     $currency->setLabel('EUR');
     // Payment
     $order->setCurrency($currency);
     $order->setPaymentMethod('free');
     // @todo : change Payment method integration
     $order->setPaymentStatus(array_rand(BaseTransaction::getStatusList()));
     // OrderElements
     foreach ($products as $product) {
         $orderElement = $this->createOrderElement($basket, $product);
         $orderElement->setOrder($order);
         $orderElements[] = $orderElement;
         $totalExcl += $orderElement->getUnitPrice(false);
         $totalInc += $orderElement->getUnitPrice(true);
     }
     $order->setOrderElements($orderElements);
     $order->setTotalExcl($totalExcl);
     $order->setTotalInc($totalInc);
     $order->setStatus(array_rand(BaseOrder::getStatusList()));
     if (OrderInterface::STATUS_VALIDATED == $order->getStatus()) {
         $order->setValidatedAt(new \DateTime());
     }
     $manager->persist($order);
     return $order;
 }