Completed
Push — master ( 5e44e2...ae0969 )
by Aimeos
07:40
created

StandardTest::testCreateFilter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
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\Locale;
10
11
12
class StandardTest extends \PHPUnit_Framework_TestCase
13
{
14
	private $object;
15
16
17
	protected function setUp()
18
	{
19
		$this->object = new \Aimeos\Controller\Frontend\Locale\Standard( \TestHelperFrontend::getContext() );
20
	}
21
22
23
	protected function tearDown()
24
	{
25
		unset( $this->object );
26
	}
27
28
29
	public function testCreateFilter()
30
	{
31
		$filter = $this->object->createFilter();
32
33
		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
34
		$this->assertEquals( 1, count( $filter->getSortations() ) );
35
		$this->assertEquals( 0, $filter->getSliceStart() );
36
		$this->assertEquals( 100, $filter->getSliceSize() );
37
	}
38
39
40
	public function testGetItem()
41
	{
42
		$localeManager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'locale' );
43
		$search = $localeManager->createSearch();
44
		$search->setSortations( [$search->sort( '+', 'locale.position' )] );
45
		$search->setSlice( 0, 1 );
46
		$localeItems = $localeManager->searchItems( $search );
47
48
		if( ( $localeItem = reset( $localeItems ) ) === false ) {
49
			throw new \Exception( 'No locale item found' );
50
		}
51
52
53
		$result = $this->object->getItem( $localeItem->getId() );
54
55
		$this->assertInstanceOf( '\Aimeos\MShop\Locale\Item\Iface', $result );
56
	}
57
58
59
	public function testSearchItems()
60
	{
61
		$total = 0;
62
		$filter = $this->object->createFilter();
63
		$results = $this->object->searchItems( $filter, [], $total );
64
65
		$this->assertEquals( 1, $total );
66
		$this->assertEquals( 1, count( $results ) );
67
	}
68
}
69