1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2013 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\Client\Html\Catalog\Suggest; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
14
|
|
|
{ |
15
|
|
|
private $object; |
16
|
|
|
private $context; |
17
|
|
|
private $view; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
protected function setUp() : void |
21
|
|
|
{ |
22
|
|
|
$this->view = \TestHelperHtml::view(); |
23
|
|
|
$this->context = \TestHelperHtml::context(); |
24
|
|
|
|
25
|
|
|
$this->object = new \Aimeos\Client\Html\Catalog\Suggest\Standard( $this->context ); |
26
|
|
|
$this->object->setView( $this->view ); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
protected function tearDown() : void |
31
|
|
|
{ |
32
|
|
|
unset( $this->object, $this->context, $this->view ); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
public function testHeader() |
37
|
|
|
{ |
38
|
|
|
$output = $this->object->header(); |
39
|
|
|
$this->assertNotNull( $output ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function testBody() |
44
|
|
|
{ |
45
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, array( 'f_search' => 'Unterpro' ) ); |
46
|
|
|
$this->view->addHelper( 'param', $helper ); |
47
|
|
|
|
48
|
|
|
$output = $this->object->body(); |
49
|
|
|
$suggestItems = $this->view->suggestItems; |
50
|
|
|
|
51
|
|
|
$this->assertRegExp( '#\[\{"label":"Unterpro.*","html":".*Unterpro.*"\}\]#smU', $output ); |
52
|
|
|
$this->assertNotEquals( [], $suggestItems ); |
53
|
|
|
|
54
|
|
|
foreach( $suggestItems as $item ) { |
55
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $item ); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
public function testBodyUseCodes() |
61
|
|
|
{ |
62
|
|
|
$this->context->config()->set( 'client/html/catalog/suggest/usecode', true ); |
63
|
|
|
|
64
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, array( 'f_search' => 'CNC' ) ); |
65
|
|
|
$this->view->addHelper( 'param', $helper ); |
66
|
|
|
|
67
|
|
|
$output = $this->object->body(); |
68
|
|
|
$suggestItems = $this->view->suggestItems; |
69
|
|
|
|
70
|
|
|
$this->assertRegExp( '#\[.*\{"label":"Cafe.*","html":".*Cafe.*"\}.*\]#smU', $output ); |
71
|
|
|
$this->assertNotEquals( [], $suggestItems ); |
72
|
|
|
|
73
|
|
|
foreach( $suggestItems as $item ) { |
74
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $item ); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|