|
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\Client\Html\Cms\Page; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
private $object; |
|
15
|
|
|
private $context; |
|
16
|
|
|
private $view; |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
protected function setUp() : void |
|
20
|
|
|
{ |
|
21
|
|
|
$this->context = \TestHelper::context(); |
|
22
|
|
|
$this->context->locale()->setLanguageId( 'en' ); |
|
23
|
|
|
$this->view = $this->context->view(); |
|
24
|
|
|
|
|
25
|
|
|
$this->object = new \Aimeos\Client\Html\Cms\Page\Standard( $this->context ); |
|
26
|
|
|
$this->object->setView( $this->context->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
|
|
|
$tags = []; |
|
39
|
|
|
$expire = null; |
|
40
|
|
|
$view = $this->view; |
|
41
|
|
|
|
|
42
|
|
|
$helper = new \Aimeos\Base\View\Helper\Param\Standard( $view, ['path' => 'contact'] ); |
|
43
|
|
|
$view->addHelper( 'param', $helper ); |
|
44
|
|
|
|
|
45
|
|
|
$this->object->setView( $this->object->data( $view, $tags, $expire ) ); |
|
46
|
|
|
$output = $this->object->header(); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertStringContainsString( '<title>Contact page | Aimeos</title>', $output ); |
|
49
|
|
|
$this->assertEquals( null, $expire ); |
|
50
|
|
|
$this->assertEquals( 1, count( $tags ) ); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
public function testBody() |
|
55
|
|
|
{ |
|
56
|
|
|
$tags = []; |
|
57
|
|
|
$expire = null; |
|
58
|
|
|
$view = $this->view; |
|
59
|
|
|
|
|
60
|
|
|
$helper = new \Aimeos\Base\View\Helper\Param\Standard( $view, ['path' => 'contact'] ); |
|
61
|
|
|
$view->addHelper( 'param', $helper ); |
|
62
|
|
|
|
|
63
|
|
|
$this->object->setView( $this->object->data( $view, $tags, $expire ) ); |
|
64
|
|
|
$output = $this->object->body(); |
|
65
|
|
|
|
|
66
|
|
|
$this->assertStringStartsWith( '<section class="aimeos cms-page', $output ); |
|
67
|
|
|
$this->assertStringContainsString( '<h1>Hello!</h1>', $output ); |
|
68
|
|
|
|
|
69
|
|
|
$this->assertEquals( null, $expire ); |
|
70
|
|
|
$this->assertEquals( 1, count( $tags ) ); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
public function testGetSubClientInvalid() |
|
75
|
|
|
{ |
|
76
|
|
|
$this->expectException( \LogicException::class ); |
|
77
|
|
|
$this->object->getSubClient( 'unknown', 'unknown' ); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
public function testGetSubClientInvalidName() |
|
82
|
|
|
{ |
|
83
|
|
|
$this->expectException( \LogicException::class ); |
|
84
|
|
|
$this->object->getSubClient( '$$$', '$$$' ); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
public function testInit() |
|
89
|
|
|
{ |
|
90
|
|
|
$this->object->init(); |
|
91
|
|
|
|
|
92
|
|
|
$this->assertEmpty( $this->view->get( 'errors' ) ); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|