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\PersonStatusMapping as ClassToTest; |
30
|
|
|
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
31
|
|
|
use Magento\Framework\Data\Form\Element\Factory; |
32
|
|
|
use Payone\Core\Model\Source\PersonStatus; |
33
|
|
|
use Payone\Core\Model\Source\CreditScore; |
34
|
|
|
use Magento\Framework\Data\Form\Element\AbstractElement; |
35
|
|
|
use Magento\Framework\Data\Form\Element\Multiselect; |
36
|
|
|
use Magento\Framework\Data\Form\AbstractForm; |
37
|
|
|
|
38
|
|
|
class PersonStatusMappingTest 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
|
|
|
$form = $this->getMockBuilder(AbstractForm::class)->disableOriginalConstructor()->getMock(); |
55
|
|
|
|
56
|
|
|
$element = $this->getMockBuilder(AbstractElement::class) |
57
|
|
|
->disableOriginalConstructor() |
58
|
|
|
->setMethods(['setForm', 'getForm', 'setName', 'setHtmlId', 'setValues']) |
59
|
|
|
->getMock(); |
60
|
|
|
$element->method('getForm')->willReturn($form); |
61
|
|
|
|
62
|
|
|
$elementFactory = $this->getMockBuilder(Factory::class)->disableOriginalConstructor()->getMock(); |
63
|
|
|
$elementFactory->method('create')->willReturn($element); |
64
|
|
|
|
65
|
|
|
$personStatus = $this->getMockBuilder(PersonStatus::class)->disableOriginalConstructor()->getMock(); |
66
|
|
|
$personStatus->method('toOptionArray')->willReturn([ |
67
|
|
|
['value' => 'NONE', 'label' => 'NONE'] |
68
|
|
|
]); |
69
|
|
|
|
70
|
|
|
$creditScore = $this->getMockBuilder(CreditScore::class)->disableOriginalConstructor()->getMock(); |
71
|
|
|
$creditScore->method('toOptionArray')->willReturn([ |
72
|
|
|
['value' => 'G', 'label' => 'Green'] |
73
|
|
|
]); |
74
|
|
|
|
75
|
|
|
$this->classToTest = $this->objectManager->getObject(ClassToTest::class, [ |
76
|
|
|
'elementFactory' => $elementFactory, |
77
|
|
|
'personStatus' => $personStatus, |
78
|
|
|
'creditScore' => $creditScore |
79
|
|
|
]); |
80
|
|
|
|
81
|
|
|
$form = $this->objectManager->getObject(AbstractForm::class); |
82
|
|
|
$element = $this->objectManager->getObject(Multiselect::class); |
83
|
|
|
$element->setValue([['te<s>t' => 't<e>st', 'data&1' => 'da&ta1']]); |
84
|
|
|
$element->setForm($form); |
85
|
|
|
$this->classToTest->setElement($element); |
86
|
|
|
$this->classToTest->setForm($form); |
87
|
|
|
$this->classToTest->addColumn('dummy', ['label' => __('Dummy')]); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function testRenderCellTemplate() |
91
|
|
|
{ |
92
|
|
|
$result = $this->classToTest->renderCellTemplate('personstatus'); |
93
|
|
|
$this->assertNotEmpty($result); |
94
|
|
|
|
95
|
|
|
$result = $this->classToTest->renderCellTemplate('score'); |
96
|
|
|
$this->assertNotEmpty($result); |
97
|
|
|
|
98
|
|
|
$result = $this->classToTest->renderCellTemplate('dummy'); |
99
|
|
|
$this->assertNotEmpty($result); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|