1
1
<?php
2
2
3
+ use Codeception \Configuration ;
4
+ use Codeception \Example ;
3
5
use Codeception \Module \UniversalFramework ;
4
6
use Codeception \Test \Unit ;
5
7
use Codeception \Util \Stub ;
@@ -17,9 +19,9 @@ class RestTest extends Unit
17
19
18
20
public function _setUp ()
19
21
{
20
- $ index = \ Codeception \ Configuration::dataDir () . '/rest/index.php ' ;
22
+ $ index = Configuration::dataDir () . '/rest/index.php ' ;
21
23
22
- $ container = \ Codeception \ Util \ Stub::make ('Codeception\Lib\ModuleContainer ' );
24
+ $ container = Stub::make ('Codeception\Lib\ModuleContainer ' );
23
25
$ connectionModule = new UniversalFramework ($ container , ['index ' => $ index ]);
24
26
$ connectionModule ->_initialize ();
25
27
$ this ->module = Stub::make ('\Codeception\Module\REST ' );
@@ -204,16 +206,30 @@ public function testApplicationJsonIncludesObjectSerialized()
204
206
$ this ->assertJson ($ request ->getContent ());
205
207
}
206
208
207
- public function testGetApplicationJsonNotIncludesJsonAsContent ()
209
+ /**
210
+ * @param string $method
211
+ *
212
+ * @dataProvider queryParamsAwareMethods
213
+ */
214
+ public function testGetApplicationJsonNotIncludesJsonAsContent ($ method )
208
215
{
216
+ $ method = 'send ' . $ method ;
209
217
$ this ->module ->haveHttpHeader ('Content-Type ' , 'application/json ' );
210
- $ this ->module ->sendGET ('/ ' , ['name ' => 'john ' ]);
218
+ $ this ->module ->$ method ('/ ' , ['name ' => 'john ' ]);
211
219
/** @var $request \Symfony\Component\BrowserKit\Request **/
212
220
$ request = $ this ->module ->client ->getRequest ();
213
221
$ this ->assertNull ($ request ->getContent ());
214
222
$ this ->assertContains ('john ' , $ request ->getParameters ());
215
223
}
216
224
225
+ public function queryParamsAwareMethods ()
226
+ {
227
+ return [
228
+ ['Get ' ],
229
+ ['Head ' ],
230
+ ];
231
+ }
232
+
217
233
public function testUrlIsFull ()
218
234
{
219
235
$ this ->module ->sendGET ('/api/v1/users ' );
@@ -529,7 +545,7 @@ public function testRestExecute($configUrl, $requestUrl, $expectedFullUrl)
529
545
530
546
$ config = ['url ' => $ configUrl ];
531
547
532
- /** @var \Codeception\Module\ REST */
548
+ /** @var REST */
533
549
$ module = Stub::make ('\Codeception\Module\REST ' );
534
550
$ module ->_setConfig ($ config );
535
551
$ module ->_inject ($ connectionModule );
0 commit comments