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\Contact; |
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->view = $this->context->view(); |
23
|
|
|
|
24
|
|
|
$this->object = new \Aimeos\Client\Html\Cms\Page\Contact\Standard( $this->context ); |
25
|
|
|
$this->object->setView( $this->view ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
protected function tearDown() : void |
30
|
|
|
{ |
31
|
|
|
unset( $this->object, $this->context, $this->view ); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
public function testBody() |
36
|
|
|
{ |
37
|
|
|
$this->object->setView( $this->object->data( $this->view ) ); |
38
|
|
|
$output = $this->object->body(); |
39
|
|
|
$this->assertEquals( '', $output ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function testInit() |
44
|
|
|
{ |
45
|
|
|
$this->context->config()->set( 'resource/email/from-email', 'rcpt@localhost' ); |
46
|
|
|
|
47
|
|
|
$view = $this->view; |
48
|
|
|
$param = [ |
49
|
|
|
'contact' => [ |
50
|
|
|
'name' => 'test', |
51
|
|
|
'email' => 'test@localhost', |
52
|
|
|
'message' => 'Test msg', |
53
|
|
|
'url' => '' |
54
|
|
|
] |
55
|
|
|
]; |
56
|
|
|
|
57
|
|
|
$helper = new \Aimeos\Base\View\Helper\Param\Standard( $view, $param ); |
58
|
|
|
$view->addHelper( 'param', $helper ); |
59
|
|
|
|
60
|
|
|
$this->object->init(); |
61
|
|
|
|
62
|
|
|
$this->assertEquals( 1, count( $view->get( 'infos', [] ) ) ); |
63
|
|
|
$this->assertEquals( 0, count( $view->get( 'errors', [] ) ) ); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
public function testInitHoneypot() |
68
|
|
|
{ |
69
|
|
|
$view = $this->view; |
70
|
|
|
$param = [ |
71
|
|
|
'contact' => [ |
72
|
|
|
'name' => 'test', |
73
|
|
|
'email' => 'test@localhost', |
74
|
|
|
'message' => 'Test msg', |
75
|
|
|
'url' => 'http://localhost' |
76
|
|
|
] |
77
|
|
|
]; |
78
|
|
|
|
79
|
|
|
$helper = new \Aimeos\Base\View\Helper\Param\Standard( $view, $param ); |
80
|
|
|
$view->addHelper( 'param', $helper ); |
81
|
|
|
|
82
|
|
|
$this->object->init(); |
83
|
|
|
|
84
|
|
|
$this->assertEquals( 0, count( $view->get( 'infos', [] ) ) ); |
85
|
|
|
$this->assertEquals( 0, count( $view->get( 'errors', [] ) ) ); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
public function testInitError() |
90
|
|
|
{ |
91
|
|
|
$this->context->config()->set( 'resource/email/from-email', '' ); |
92
|
|
|
|
93
|
|
|
$view = $this->view; |
94
|
|
|
$param = [ |
95
|
|
|
'contact' => [ |
96
|
|
|
'name' => 'test', |
97
|
|
|
'email' => 'test@localhost', |
98
|
|
|
'message' => 'Test msg', |
99
|
|
|
'url' => '' |
100
|
|
|
] |
101
|
|
|
]; |
102
|
|
|
|
103
|
|
|
$helper = new \Aimeos\Base\View\Helper\Param\Standard( $view, $param ); |
104
|
|
|
$view->addHelper( 'param', $helper ); |
105
|
|
|
|
106
|
|
|
$this->object->init(); |
107
|
|
|
|
108
|
|
|
$this->assertEquals( 1, count( $view->get( 'errors', [] ) ) ); |
109
|
|
|
$this->assertEquals( 0, count( $view->get( 'infos', [] ) ) ); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|