Passed
Push — master ( 5fb2be...b6cfe0 )
by Aimeos
01:40
created

StandardTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
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
		$this->assertInstanceOf( \Aimeos\MShop\Customer\Item\Iface::class, $this->object->find( 'UTC001' ) );
107
	}
108
109
110
	public function testGet()
111
	{
112
		$this->assertInstanceOf( \Aimeos\MShop\Customer\Item\Iface::class, $this->object->get() );
113
	}
114
115
116
	public function testStoreDelete()
117
	{
118
		$this->object->add( ['customer.code' => 'cntl-test'] );
119
120
		$this->assertSame( $this->object, $this->object->store() );
121
122
		$this->assertEquals( 'cntl-test', $this->object->get()->getCode() );
123
124
		$this->assertSame( $this->object, $this->object->delete() );
125
	}
126
127
128
	public function testUse()
129
	{
130
		$this->context->setUserId( \Aimeos\MShop::create( $this->context, 'customer' )->findItem( 'UTC001' )->getId() );
131
132
		$this->assertSame( $this->object, $this->object->use( ['text'] ) );
133
		$this->assertEquals( 1, count( $this->object->get()->getListItems( 'text' ) ) );
134
	}
135
}
136