Passed
Push — master ( c9dfc7...a4ce90 )
by Aimeos
01:38
created

StandardTest::testUses()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2018
6
 */
7
8
9
namespace Aimeos\Controller\Frontend\Customer;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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->object, $this->context );
28
	}
29
30
31
	public function testAdd()
32
	{
33
		$this->assertSame( $this->object, $this->object->add( ['customer.code' => 'test'] ) );
34
		$this->assertEquals( 'test', $this->object->get()->getCode() );
35
	}
36
37
38
	public function testAddAddressItem()
39
	{
40
		$item = \Aimeos\MShop::create( $this->context, 'customer/address' )->createItem();
41
		$this->assertSame( $this->object, $this->object->addAddressItem( $item ) );
42
	}
43
44
45
	public function testAddListItem()
46
	{
47
		$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->createItem();
48
		$this->assertSame( $this->object, $this->object->addListItem( 'customer', $listItem ) );
49
	}
50
51
52
	public function testAddPropertyItem()
53
	{
54
		$item = \Aimeos\MShop::create( $this->context, 'customer/property' )->createItem();
55
		$this->assertSame( $this->object, $this->object->addPropertyItem( $item ) );
56
	}
57
58
59
	public function testCreateAddressItem()
60
	{
61
		$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Address\Iface::class, $this->object->createAddressItem() );
62
	}
63
64
65
	public function testCreateListItem()
66
	{
67
		$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Lists\Iface::class, $this->object->createListItem() );
68
	}
69
70
71
	public function testCreatePropertyItem()
72
	{
73
		$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Property\Iface::class, $this->object->createPropertyItem() );
74
	}
75
76
77
	public function testDeleteAddressItem()
78
	{
79
		$item = \Aimeos\MShop::create( $this->context, 'customer/address' )->createItem();
80
81
		$this->setExpectedException( \Aimeos\MShop\Exception::class );
82
		$this->assertSame( $this->object, $this->object->deleteAddressItem( $item ) );
83
	}
84
85
86
	public function testDeleteListItem()
87
	{
88
		$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->createItem();
89
90
		$this->setExpectedException( \Aimeos\MShop\Exception::class );
91
		$this->assertSame( $this->object, $this->object->deleteListItem( 'customer', $listItem ) );
92
	}
93
94
95
	public function testDeletePropertyItem()
96
	{
97
		$item = \Aimeos\MShop::create( $this->context, 'customer/property' )->createItem();
98
99
		$this->setExpectedException( \Aimeos\MShop\Exception::class );
100
		$this->assertSame( $this->object, $this->object->deletePropertyItem( $item ) );
101
	}
102
103
104
	public function testFind()
105
	{
106
		$item = $this->object->uses( ['product'] )->find( 'UTC001' );
107
108
		$this->assertInstanceOf( \Aimeos\MShop\Customer\Item\Iface::class, $item );
109
		$this->assertEquals( 1, count( $item->getRefItems( 'product' ) ) );
110
	}
111
112
113
	public function testGet()
114
	{
115
		$this->context->setUserId( $this->object->find( 'UTC001' )->getId() );
116
		$item = $this->object->uses( ['product'] )->get();
117
118
		$this->assertInstanceOf( \Aimeos\MShop\Customer\Item\Iface::class, $item );
119
		$this->assertEquals( 1, count( $item->getRefItems( 'product' ) ) );
120
	}
121
122
123
	public function testStoreDelete()
124
	{
125
		$this->object->add( ['customer.code' => 'cntl-test'] );
126
127
		$this->assertSame( $this->object, $this->object->store() );
128
		$this->assertEquals( 'cntl-test', $this->object->get()->getCode() );
129
		$this->assertSame( $this->object, $this->object->delete() );
130
	}
131
132
133
	public function testUses()
134
	{
135
		$this->assertSame( $this->object, $this->object->uses( ['product'] ) );
136
	}
137
}
138