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
|
|
|
|