SofortUeberweisungTest::testAssignData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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\Model\Methods\OnlineBankTransfer;
28
29
use Magento\Quote\Model\Quote\Address;
30
use Payone\Core\Helper\Toolkit;
31
use Payone\Core\Model\Methods\OnlineBankTransfer\SofortUeberweisung as ClassToTest;
32
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
33
use Magento\Sales\Model\Order;
34
use Magento\Payment\Model\InfoInterface;
35
use Magento\Framework\DataObject;
36
use Payone\Core\Test\Unit\BaseTestCase;
37
use Payone\Core\Model\Test\PayoneObjectManager;
38
39
class SofortUeberweisungTest extends BaseTestCase
40
{
41
    /**
42
     * @var ClassToTest
43
     */
44
    private $classToTest;
45
46
    /**
47
     * @var ObjectManager|PayoneObjectManager
48
     */
49
    private $objectManager;
50
51
    protected function setUp()
52
    {
53
        $this->objectManager = $this->getObjectManager();
54
55
        $info = $this->getMockBuilder(InfoInterface::class)->disableOriginalConstructor()->getMock();
56
        $info->method('getAdditionalInformation')->willReturn('info');
57
58
        $toolkitHelper = $this->getMockBuilder(Toolkit::class)->disableOriginalConstructor()->getMock();
59
        $toolkitHelper->method('getAdditionalDataEntry')->willReturn('info');
60
61
        $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [
62
            'toolkitHelper' => $toolkitHelper
63
        ]);
64
        $this->classToTest->setInfoInstance($info);
65
    }
66
67
    public function testGetSubTypeSpecificParameters()
68
    {
69
        $address = $this->getMockBuilder(Address::class)->disableOriginalConstructor()->getMock();
70
        $address->method('getCountryId')->willReturn('DE');
71
        $order = $this->getMockBuilder(Order::class)->disableOriginalConstructor()->getMock();
72
        $order->method('getBillingAddress')->willReturn($address);
73
74
        $result = $this->classToTest->getSubTypeSpecificParameters($order);
75
        $expected = ['bankcountry' => 'DE', 'iban' => 'info', 'bic' => 'info'];
76
        $this->assertEquals($expected, $result);
77
    }
78
79
    public function testAssignData()
80
    {
81
        $data = $this->getMockBuilder(DataObject::class)->disableOriginalConstructor()->getMock();
82
83
        $result = $this->classToTest->assignData($data);
84
        $this->assertInstanceOf(ClassToTest::class, $result);
85
    }
86
87
    public function testIsGroupMethod()
88
    {
89
        $result = $this->classToTest->isGroupMethod();
90
        $this->assertTrue($result);
91
    }
92
}
93