Completed
Push — master ( 342d7b...50fff4 )
by Florian
13s
created

CreditcardTemplateTest::testFcpoGetValueNoArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
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\Block\Adminhtml\Config\Form\Field;
28
29
use Payone\Core\Block\Adminhtml\Config\Form\Field\CreditcardTemplate as ClassToTest;
30
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
31
use Magento\Framework\Data\Form\Element\Multiselect;
32
use Magento\Framework\Data\Form\AbstractForm;
33
use Payone\Core\Test\Unit\BaseTestCase;
34
use Payone\Core\Model\Test\PayoneObjectManager;
35
36
class CreditcardTemplateTest extends BaseTestCase
37
{
38
    /**
39
     * @var ClassToTest
40
     */
41
    private $classToTest;
42
43
    /**
44
     * @var ObjectManager|PayoneObjectManager
45
     */
46
    private $objectManager;
47
48
    /**
49
     * @var Multiselect
50
     */
51
    private $element;
52
53
    protected function setUp()
54
    {
55
        $this->objectManager = $this->getObjectManager();
56
57
        $this->classToTest = $this->objectManager->getObject(ClassToTest::class);
58
59
        $form = $this->objectManager->getObject(AbstractForm::class);
60
61
        $this->element = $this->objectManager->getObject(Multiselect::class);
62
        $this->element->setValue(['Number_height' => '20px']);
63
        $this->element->setForm($form);
64
65
        $this->classToTest->setElement($this->element);
66
        $this->classToTest->addColumn('dummy', ['label' => __('Dummy')]);
67
        $this->classToTest->setForm($form);
68
    }
69
70
    public function testGetCCFields()
71
    {
72
        $result = $this->classToTest->getCCFields();
73
        $expected = ['Number', 'CVC', 'Month', 'Year'];
74
        $this->assertEquals($expected, $result);
75
    }
76
77
    public function testGetCCStyles()
78
    {
79
        $result = $this->classToTest->getCCStyles();
80
        $expected = ['standard' => 'Standard', 'custom' => 'Custom'];
81
        $this->assertEquals($expected, $result);
82
    }
83
84
    public function testGetCCTypes()
85
    {
86
        $result = $this->classToTest->getCCTypes('Year');
87
        $expected = ['select' => 'Select', 'tel' => 'Numeric', 'password' => 'Password', 'text' => 'Text'];
88
        $this->assertEquals($expected, $result);
89
    }
90
91
    public function testFcpoGetValue()
92
    {
93
        $result = $this->classToTest->fcpoGetValue('Number_height');
94
        $expected = '20px';
95
        $this->assertEquals($expected, $result);
96
97
        $result = $this->classToTest->fcpoGetValue('CVC_iframe');
98
        $expected = 'standard';
99
        $this->assertEquals($expected, $result);
100
    }
101
102
    public function testFcpoGetValueNoArray()
103
    {
104
        $this->element->setValue(json_encode(['Number_height' => '40px']));
105
        $result = $this->classToTest->fcpoGetValue('Number_height');
106
        $expected = '40px';
107
        $this->assertEquals($expected, $result);
108
    }
109
}
110