/** * @dataProvider isCanceledDataProvider * @param $status * @param $result */ public function testIsCanceled($status, $result) { $this->entity->setStatus($status); if ($result) { $this->assertTrue($this->entity->isCanceled()); } else { $this->assertFalse($this->entity->isCanceled()); } }
/** * @param EntityManager $entityManager * @param Order $order */ protected function updateCustomerLifetime(EntityManager $entityManager, Order $order) { /** @var CustomerRepository $customerRepository */ $customerRepository = $entityManager->getRepository('OroCRMMagentoBundle:Customer'); $subtotalAmount = $order->getSubtotalAmount(); if ($subtotalAmount) { $discountAmount = $order->getDiscountAmount(); $lifetimeValue = $discountAmount ? $subtotalAmount - abs($discountAmount) : $subtotalAmount; // if order status changed to canceled we should remove order lifetime value from customer lifetime if ($order->isCanceled()) { $lifetimeValue *= -1; } $customer = $order->getCustomer(); $customerRepository->updateCustomerLifetimeValue($customer, $lifetimeValue); // schedule lifetime history update if ($customer->getAccount()) { $this->channelDoctrineListener->scheduleEntityUpdate($customer, $customer->getAccount(), $customer->getDataChannel()); } } }