public function testSendVirtualOrder()
 {
     $isVirtualOrder = true;
     $this->orderMock->setData(\Magento\Sales\Api\Data\OrderInterface::IS_VIRTUAL, $isVirtualOrder);
     $this->stepAddressFormat($this->addressMock, $isVirtualOrder);
     $this->identityContainerMock->expects($this->once())->method('isEnabled')->will($this->returnValue(false));
     $this->templateContainerMock->expects($this->once())->method('setTemplateVars')->with($this->equalTo(['order' => $this->orderMock, 'comment' => '', 'billing' => $this->addressMock, 'store' => $this->storeMock, 'formattedShippingAddress' => null, 'formattedBillingAddress' => 1]));
     $this->assertFalse($this->sender->send($this->orderMock));
 }
Exemplo n.º 2
0
 public function testSendTrue()
 {
     $billingAddress = $this->addressMock;
     $comment = 'comment_test';
     $this->stepAddressFormat($billingAddress);
     $this->orderMock->expects($this->once())->method('getCustomerIsGuest')->will($this->returnValue(false));
     $this->identityContainerMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
     $this->templateContainerMock->expects($this->once())->method('setTemplateVars')->with($this->equalTo(['order' => $this->orderMock, 'billing' => $billingAddress, 'comment' => $comment, 'store' => $this->storeMock, 'formattedShippingAddress' => 1, 'formattedBillingAddress' => 1]));
     $this->stepSendWithoutSendCopy();
     $result = $this->sender->send($this->orderMock, true, $comment);
     $this->assertTrue($result);
 }
 public function testSendTrue()
 {
     $billingAddress = 'billing_address';
     $comment = 'comment_test';
     $this->orderMock->expects($this->once())->method('getCustomerIsGuest')->will($this->returnValue(false));
     $this->orderMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($billingAddress));
     $this->identityContainerMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
     $this->templateContainerMock->expects($this->once())->method('setTemplateVars')->with($this->equalTo(['order' => $this->orderMock, 'billing' => $billingAddress, 'comment' => $comment, 'store' => $this->storeMock]));
     $senderMock = $this->getMock('Magento\\Sales\\Model\\Order\\Email\\Sender', ['send', 'sendCopyTo'], [], '', false);
     $senderMock->expects($this->once())->method('send');
     $senderMock->expects($this->never())->method('sendCopyTo');
     $this->senderBuilderFactoryMock->expects($this->once())->method('create')->will($this->returnValue($senderMock));
     $result = $this->sender->send($this->orderMock, true, $comment);
     $this->assertTrue($result);
 }
Exemplo n.º 4
0
 /**
  * Add comment to order
  *
  * @param int $id
  * @param \Magento\Sales\Api\Data\OrderStatusHistoryInterface $statusHistory
  * @return bool
  */
 public function addComment($id, \Magento\Sales\Api\Data\OrderStatusHistoryInterface $statusHistory)
 {
     $order = $this->orderRepository->get($id);
     $order->addStatusHistory($statusHistory);
     $this->orderRepository->save($order);
     $notify = isset($statusHistory['is_customer_notified']) ? $statusHistory['is_customer_notified'] : false;
     $comment = trim(strip_tags($statusHistory->getComment()));
     $this->orderCommentSender->send($order, $notify, $comment);
     return true;
 }
Exemplo n.º 5
0
 public function testAddComment()
 {
     $clearComment = "Comment text here...";
     $this->orderRepositoryMock->expects($this->once())->method('get')->with(123)->willReturn($this->orderMock);
     $this->orderMock->expects($this->once())->method('addStatusHistory')->with($this->orderStatusHistoryMock)->willReturn($this->orderMock);
     $this->orderStatusHistoryMock->expects($this->once())->method('getComment')->willReturn("<h1>" . $clearComment);
     $this->orderRepositoryMock->expects($this->once())->method('save')->with($this->orderMock)->willReturn([]);
     $this->orderCommentSender->expects($this->once())->method('send')->with($this->orderMock, false, $clearComment);
     $this->assertTrue($this->orderService->addComment(123, $this->orderStatusHistoryMock));
 }