@@ -137,21 +137,19 @@ public function testExecuteEmptyPost(): void
137
137
138
138
/**
139
139
* Test exceute post validation
140
+ *
140
141
* @param array $postData
141
- * @param bool $exceptionExpected
142
142
* @dataProvider postDataProvider
143
143
*/
144
- public function testExecutePostValidation ($ postData, $ exceptionExpected ): void
144
+ public function testExecutePostValidation ($ postData ): void
145
145
{
146
146
$ this ->stubRequestPostData ($ postData );
147
+ $ this ->messageManagerMock ->expects ($ this ->once ())
148
+ ->method ('addErrorMessage ' );
149
+ $ this ->dataPersistorMock ->expects ($ this ->once ())
150
+ ->method ('set ' )
151
+ ->with ('contact_us ' , $ postData );
147
152
148
- if ($ exceptionExpected ) {
149
- $ this ->messageManagerMock ->expects ($ this ->once ())
150
- ->method ('addErrorMessage ' );
151
- $ this ->dataPersistorMock ->expects ($ this ->once ())
152
- ->method ('set ' )
153
- ->with ('contact_us ' , $ postData );
154
- }
155
153
156
154
$ this ->controller ->execute ();
157
155
}
@@ -162,12 +160,12 @@ public function testExecutePostValidation($postData, $exceptionExpected): void
162
160
public function postDataProvider (): array
163
161
{
164
162
return [
165
- [['name ' => null , 'comment ' => null , 'email ' => '' , 'hideit ' => 'no ' ], true ],
166
- [['name ' => 'test ' , 'comment ' => '' , 'email ' => '' , 'hideit ' => 'no ' ], true ],
167
- [['name ' => '' , 'comment ' => 'test ' , 'email ' => '' , 'hideit ' => 'no ' ], true ],
168
- [['name ' => '' , 'comment ' => '' , 'email ' => 'test ' , 'hideit ' => 'no ' ], true ],
169
- [['name ' => '' , 'comment ' => '' , 'email ' => '' , 'hideit ' => 'no ' ], true ],
170
- [['name ' => 'Name ' , 'comment ' => 'Name ' , 'email ' => 'invalidmail ' , 'hideit ' => 'no ' ], true ],
163
+ [['name ' => null , 'comment ' => null , 'email ' => '' , 'hideit ' => 'no ' ]],
164
+ [['name ' => 'test ' , 'comment ' => '' , 'email ' => '' , 'hideit ' => 'no ' ]],
165
+ [['name ' => '' , 'comment ' => 'test ' , 'email ' => '' , 'hideit ' => 'no ' ]],
166
+ [['name ' => '' , 'comment ' => '' , 'email ' => 'test ' , 'hideit ' => 'no ' ]],
167
+ [['name ' => '' , 'comment ' => '' , 'email ' => '' , 'hideit ' => 'no ' ]],
168
+ [['name ' => 'Name ' , 'comment ' => 'Name ' , 'email ' => 'invalidmail ' , 'hideit ' => 'no ' ]],
171
169
];
172
170
}
173
171
@@ -206,8 +204,8 @@ private function stubRequestPostData($post): void
206
204
$ this ->requestStub ->method ('getPostValue ' )->willReturn ($ post );
207
205
$ this ->requestStub ->method ('getParams ' )->willReturn ($ post );
208
206
$ this ->requestStub ->method ('getParam ' )->willReturnCallback (
209
- function ($ key ) use ($ post ) {
210
- return $ post [$ key ] ?? '' ;
207
+ function ($ key, $ defaultValue ) use ($ post ) {
208
+ return $ post [$ key ] ?? $ defaultValue ;
211
209
}
212
210
);
213
211
}
0 commit comments