Completed
Push — master ( 341936...178071 )
by Florian
03:31
created

OrderPaymentPlaceEndTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 49
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B DownloadTest::setUp() 0 30 1
A DownloadTest::testExecute() 0 5 1
1
<?php
2
3
/**
4
 * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * PHP version 5
18
 *
19
 * @category  Payone
20
 * @package   Payone_Magento2_Plugin
21
 * @author    FATCHIP GmbH <[email protected]>
22
 * @copyright 2003 - 2017 Payone GmbH
23
 * @license   <http://www.gnu.org/licenses/> GNU Lesser General Public License
24
 * @link      http://www.payone.de
25
 */
26
27
namespace Payone\Core\Test\Unit\Controller\Mandate;
28
29
use Payone\Core\Controller\Mandate\Download as ClassToTest;
30
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
31
use Magento\Checkout\Model\Session;
32
use Payone\Core\Model\Api\Request\Getfile;
33
use Payone\Core\Helper\Payment;
34
use Magento\Framework\Controller\Result\RawFactory;
35
use Magento\Framework\Controller\Result\Raw;
36
use Magento\Sales\Model\Order;
37
38
class DownloadTest extends \PHPUnit_Framework_TestCase
39
{
40
    /**
41
     * @var ClassToTest
42
     */
43
    private $classToTest;
44
45
    /**
46
     * @var ObjectManager
47
     */
48
    private $objectManager;
49
50
    protected function setUp()
51
    {
52
        $this->objectManager = new ObjectManager($this);
53
54
        $order = $this->getMockBuilder(Order::class)->disableOriginalConstructor()->getMock();
55
        $order->method('getPayoneMandateId')->willReturn('12345');
56
57
        $checkoutSession = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
58
        $checkoutSession->method('getLastRealOrder')->willReturn($order);
59
60
        $getfileRequest = $this->getMockBuilder(Getfile::class)->disableOriginalConstructor()->getMock();
61
        $getfileRequest->method('sendRequest')->willReturn('Mandate Test Text');
62
63
        $paymentHelper = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->getMock();
64
        $paymentHelper->method('isMandateManagementDownloadActive')->willReturn(true);
65
66
        $rawResponse = $this->getMockBuilder(Raw::class)->disableOriginalConstructor()->getMock();
67
        $resultRawFactory = $this->getMockBuilder(RawFactory::class)
68
            ->disableOriginalConstructor()
69
            ->setMethods(['create'])
70
            ->getMock();
71
        $resultRawFactory->method('create')->willReturn($rawResponse);
72
73
        $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [
74
            'checkoutSession' => $checkoutSession,
75
            'getfileRequest' => $getfileRequest,
76
            'paymentHelper' => $paymentHelper,
77
            'resultRawFactory' => $resultRawFactory
78
        ]);
79
    }
80
81
    public function testExecute()
82
    {
83
        $result = $this->classToTest->execute();
84
        $this->assertInstanceOf(Raw::class, $result);
85
    }
86
}
87