|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2022-2023 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Admin\JQAdm\Order\Transaction; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
private $context; |
|
15
|
|
|
private $object; |
|
16
|
|
|
private $view; |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
protected function setUp() : void |
|
20
|
|
|
{ |
|
21
|
|
|
$this->view = \TestHelper::view(); |
|
22
|
|
|
$this->context = \TestHelper::context(); |
|
23
|
|
|
|
|
24
|
|
|
$this->object = new \Aimeos\Admin\JQAdm\Order\Transaction\Standard( $this->context ); |
|
25
|
|
|
$this->object = new \Aimeos\Admin\JQAdm\Common\Decorator\Page( $this->object, $this->context ); |
|
26
|
|
|
$this->object->setAimeos( \TestHelper::getAimeos() ); |
|
27
|
|
|
$this->object->setView( $this->view ); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
protected function tearDown() : void |
|
32
|
|
|
{ |
|
33
|
|
|
unset( $this->object, $this->view, $this->context ); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
public function testCopy() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->view->item = $this->getOrderBaseItem(); |
|
40
|
|
|
|
|
41
|
|
|
$result = $this->object->copy(); |
|
42
|
|
|
|
|
43
|
|
|
$this->assertStringContainsString( 'item-transaction', $result ); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
public function testCreate() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->view->item = $this->getOrderBaseItem(); |
|
50
|
|
|
|
|
51
|
|
|
$result = $this->object->create(); |
|
52
|
|
|
|
|
53
|
|
|
$this->assertStringContainsString( 'item-transaction', $result ); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
public function testGet() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->view->item = $this->getOrderBaseItem(); |
|
60
|
|
|
|
|
61
|
|
|
$result = $this->object->get(); |
|
62
|
|
|
|
|
63
|
|
|
$this->assertStringContainsString( 'item-transaction', $result ); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
public function testSave() |
|
68
|
|
|
{ |
|
69
|
|
|
$this->view->item = $this->getOrderBaseItem(); |
|
70
|
|
|
$serviceId = current( $this->view->item->getService( 'payment' ) )->getId(); |
|
71
|
|
|
|
|
72
|
|
|
$param = [ |
|
73
|
|
|
'site' => 'unittest', |
|
74
|
|
|
'transaction' => [ |
|
75
|
|
|
$serviceId => [ |
|
76
|
|
|
'order.service.transaction.value' => 10, |
|
77
|
|
|
'order.service.transaction.costs' => 1, |
|
78
|
|
|
] |
|
79
|
|
|
], |
|
80
|
|
|
]; |
|
81
|
|
|
|
|
82
|
|
|
$helper = new \Aimeos\Base\View\Helper\Param\Standard( $this->view, $param ); |
|
83
|
|
|
$this->view->addHelper( 'param', $helper ); |
|
84
|
|
|
|
|
85
|
|
|
$result = $this->object->save(); |
|
86
|
|
|
|
|
87
|
|
|
$this->assertEmpty( $result ); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
|
|
91
|
|
|
public function testGetSubClient() |
|
92
|
|
|
{ |
|
93
|
|
|
$this->expectException( \LogicException::class ); |
|
94
|
|
|
$this->object->getSubClient( 'unknown' ); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
protected function getViewNoRender() |
|
99
|
|
|
{ |
|
100
|
|
|
$view = $this->getMockBuilder( \Aimeos\Base\View\Standard::class ) |
|
101
|
|
|
->setConstructorArgs( array( [] ) ) |
|
102
|
|
|
->onlyMethods( ['render'] )->addMethods( ['config'] ) |
|
103
|
|
|
->getMock(); |
|
104
|
|
|
|
|
105
|
|
|
$view->item = $this->getOrderBaseItem(); |
|
|
|
|
|
|
106
|
|
|
|
|
107
|
|
|
return $view; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
protected function getOrderBaseItem( $value = '672.00' ) |
|
112
|
|
|
{ |
|
113
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'order' ); |
|
114
|
|
|
$search = $manager->filter()->add( 'order.price', '==', $value ); |
|
115
|
|
|
|
|
116
|
|
|
return $manager->search( $search, ['order/service'] ) |
|
117
|
|
|
->first( new \RuntimeException( 'No order item found' ) ); |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|