Ejemplo n.º 1
0
 /**
  * @return array
  */
 public function itemsProvider()
 {
     $order1 = new Order();
     $order2 = new Order();
     $order1->setIncrementId('1111');
     $order2->setIncrementId('2222');
     $order3 = clone $order1;
     $cart1 = new Cart();
     $cart2 = new Cart();
     $cart1->setOriginId(1111);
     $cart2->setOriginId(2222);
     $cart3 = clone $cart1;
     $customer1 = new Customer();
     $customer1->setOriginId(111);
     $customer2 = clone $customer1;
     $someEntity = new \stdClass();
     $someEntity2 = new \stdClass();
     return ['should skip non-unique orders' => ['$items' => [$order1, $order2, $order3], '$expectedItems' => [$order3->getIncrementId() => $order3, $order2->getIncrementId() => $order2]], 'should skip non-unique carts' => ['$items' => [$cart1, $cart2, $cart3], '$expectedItems' => [$cart3->getOriginId() => $cart3, $cart2->getOriginId() => $cart2]], 'should skip non-unique customers' => ['$items' => [$customer1, $customer2], '$expectedItems' => [$customer2->getOriginId() => $customer2]], 'should not break logic with entities that not consist originId' => ['$items' => [$someEntity, $someEntity2], '$expectedItems' => [$someEntity, $someEntity2]]];
 }
Ejemplo n.º 2
0
 /**
  * @param array $data
  *
  * @dataProvider dataProvider
  */
 public function testRead(array $data)
 {
     $this->executionContext->expects($this->once())->method('get')->will($this->returnCallback(function ($key) use($data) {
         if (empty($data[$key])) {
             return null;
         }
         return $data[$key];
     }));
     $originId = 321;
     $expectedData = new Order();
     $expectedData->setIncrementId($originId);
     $this->context->expects($this->any())->method('getConfiguration')->will($this->returnValue(['data' => $expectedData]));
     $this->transport->expects($this->once())->method('getOrderInfo')->will($this->returnCallback(function ($incrementId) {
         $object = new \stdClass();
         $object->origin_id = $incrementId;
         $object->store_id = 0;
         return $object;
     }));
     $reader = $this->getReader();
     $reader->setStepExecution($this->stepExecutionMock);
     $this->assertEquals(['origin_id' => $originId, 'store_id' => 0], $reader->read());
     $this->assertNull($reader->read());
 }
Ejemplo n.º 3
0
 /**
  * @param Cart     $cart
  * @param Customer $customer
  *
  * @return Order
  */
 protected function createOrder(Cart $cart, Customer $customer)
 {
     $order = new Order();
     $order->setChannel($this->integration);
     $order->setDataChannel($this->channel);
     $order->setStatus('open');
     $order->setIncrementId('one');
     $order->setCreatedAt(new \DateTime('now'));
     $order->setUpdatedAt(new \DateTime('now'));
     $order->setCart($cart);
     $order->setStore($this->store);
     $order->setCustomer($customer);
     $order->setCustomerEmail('*****@*****.**');
     $order->setDiscountAmount(34.4);
     $order->setTaxAmount(12.47);
     $order->setShippingAmount(5);
     $order->setTotalPaidAmount(17.85);
     $order->setTotalInvoicedAmount(11);
     $order->setTotalRefundedAmount(4);
     $order->setTotalCanceledAmount(0);
     $order->setShippingMethod('some unique shipping method');
     $order->setRemoteIp('unique ip');
     $order->setGiftMessage('some very unique gift message');
     $order->setOwner($this->getUser());
     $order->setOrganization($this->organization);
     $this->em->persist($order);
     return $order;
 }
Ejemplo n.º 4
0
 /**
  * @param ObjectManager $om
  * @param Store         $store
  * @param Integration   $integration
  * @param Customer      $customer
  * @param string        $status
  * @param Cart          $cart
  * @param string        $paymentMethod
  * @param string        $paymentMethodDetails
  * @param mixed         $origin
  *
  * @return Order
  */
 protected function generateOrder(ObjectManager $om, Store $store, Integration $integration, Customer $customer, $status, Cart $cart, $paymentMethod, $paymentMethodDetails, $origin)
 {
     $order = new Order();
     $order->setOrganization($this->organization);
     $order->setChannel($integration);
     $order->setCustomer($customer);
     $order->setOwner($customer->getOwner());
     $order->setStatus($status);
     $order->setStore($store);
     $order->setStoreName($store->getName());
     $order->setIsGuest(0);
     $order->setIncrementId((string) $origin);
     $order->setCreatedAt(new \DateTime('now'));
     $order->setUpdatedAt(new \DateTime('now'));
     $order->setCart($cart);
     $order->setCurrency($cart->getBaseCurrencyCode());
     $order->setTotalAmount($cart->getGrandTotal());
     $order->setTotalInvoicedAmount($cart->getGrandTotal());
     $order->setDataChannel($this->dataChannel);
     if ($status == 'Completed') {
         $order->setTotalPaidAmount($cart->getGrandTotal());
     }
     $order->setSubtotalAmount($cart->getSubTotal());
     $order->setShippingAmount(rand(5, 10));
     $order->setPaymentMethod($paymentMethod);
     $order->setPaymentDetails($paymentMethodDetails);
     $order->setShippingMethod('flatrate_flatrate');
     $address = $this->getOrderAddress($om);
     $order->addAddress($address);
     $address->setOwner($order);
     $om->persist($order);
     return $order;
 }