1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2023 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\MShop\Group\Manager; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class Typo3Test extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $object = null; |
15
|
|
|
private $editor = ''; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
protected function setUp() : void |
19
|
|
|
{ |
20
|
|
|
$context = \TestHelper::context(); |
21
|
|
|
$this->editor = $context->editor(); |
22
|
|
|
|
23
|
|
|
$this->object = new \Aimeos\MShop\Group\Manager\Typo3( $context ); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
protected function tearDown() : void |
28
|
|
|
{ |
29
|
|
|
unset( $this->object ); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
public function testClear() |
34
|
|
|
{ |
35
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Manager\Iface::class, $this->object->clear( array( -1 ) ) ); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
public function testCreateItem() |
40
|
|
|
{ |
41
|
|
|
$item = $this->object->create(); |
42
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Group\Item\Iface::class, $item ); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
public function testCreateSearch() |
47
|
|
|
{ |
48
|
|
|
$this->assertInstanceOf( \Aimeos\Base\Criteria\Iface::class, $this->object->filter() ); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
public function testDeleteItems() |
53
|
|
|
{ |
54
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Manager\Iface::class, $this->object->delete( [-1] ) ); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
public function testGetResourceType() |
59
|
|
|
{ |
60
|
|
|
$this->assertContains( 'group', $this->object->getResourceType() ); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
public function testGetSearchAttributes() |
65
|
|
|
{ |
66
|
|
|
foreach( $this->object->getSearchAttributes() as $attribute ) { |
67
|
|
|
$this->assertInstanceOf( \Aimeos\Base\Criteria\Attribute\Iface::class, $attribute ); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
public function testFindItem() |
73
|
|
|
{ |
74
|
|
|
$item = $this->object->find( 'unitgroup' ); |
75
|
|
|
|
76
|
|
|
$this->assertEquals( 'unitgroup', $item->getCode() ); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
public function testGetItem() |
81
|
|
|
{ |
82
|
|
|
$item = $this->object->find( 'unitgroup' ); |
83
|
|
|
|
84
|
|
|
$this->assertEquals( $item, $this->object->get( $item->getId() ) ); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
public function testSaveUpdateDeleteItem() |
89
|
|
|
{ |
90
|
|
|
$item = $this->object->create(); |
91
|
|
|
$item->setCode( 'unittest-group' ); |
92
|
|
|
|
93
|
|
|
$resultSaved = $this->object->save( $item ); |
94
|
|
|
$itemSaved = $this->object->get( $item->getId() ); |
95
|
|
|
|
96
|
|
|
$itemExp = clone $itemSaved; |
97
|
|
|
$itemExp->setCode( 'unittest-group-2' ); |
98
|
|
|
|
99
|
|
|
$resultUpd = $this->object->save( $itemExp ); |
100
|
|
|
$itemUpd = $this->object->get( $itemExp->getId() ); |
101
|
|
|
|
102
|
|
|
$this->object->delete( $itemSaved->getId() ); |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
$this->assertTrue( $item->getId() !== null ); |
106
|
|
|
$this->assertEquals( $item->getId(), $itemSaved->getId() ); |
107
|
|
|
$this->assertEquals( $item->getCode(), $itemSaved->getCode() ); |
108
|
|
|
$this->assertEquals( $item->getLabel(), $itemSaved->getLabel() ); |
109
|
|
|
|
110
|
|
|
$this->assertMatchesRegularExpression( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeCreated() ); |
111
|
|
|
$this->assertMatchesRegularExpression( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemSaved->getTimeModified() ); |
112
|
|
|
|
113
|
|
|
$this->assertEquals( $itemExp->getId(), $itemUpd->getId() ); |
114
|
|
|
$this->assertEquals( $itemExp->getCode(), $itemUpd->getCode() ); |
115
|
|
|
$this->assertEquals( $itemExp->getLabel(), $itemUpd->getLabel() ); |
116
|
|
|
|
117
|
|
|
$this->assertEquals( $itemExp->getTimeCreated(), $itemUpd->getTimeCreated() ); |
118
|
|
|
$this->assertMatchesRegularExpression( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $itemUpd->getTimeModified() ); |
119
|
|
|
|
120
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Iface::class, $resultSaved ); |
121
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Iface::class, $resultUpd ); |
122
|
|
|
|
123
|
|
|
$this->expectException( \Aimeos\MShop\Exception::class ); |
124
|
|
|
$this->object->get( $itemSaved->getId() ); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
|
128
|
|
|
public function testSearchItem() |
129
|
|
|
{ |
130
|
|
|
$search = $this->object->filter(); |
131
|
|
|
$search->setConditions( $search->compare( '==', 'group.label', 'Unitgroup' ) ); |
132
|
|
|
$search->slice( 0, 1 ); |
133
|
|
|
|
134
|
|
|
$total = 0; |
135
|
|
|
$results = $this->object->search( $search, [], $total ); |
136
|
|
|
|
137
|
|
|
$this->assertEquals( 1, count( $results ) ); |
138
|
|
|
$this->assertEquals( 1, $total ); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
} |
142
|
|
|
|