1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Frontend\Customer; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit_Framework_TestCase |
13
|
|
|
{ |
14
|
|
|
private $context; |
15
|
|
|
private $object; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
protected function setUp() |
19
|
|
|
{ |
20
|
|
|
$this->context = \TestHelperFrontend::getContext(); |
21
|
|
|
$this->object = new \Aimeos\Controller\Frontend\Customer\Standard( $this->context ); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
protected function tearDown() |
26
|
|
|
{ |
27
|
|
|
unset( $this->context, $this->object ); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
public function testAddEditSaveDeleteItem() |
32
|
|
|
{ |
33
|
|
|
$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
34
|
|
|
$id = $manager->findItem( 'UTC001' )->getId(); |
35
|
|
|
|
36
|
|
|
$this->context->setUserId( $id ); |
37
|
|
|
$item = $this->object->addItem( ['customer.code' => 'unittest-ctnl', 'customer.status' => 1] ); |
38
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
39
|
|
|
|
40
|
|
|
$this->context->setUserId( $item->getId() ); |
41
|
|
|
$item = $this->object->editItem( $item->getId(), ['customer.code' => 'unittest-ctnl2'] ); |
42
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
43
|
|
|
|
44
|
|
|
$item->setStatus( 0 ); |
45
|
|
|
$this->object->saveItem( $item ); |
46
|
|
|
$this->assertEquals( 0, $item->getStatus() ); |
47
|
|
|
|
48
|
|
|
$this->object->deleteItem( $item->getId() ); |
49
|
|
|
|
50
|
|
|
$this->setExpectedException( '\Aimeos\MShop\Exception' ); |
51
|
|
|
$manager->findItem( 'unittest-ctnl' ); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
public function testCreateItem() |
56
|
|
|
{ |
57
|
|
|
$result = $this->object->createItem(); |
58
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
public function testGetItem() |
63
|
|
|
{ |
64
|
|
|
$id = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' )->getId(); |
65
|
|
|
$this->context->setUserId( $id ); |
66
|
|
|
|
67
|
|
|
$result = $this->object->getItem( $id, ['address', 'text'] ); |
68
|
|
|
|
69
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
70
|
|
|
$this->assertEquals( 1, count( $result->getRefItems( 'text' ) ) ); |
71
|
|
|
$this->assertEquals( 1, count( $result->getAddressItems() ) ); |
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
public function testFindItem() |
76
|
|
|
{ |
77
|
|
|
$result = $this->object->findItem( 'UTC001' ); |
78
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
public function testAddEditSaveDeleteAddressItem() |
83
|
|
|
{ |
84
|
|
|
$customer = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' ); |
85
|
|
|
$this->context->setUserId( $customer->getId() ); |
86
|
|
|
|
87
|
|
|
$item = $this->object->addAddressItem( ['customer.address.lastname' => 'unittest-ctnl'] ); |
88
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item ); |
89
|
|
|
|
90
|
|
|
$item = $this->object->editAddressItem( $item->getId(), ['customer.address.lastname' => 'unittest-ctnl2'] ); |
91
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item ); |
92
|
|
|
|
93
|
|
|
$item->setLastName( 'test' ); |
|
|
|
|
94
|
|
|
$this->object->saveAddressItem( $item ); |
|
|
|
|
95
|
|
|
$this->assertEquals( 'test', $item->getLastName() ); |
|
|
|
|
96
|
|
|
|
97
|
|
|
$this->object->deleteAddressItem( $item->getId() ); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
|
101
|
|
|
public function testCreateAddressItem() |
102
|
|
|
{ |
103
|
|
|
$result = $this->object->createAddressItem(); |
104
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result ); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
public function testGetAddressItem() |
109
|
|
|
{ |
110
|
|
|
$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer/address' ); |
111
|
|
|
$search = $manager->createSearch(); |
112
|
|
|
$search->setSlice( 0, 1 ); |
113
|
|
|
$result = $manager->searchItems( $search ); |
114
|
|
|
|
115
|
|
|
if( ( $item = reset( $result ) ) === false ) { |
116
|
|
|
throw new \RuntimeException( 'No customer address available' ); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
$this->context->setUserId( $item->getParentId() ); |
120
|
|
|
$result = $this->object->getAddressItem( $item->getId() ); |
121
|
|
|
$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result ); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.