1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2012 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2018 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\Client\Html\Catalog\Lists\Promo; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
14
|
|
|
{ |
15
|
|
|
private $context; |
16
|
|
|
private $catItem; |
17
|
|
|
private $object; |
18
|
|
|
private $view; |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
protected function setUp() : void |
22
|
|
|
{ |
23
|
|
|
$this->context = \TestHelperHtml::getContext(); |
24
|
|
|
|
25
|
|
|
$catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::create( $this->context ); |
26
|
|
|
$search = $catalogManager->createSearch(); |
27
|
|
|
$search->setConditions( $search->compare( '==', 'catalog.code', 'cafe' ) ); |
28
|
|
|
$catItems = $catalogManager->searchItems( $search, array( 'product' ) ); |
29
|
|
|
|
30
|
|
|
if( ( $this->catItem = reset( $catItems ) ) === false ) { |
31
|
|
|
throw new \RuntimeException( 'No catalog item found' ); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
$this->view = \TestHelperHtml::getView(); |
35
|
|
|
$this->view->listParams = []; |
36
|
|
|
$this->view->listCurrentCatItem = $this->catItem; |
37
|
|
|
|
38
|
|
|
$this->object = new \Aimeos\Client\Html\Catalog\Lists\Promo\Standard( $this->context ); |
39
|
|
|
$this->object->setView( $this->view ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
protected function tearDown() : void |
44
|
|
|
{ |
45
|
|
|
unset( $this->object ); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
public function testGetHeader() |
50
|
|
|
{ |
51
|
|
|
$tags = []; |
52
|
|
|
$expire = null; |
53
|
|
|
|
54
|
|
|
$this->object->setView( $this->object->addData( $this->object->getView(), $tags, $expire ) ); |
55
|
|
|
$output = $this->object->getHeader(); |
56
|
|
|
|
57
|
|
|
$this->assertStringContainsString( '<script type="text/javascript"', $output ); |
58
|
|
|
$this->assertEquals( '2098-01-01 00:00:00', $expire ); |
59
|
|
|
$this->assertEquals( 4, count( $tags ) ); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
public function testGetBody() |
64
|
|
|
{ |
65
|
|
|
$tags = []; |
66
|
|
|
$expire = null; |
67
|
|
|
|
68
|
|
|
$this->object->setView( $this->object->addData( $this->object->getView(), $tags, $expire ) ); |
69
|
|
|
$output = $this->object->getBody( 1, $tags, $expire ); |
70
|
|
|
|
71
|
|
|
$this->assertStringContainsString( '<section class="catalog-list-promo">', $output ); |
72
|
|
|
$this->assertRegExp( '/.*Expresso.*Cappuccino.*/smu', $output ); |
73
|
|
|
$this->assertEquals( '2098-01-01 00:00:00', $expire ); |
74
|
|
|
$this->assertEquals( 4, count( $tags ) ); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
public function testGetBodyDefaultCatid() |
79
|
|
|
{ |
80
|
|
|
unset( $this->view->listCurrentCatItem ); |
81
|
|
|
$this->object->setView( $this->view ); |
82
|
|
|
$this->context->getConfig()->set( 'client/html/catalog/lists/catid-default', $this->catItem->getId() ); |
83
|
|
|
|
84
|
|
|
$this->object->setView( $this->object->addData( $this->object->getView() ) ); |
85
|
|
|
$output = $this->object->getBody(); |
86
|
|
|
|
87
|
|
|
$this->assertStringContainsString( '<section class="catalog-list-promo">', $output ); |
88
|
|
|
$this->assertRegExp( '/.*Expresso.*Cappuccino.*/smu', $output ); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
public function testGetSubClient() |
93
|
|
|
{ |
94
|
|
|
$this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
95
|
|
|
$this->object->getSubClient( 'invalid', 'invalid' ); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|