Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OrderCommentSenderTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Sales\Model\Order\Email\Sender\OrderCommentSender;
9 
11 {
15  protected $sender;
16 
17  protected function setUp()
18  {
19  $this->stepMockSetup();
20  $this->stepIdentityContainerInit(\Magento\Sales\Model\Order\Email\Container\OrderCommentIdentity::class);
21  $this->addressRenderer->expects($this->any())->method('format')->willReturn(1);
22  $this->sender = new OrderCommentSender(
23  $this->templateContainerMock,
24  $this->identityContainerMock,
25  $this->senderBuilderFactoryMock,
26  $this->loggerMock,
27  $this->addressRenderer,
28  $this->eventManagerMock
29  );
30  }
31 
32  public function testSendFalse()
33  {
34  $this->stepAddressFormat($this->addressMock);
35  $result = $this->sender->send($this->orderMock);
36  $this->assertFalse($result);
37  }
38 
39  public function testSendTrue()
40  {
42  $comment = 'comment_test';
44  $this->orderMock->expects($this->once())
45  ->method('getCustomerIsGuest')
46  ->will($this->returnValue(false));
47 
48  $this->identityContainerMock->expects($this->once())
49  ->method('isEnabled')
50  ->will($this->returnValue(true));
51  $this->templateContainerMock->expects($this->once())
52  ->method('setTemplateVars')
53  ->with(
54  $this->equalTo(
55  [
56  'order' => $this->orderMock,
57  'billing' => $billingAddress,
58  'comment' => $comment,
59  'store' => $this->storeMock,
60  'formattedShippingAddress' => 1,
61  'formattedBillingAddress' => 1
62  ]
63  )
64  );
65  $this->stepSendWithoutSendCopy();
66  $result = $this->sender->send($this->orderMock, true, $comment);
67  $this->assertTrue($result);
68  }
69 
70  public function testSendVirtualOrder()
71  {
72  $isVirtualOrder = true;
73  $this->orderMock->setData(\Magento\Sales\Api\Data\OrderInterface::IS_VIRTUAL, $isVirtualOrder);
74  $this->stepAddressFormat($this->addressMock, $isVirtualOrder);
75 
76  $this->identityContainerMock->expects($this->once())
77  ->method('isEnabled')
78  ->will($this->returnValue(false));
79  $this->templateContainerMock->expects($this->once())
80  ->method('setTemplateVars')
81  ->with(
82  $this->equalTo(
83  [
84  'order' => $this->orderMock,
85  'comment' => '',
86  'billing' => $this->addressMock,
87  'store' => $this->storeMock,
88  'formattedShippingAddress' => null,
89  'formattedBillingAddress' => 1
90  ]
91  )
92  );
93  $this->assertFalse($this->sender->send($this->orderMock));
94  }
95 }
$billingAddress
Definition: order.php:25