Code Duplication    Length = 12-16 lines in 4 locations

Test/Unit/Controller/Onepage/DebitTest.php 1 location

@@ 181-192 (lines=12) @@
178
        $this->assertNull($result);
179
    }
180
181
    public function testExecuteMandatePending()
182
    {
183
        $paymentMethod = $this->getMockBuilder(PayoneMethod::class)->disableOriginalConstructor()->getMock();
184
        $paymentMethod->method('getCustomConfigParam')->willReturn(true);
185
        $this->payment->method('getMethodInstance')->willReturn($paymentMethod);
186
        $this->request->method('getParam')->willReturn(1);
187
        $this->checkoutSession->method('getPayoneMandate')->willReturn(null);
188
        $this->managemandateRequest->method('sendRequest')->willReturn(['status' => 'VALID', 'mandate_status' => 'pending']);
189
190
        $result = $this->classToTest->execute();
191
        $this->assertInstanceOf(Page::class, $result);
192
    }
193
194
    public function testExecuteMandateError()
195
    {

Test/Unit/Controller/Paypal/ExpressTest.php 3 locations

@@ 149-164 (lines=16) @@
146
        $this->assertInstanceOf(Redirect::class, $result);
147
    }
148
149
    public function testExecuteStatusError()
150
    {
151
        $this->paymentHelper->method('isPayPalExpressActive')->willReturn(true);
152
        $this->checkoutHelper->method('isAllowedGuestCheckout')->willReturn(false);
153
154
        $customer = $this->getMockBuilder(CustomerInterface::class)->disableOriginalConstructor()->getMock();
155
        $customer->method('getId')->willReturn(15);
156
157
        $this->customerSession->method('getCustomerDataObject')->willReturn($customer);
158
159
        $response = ['status' => 'ERROR', 'customermessage' => 'An error occured'];
160
        $this->genericRequest->method('sendRequest')->willReturn($response);
161
162
        $result = $this->classToTest->execute();
163
        $this->assertInstanceOf(Redirect::class, $result);
164
    }
165
166
    public function testExecuteStatusErrorGuestAllowed()
167
    {
@@ 166-181 (lines=16) @@
163
        $this->assertInstanceOf(Redirect::class, $result);
164
    }
165
166
    public function testExecuteStatusErrorGuestAllowed()
167
    {
168
        $this->paymentHelper->method('isPayPalExpressActive')->willReturn(true);
169
        $this->checkoutHelper->method('isAllowedGuestCheckout')->willReturn(true);
170
171
        $customer = $this->getMockBuilder(CustomerInterface::class)->disableOriginalConstructor()->getMock();
172
        $customer->method('getId')->willReturn(null);
173
174
        $this->customerSession->method('getCustomerDataObject')->willReturn($customer);
175
176
        $response = ['status' => 'ERROR', 'customermessage' => 'An error occured'];
177
        $this->genericRequest->method('sendRequest')->willReturn($response);
178
179
        $result = $this->classToTest->execute();
180
        $this->assertInstanceOf(Redirect::class, $result);
181
    }
182
183
    public function testExecuteStatusRedirect()
184
    {
@@ 183-198 (lines=16) @@
180
        $this->assertInstanceOf(Redirect::class, $result);
181
    }
182
183
    public function testExecuteStatusRedirect()
184
    {
185
        $this->paymentHelper->method('isPayPalExpressActive')->willReturn(true);
186
        $this->checkoutHelper->method('isAllowedGuestCheckout')->willReturn(false);
187
188
        $customer = $this->getMockBuilder(CustomerInterface::class)->disableOriginalConstructor()->getMock();
189
        $customer->method('getId')->willReturn(15);
190
191
        $this->customerSession->method('getCustomerDataObject')->willReturn($customer);
192
193
        $response = ['status' => 'REDIRECT', 'workorderid' => '12345', 'redirecturl' => 'http://redirect.org'];
194
        $this->genericRequest->method('sendRequest')->willReturn($response);
195
196
        $result = $this->classToTest->execute();
197
        $this->assertNull($result);
198
    }
199
}
200