StandardTest   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 14
eloc 33
dl 0
loc 103
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A testGet() 0 6 1
A setUp() 0 4 1
A testRoot() 0 5 1
A testGetTree() 0 10 2
A testParse() 0 4 1
A testCompare() 0 4 1
A testSort() 0 3 1
A testFind() 0 5 1
A testGetPath() 0 9 2
A testSlice() 0 3 1
A testSearch() 0 7 1
A tearDown() 0 3 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021-2025
6
 */
7
8
9
namespace Aimeos\Controller\Frontend\Site;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $context;
15
	private $object;
16
17
18
	protected function setUp() : void
19
	{
20
		$this->context = \TestHelper::context();
21
		$this->object = new \Aimeos\Controller\Frontend\Site\Standard( $this->context );
22
	}
23
24
25
	protected function tearDown() : void
26
	{
27
		unset( $this->object, $this->context );
28
	}
29
30
31
	public function testCompare()
32
	{
33
		$list = $this->object->compare( '==', 'locale.site.status', 1 )->search();
34
		$this->assertGreaterThanOrEqual( 1, count( $list ) );
35
	}
36
37
38
	public function testFind()
39
	{
40
		$item = $this->object->find( 'unittest' );
41
42
		$this->assertInstanceOf( \Aimeos\MShop\Locale\Item\Site\Iface::class, $item );
43
	}
44
45
46
	public function testGet()
47
	{
48
		$item = \Aimeos\MShop::create( $this->context, 'locale/site' )->find( 'unittest' );
49
		$item = $this->object->get( $item->getId() );
50
51
		$this->assertInstanceOf( \Aimeos\MShop\Locale\Item\Site\Iface::class, $item );
52
	}
53
54
55
	public function testGetPath()
56
	{
57
		$item = \Aimeos\MShop::create( $this->context, 'locale/site' )->find( 'unittest', [] );
58
		$items = $this->object->getPath( $item->getId() );
59
60
		$this->assertGreaterThanOrEqual( 1, count( $items ) );
61
62
		foreach( $items as $item ) {
63
			$this->assertInstanceOf( \Aimeos\MShop\Locale\Item\Site\Iface::class, $item );
64
		}
65
	}
66
67
68
	public function testGetTree()
69
	{
70
		$item = \Aimeos\MShop::create( $this->context, 'locale/site' )->find( 'unittest' );
71
		$tree = $this->object->root( $item->getId() )->getTree();
72
73
		foreach( $tree->toList() as $item ) {
74
			$this->assertInstanceOf( \Aimeos\MShop\Locale\Item\Site\Iface::class, $item );
75
		}
76
77
		$this->assertGreaterThanOrEqual( 1, count( $tree->toList() ) );
78
	}
79
80
81
	public function testParse()
82
	{
83
		$cond = ['>' => ['locale.site.status' => 0]];
84
		$this->assertGreaterThanOrEqual( 1, count( $this->object->parse( $cond )->search() ) );
85
	}
86
87
88
	public function testRoot()
89
	{
90
		$item = \Aimeos\MShop::create( $this->context, 'locale/site' )->find( 'unittest' );
91
92
		$this->assertGreaterThanOrEqual( 1, count( $this->object->root( $item->getId() )->getPath( $item->getId() ) ) );
93
	}
94
95
96
	public function testSearch()
97
	{
98
		$total = 0;
99
		$items = $this->object->compare( '==', 'locale.site.code', 'unittest' )->search( $total );
100
101
		$this->assertCount( 1, $items );
102
		$this->assertEquals( 1, $total );
103
	}
104
105
106
	public function testSlice()
107
	{
108
		$this->assertEquals( 1, count( $this->object->slice( 0, 1 )->search() ) );
109
	}
110
111
112
	public function testSort()
113
	{
114
		$this->assertGreaterThanOrEqual( 1, count( $this->object->sort( 'locale.site.label' )->search() ) );
115
	}
116
}
117