|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2014 |
|
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2023 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
namespace Aimeos\Controller\Frontend\Order; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
private $object; |
|
16
|
|
|
private $context; |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
protected function setUp() : void |
|
20
|
|
|
{ |
|
21
|
|
|
\Aimeos\MShop::cache( true ); |
|
22
|
|
|
|
|
23
|
|
|
$this->context = \TestHelper::context(); |
|
24
|
|
|
$this->object = new \Aimeos\Controller\Frontend\Order\Standard( $this->context ); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
protected function tearDown() : void |
|
29
|
|
|
{ |
|
30
|
|
|
\Aimeos\MShop::cache( false ); |
|
31
|
|
|
unset( $this->object, $this->context ); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
public function testCompare() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->assertSame( $this->object, $this->object->compare( '==', 'order.type', 'test' ) ); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
public function testGet() |
|
42
|
|
|
{ |
|
43
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'order' ); |
|
44
|
|
|
$items = $manager->search( $manager->filter()->slice( 0, 1 ) ); |
|
45
|
|
|
|
|
46
|
|
|
if( ( $item = $items->first() ) === null ) { |
|
47
|
|
|
throw new \RuntimeException( 'No order item found' ); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
$this->assertEquals( $item, $this->object->get( $item->getId(), false ) ); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
public function testParse() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->assertSame( $this->object, $this->object->parse( [] ) ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
public function testSave() |
|
61
|
|
|
{ |
|
62
|
|
|
$manager = $this->getMockBuilder( \Aimeos\MShop\Order\Manager\Standard::class ) |
|
63
|
|
|
->setConstructorArgs( [$this->context] ) |
|
64
|
|
|
->onlyMethods( ['save'] ) |
|
65
|
|
|
->getMock(); |
|
66
|
|
|
|
|
67
|
|
|
\Aimeos\MShop::inject( \Aimeos\MShop\Order\Manager\Standard::class, $manager ); |
|
68
|
|
|
|
|
69
|
|
|
$item = $manager->create(); |
|
70
|
|
|
$object = new \Aimeos\Controller\Frontend\Order\Standard( $this->context ); |
|
71
|
|
|
|
|
72
|
|
|
$manager->expects( $this->once() )->method( 'save' )->will( $this->returnArgument( 0 ) ); |
|
73
|
|
|
|
|
74
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Iface::class, $object->save( $item ) ); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
public function testSearch() |
|
79
|
|
|
{ |
|
80
|
|
|
$user = \Aimeos\MShop::create( $this->context, 'customer' )->find( '[email protected]' ); |
|
81
|
|
|
$this->context->setUser( $user ); |
|
82
|
|
|
|
|
83
|
|
|
$total = 0; |
|
84
|
|
|
$object = new \Aimeos\Controller\Frontend\Order\Standard( $this->context ); |
|
85
|
|
|
$items = $object->uses( ['order'] )->search( $total ); |
|
86
|
|
|
|
|
87
|
|
|
$this->assertGreaterThanOrEqual( 4, $items->count() ); |
|
88
|
|
|
$this->assertGreaterThanOrEqual( 4, $total ); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
public function testSlice() |
|
93
|
|
|
{ |
|
94
|
|
|
$this->assertSame( $this->object, $this->object->slice( 0, 100 ) ); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
public function testSort() |
|
99
|
|
|
{ |
|
100
|
|
|
$this->assertSame( $this->object, $this->object->sort( '-order.type,order.id' ) ); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
|
|
104
|
|
|
public function testUpdate() |
|
105
|
|
|
{ |
|
106
|
|
|
$manager = $this->getMockBuilder( \Aimeos\MShop\Order\Manager\Standard::class ) |
|
107
|
|
|
->setConstructorArgs( [$this->context] ) |
|
108
|
|
|
->onlyMethods( ['update'] ) |
|
109
|
|
|
->getMock(); |
|
110
|
|
|
|
|
111
|
|
|
\Aimeos\MShop::inject( \Aimeos\MShop\Order\Manager\Standard::class, $manager ); |
|
112
|
|
|
|
|
113
|
|
|
$object = new \Aimeos\Controller\Frontend\Order\Standard( $this->context ); |
|
114
|
|
|
|
|
115
|
|
|
$manager->expects( $this->once() )->method( 'update' )->will( $this->returnArgument( 0 ) ); |
|
116
|
|
|
|
|
117
|
|
|
$this->assertSame( $object, $object->update( $manager->create() ) ); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
public function testUses() |
|
122
|
|
|
{ |
|
123
|
|
|
$this->assertSame( $this->object, $this->object->uses( ['order'] ) ); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|