|
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\Ui\Component\Listing\Column; |
|
28
|
|
|
|
|
29
|
|
|
use Payone\Core\Ui\Component\Listing\Column\ViewAction as ClassToTest; |
|
30
|
|
|
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
|
31
|
|
|
use Magento\Framework\View\Element\UiComponent\Context; |
|
32
|
|
|
use Magento\Framework\UrlInterface; |
|
33
|
|
|
use Magento\Framework\App\Request\Http; |
|
34
|
|
|
|
|
35
|
|
|
class ViewActionTest extends \PHPUnit_Framework_TestCase |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* @var ClassToTest |
|
39
|
|
|
*/ |
|
40
|
|
|
private $classToTest; |
|
41
|
|
|
|
|
42
|
|
|
protected function setUp() |
|
43
|
|
|
{ |
|
44
|
|
|
$objectManager = new ObjectManager($this); |
|
45
|
|
|
|
|
46
|
|
|
$urlBuilder = $this->getMockBuilder(UrlInterface::class)->disableOriginalConstructor()->getMock(); |
|
47
|
|
|
$urlBuilder->method('getUrl')->willReturn('http://testdomain.com'); |
|
48
|
|
|
|
|
49
|
|
|
$request = $this->getMockBuilder(Http::class) |
|
50
|
|
|
->disableOriginalConstructor() |
|
51
|
|
|
->setMethods(['getHeader']) |
|
52
|
|
|
->getMock(); |
|
53
|
|
|
$request->method('getHeader')->willReturn('html'); |
|
54
|
|
|
$context = $objectManager->getObject(Context::class, [ |
|
55
|
|
|
'request' => $request |
|
56
|
|
|
]); |
|
57
|
|
|
|
|
58
|
|
|
$data = [ |
|
59
|
|
|
'name' => 'Name', |
|
60
|
|
|
'config' => [ |
|
61
|
|
|
'viewUrlPath' => 'viewUrlPath', |
|
62
|
|
|
'urlEntityParamName' => 'urlEntityParamName', |
|
63
|
|
|
], |
|
64
|
|
|
]; |
|
65
|
|
|
|
|
66
|
|
|
$this->classToTest = $objectManager->getObject(ClassToTest::class, [ |
|
67
|
|
|
'context' => $context, |
|
68
|
|
|
'data' => $data, |
|
69
|
|
|
'urlBuilder' => $urlBuilder |
|
70
|
|
|
]); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function testPrepareDataSource() |
|
74
|
|
|
{ |
|
75
|
|
|
$input = [ |
|
76
|
|
|
'data' => [ |
|
77
|
|
|
'items' => [ |
|
78
|
|
|
['id' => '12345'], |
|
79
|
|
|
] |
|
80
|
|
|
] |
|
81
|
|
|
]; |
|
82
|
|
|
$result = $this->classToTest->prepareDataSource($input); |
|
83
|
|
|
$expected = 'http://testdomain.com'; |
|
84
|
|
|
$this->assertEquals($expected, $result['data']['items'][0]['Name']['view']['href']); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|