1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Tests\View\Helper; |
3
|
|
|
|
4
|
|
|
use Redaxscript\Tests\TestCaseAbstract; |
5
|
|
|
use Redaxscript\View\Helper\Messenger; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* MessengerTest |
9
|
|
|
* |
10
|
|
|
* @since 3.0.0 |
11
|
|
|
* |
12
|
|
|
* @package Redaxscript |
13
|
|
|
* @category Tests |
14
|
|
|
* @author Henry Ruhs |
15
|
|
|
* |
16
|
|
|
* @covers Redaxscript\View\Helper\Messenger |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
class MessengerTest extends TestCaseAbstract |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* testSuccess |
23
|
|
|
* |
24
|
|
|
* @since 3.0.0 |
25
|
|
|
* |
26
|
|
|
* @param array $successArray |
27
|
|
|
* @param array $actionArray |
28
|
|
|
* @param string $expect |
29
|
|
|
* |
30
|
|
|
* @dataProvider providerAutoloader |
31
|
|
|
*/ |
32
|
|
|
|
33
|
|
|
public function testSuccess(array $successArray = [], array $actionArray = [], string $expect = null) : void |
34
|
|
|
{ |
35
|
|
|
/* setup */ |
36
|
|
|
|
37
|
|
|
$messenger = new Messenger($this->_registry); |
38
|
|
|
$messenger->setRoute($actionArray['text'], $actionArray['route']); |
39
|
|
|
|
40
|
|
|
/* actual */ |
41
|
|
|
|
42
|
|
|
$actual = $messenger->success($successArray['message'], $successArray['title']); |
43
|
|
|
|
44
|
|
|
/* compare */ |
45
|
|
|
|
46
|
|
|
$this->assertEquals($expect, $actual); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* testInfo |
51
|
|
|
* |
52
|
|
|
* @since 3.0.0 |
53
|
|
|
* |
54
|
|
|
* @param array $infoArray |
55
|
|
|
* @param array $actionArray |
56
|
|
|
* @param string $expect |
57
|
|
|
* |
58
|
|
|
* @dataProvider providerAutoloader |
59
|
|
|
*/ |
60
|
|
|
|
61
|
|
|
public function testInfo(array $infoArray = [], array $actionArray = [], string $expect = null) : void |
62
|
|
|
{ |
63
|
|
|
/* setup */ |
64
|
|
|
|
65
|
|
|
$messenger = new Messenger($this->_registry); |
66
|
|
|
$messenger->setRoute($actionArray['text'], $actionArray['route']); |
67
|
|
|
|
68
|
|
|
/* actual */ |
69
|
|
|
|
70
|
|
|
$actual = $messenger->info($infoArray['message'], $infoArray['title']); |
71
|
|
|
|
72
|
|
|
/* compare */ |
73
|
|
|
|
74
|
|
|
$this->assertEquals($expect, $actual); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* testWarning |
79
|
|
|
* |
80
|
|
|
* @since 3.0.0 |
81
|
|
|
* |
82
|
|
|
* @param array $warningArray |
83
|
|
|
* @param array $actionArray |
84
|
|
|
* @param string $expect |
85
|
|
|
* |
86
|
|
|
* @dataProvider providerAutoloader |
87
|
|
|
*/ |
88
|
|
|
|
89
|
|
|
public function testWarning(array $warningArray = [], array $actionArray = [], string $expect = null) : void |
90
|
|
|
{ |
91
|
|
|
/* setup */ |
92
|
|
|
|
93
|
|
|
$messenger = new Messenger($this->_registry); |
94
|
|
|
$messenger->setRoute($actionArray['text'], $actionArray['route']); |
95
|
|
|
|
96
|
|
|
/* actual */ |
97
|
|
|
|
98
|
|
|
$actual = $messenger->warning($warningArray['message'], $warningArray['title']); |
99
|
|
|
|
100
|
|
|
/* compare */ |
101
|
|
|
|
102
|
|
|
$this->assertEquals($expect, $actual); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* testError |
107
|
|
|
* |
108
|
|
|
* @since 3.0.0 |
109
|
|
|
* |
110
|
|
|
* @param array $errorArray |
111
|
|
|
* @param array $actionArray |
112
|
|
|
* @param string $expect |
113
|
|
|
* |
114
|
|
|
* @dataProvider providerAutoloader |
115
|
|
|
*/ |
116
|
|
|
|
117
|
|
|
public function testError(array $errorArray = [], array $actionArray = [], string $expect = null) : void |
118
|
|
|
{ |
119
|
|
|
/* setup */ |
120
|
|
|
|
121
|
|
|
$messenger = new Messenger($this->_registry); |
122
|
|
|
$messenger->setRoute($actionArray['text'], $actionArray['route']); |
123
|
|
|
|
124
|
|
|
/* actual */ |
125
|
|
|
|
126
|
|
|
$actual = $messenger->error($errorArray['message'], $errorArray['title']); |
127
|
|
|
|
128
|
|
|
/* compare */ |
129
|
|
|
|
130
|
|
|
$this->assertEquals($expect, $actual); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* testRender |
135
|
|
|
* |
136
|
|
|
* @since 3.0.0 |
137
|
|
|
* |
138
|
|
|
* @param array $renderArray |
139
|
|
|
* @param array $actionArray |
140
|
|
|
* @param string $expect |
141
|
|
|
* |
142
|
|
|
* @dataProvider providerAutoloader |
143
|
|
|
*/ |
144
|
|
|
|
145
|
|
|
public function testRender(array $renderArray = [], array $actionArray = [], string $expect = null) : void |
146
|
|
|
{ |
147
|
|
|
/* setup */ |
148
|
|
|
|
149
|
|
|
$messenger = new Messenger($this->_registry); |
150
|
|
|
$messenger->init(); |
151
|
|
|
$messenger |
152
|
|
|
->setUrl($actionArray['text'], $actionArray['url']) |
153
|
|
|
->doRedirect($actionArray['timeout']); |
154
|
|
|
|
155
|
|
|
/* actual */ |
156
|
|
|
|
157
|
|
|
$actual = $messenger->render($renderArray['type'], $renderArray['message'], $renderArray['title']); |
158
|
|
|
|
159
|
|
|
/* compare */ |
160
|
|
|
|
161
|
|
|
$this->assertEquals($expect, $actual); |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
|