| @@ 183-194 (lines=12) @@ | ||
| 180 | $this->assertNull($result); |
|
| 181 | } |
|
| 182 | ||
| 183 | public function testExecuteMandatePending() |
|
| 184 | { |
|
| 185 | $paymentMethod = $this->getMockBuilder(PayoneMethod::class)->disableOriginalConstructor()->getMock(); |
|
| 186 | $paymentMethod->method('getCustomConfigParam')->willReturn(true); |
|
| 187 | $this->payment->method('getMethodInstance')->willReturn($paymentMethod); |
|
| 188 | $this->request->method('getParam')->willReturn(1); |
|
| 189 | $this->checkoutSession->method('getPayoneMandate')->willReturn(null); |
|
| 190 | $this->managemandateRequest->method('sendRequest')->willReturn(['status' => 'VALID', 'mandate_status' => 'pending']); |
|
| 191 | ||
| 192 | $result = $this->classToTest->execute(); |
|
| 193 | $this->assertInstanceOf(Page::class, $result); |
|
| 194 | } |
|
| 195 | ||
| 196 | public function testExecuteMandateError() |
|
| 197 | { |
|
| @@ 155-170 (lines=16) @@ | ||
| 152 | $this->assertInstanceOf(Redirect::class, $result); |
|
| 153 | } |
|
| 154 | ||
| 155 | public function testExecuteStatusError() |
|
| 156 | { |
|
| 157 | $this->paymentHelper->method('isPayPalExpressActive')->willReturn(true); |
|
| 158 | $this->checkoutHelper->method('isAllowedGuestCheckout')->willReturn(false); |
|
| 159 | ||
| 160 | $customer = $this->getMockBuilder(CustomerInterface::class)->disableOriginalConstructor()->getMock(); |
|
| 161 | $customer->method('getId')->willReturn(15); |
|
| 162 | ||
| 163 | $this->customerSession->method('getCustomerDataObject')->willReturn($customer); |
|
| 164 | ||
| 165 | $response = ['status' => 'ERROR', 'customermessage' => 'An error occured']; |
|
| 166 | $this->genericRequest->method('sendRequest')->willReturn($response); |
|
| 167 | ||
| 168 | $result = $this->classToTest->execute(); |
|
| 169 | $this->assertInstanceOf(Redirect::class, $result); |
|
| 170 | } |
|
| 171 | ||
| 172 | public function testExecuteStatusErrorGuestAllowed() |
|
| 173 | { |
|
| @@ 172-187 (lines=16) @@ | ||
| 169 | $this->assertInstanceOf(Redirect::class, $result); |
|
| 170 | } |
|
| 171 | ||
| 172 | public function testExecuteStatusErrorGuestAllowed() |
|
| 173 | { |
|
| 174 | $this->paymentHelper->method('isPayPalExpressActive')->willReturn(true); |
|
| 175 | $this->checkoutHelper->method('isAllowedGuestCheckout')->willReturn(true); |
|
| 176 | ||
| 177 | $customer = $this->getMockBuilder(CustomerInterface::class)->disableOriginalConstructor()->getMock(); |
|
| 178 | $customer->method('getId')->willReturn(null); |
|
| 179 | ||
| 180 | $this->customerSession->method('getCustomerDataObject')->willReturn($customer); |
|
| 181 | ||
| 182 | $response = ['status' => 'ERROR', 'customermessage' => 'An error occured']; |
|
| 183 | $this->genericRequest->method('sendRequest')->willReturn($response); |
|
| 184 | ||
| 185 | $result = $this->classToTest->execute(); |
|
| 186 | $this->assertInstanceOf(Redirect::class, $result); |
|
| 187 | } |
|
| 188 | ||
| 189 | public function testExecuteStatusRedirect() |
|
| 190 | { |
|
| @@ 189-204 (lines=16) @@ | ||
| 186 | $this->assertInstanceOf(Redirect::class, $result); |
|
| 187 | } |
|
| 188 | ||
| 189 | public function testExecuteStatusRedirect() |
|
| 190 | { |
|
| 191 | $this->paymentHelper->method('isPayPalExpressActive')->willReturn(true); |
|
| 192 | $this->checkoutHelper->method('isAllowedGuestCheckout')->willReturn(false); |
|
| 193 | ||
| 194 | $customer = $this->getMockBuilder(CustomerInterface::class)->disableOriginalConstructor()->getMock(); |
|
| 195 | $customer->method('getId')->willReturn(15); |
|
| 196 | ||
| 197 | $this->customerSession->method('getCustomerDataObject')->willReturn($customer); |
|
| 198 | ||
| 199 | $response = ['status' => 'REDIRECT', 'workorderid' => '12345', 'redirecturl' => 'http://redirect.org']; |
|
| 200 | $this->genericRequest->method('sendRequest')->willReturn($response); |
|
| 201 | ||
| 202 | $result = $this->classToTest->execute(); |
|
| 203 | $this->assertNull($result); |
|
| 204 | } |
|
| 205 | } |
|
| 206 | ||