15 use PHPUnit_Framework_MockObject_MockObject as MockObject;
46 $this->payment = $this->getMockBuilder(Payment::class)
47 ->disableOriginalConstructor()
50 $this->
event = $this->getMockBuilder(Event::class)
51 ->disableOriginalConstructor()
52 ->setMethods([
'getPayment'])
55 $this->
event->expects(self::once())
56 ->method(
'getPayment')
57 ->willReturn($this->payment);
59 $this->observer = $this->getMockBuilder(Observer::class)
60 ->disableOriginalConstructor()
63 $this->observer->expects(self::once())
65 ->willReturn($this->event);
67 $this->_model = $objectManagerHelper->getObject(BeforeOrderPaymentSaveObserver::class);
76 $this->payment->expects(self::once())
79 $this->payment->expects(self::once())
80 ->method(
'setAdditionalInformation')
81 ->with(
'instructions',
'payment configuration');
82 $method = $this->getMockBuilder(Banktransfer::class)
83 ->disableOriginalConstructor()
87 ->method(
'getInstructions')
88 ->willReturn(
'payment configuration');
89 $this->payment->expects(self::once())
90 ->method(
'getMethodInstance')
93 $this->_model->execute($this->observer);
111 $this->payment->expects(self::exactly(2))
112 ->method(
'getMethod')
114 $this->payment->expects(self::exactly(2))
115 ->method(
'setAdditionalInformation')
118 [
'payable_to',
'payable to', $this->payment],
119 [
'mailing_address',
'mailing address', $this->payment],
123 $method = $this->getMockBuilder(Checkmo::class)
124 ->disableOriginalConstructor()
126 $method->expects(self::exactly(2))
127 ->method(
'getPayableTo')
128 ->willReturn(
'payable to');
129 $method->expects(self::exactly(2))
130 ->method(
'getMailingAddress')
131 ->willReturn(
'mailing address');
132 $this->payment->expects(self::once())
133 ->method(
'getMethodInstance')
135 $this->_model->execute($this->observer);
144 $this->payment->expects(self::exactly(2))
145 ->method(
'getMethod')
147 $this->payment->expects(self::never())
148 ->method(
'setAdditionalInformation');
150 $method = $this->getMockBuilder(Checkmo::class)
151 ->disableOriginalConstructor()
154 ->method(
'getPayableTo')
157 ->method(
'getMailingAddress')
159 $this->payment->expects(self::once())
160 ->method(
'getMethodInstance')
162 $this->_model->execute($this->observer);
167 $this->payment->expects(self::exactly(2))
168 ->method(
'getMethod')
169 ->willReturn(
'somepaymentmethod');
170 $this->payment->expects(self::never())
171 ->method(
'setAdditionalInformation');
173 $this->_model->execute($this->observer);
const PAYMENT_METHOD_BANKTRANSFER_CODE
testBeforeOrderPaymentSaveWithOthers()
const PAYMENT_METHOD_CHECKMO_CODE
const PAYMENT_METHOD_CASHONDELIVERY_CODE
testBeforeOrderPaymentSaveWithCheckmoWithoutConfig()
testBeforeOrderPaymentSaveWithInstructions($methodCode)
testBeforeOrderPaymentSaveWithCheckmo()
dataProviderBeforeOrderPaymentSaveWithInstructions()