Теперь при передаче запроса как json, закодированный в теле, он автоматически парсится

This commit is contained in:
ErickSkrauch
2017-05-31 03:10:22 +03:00
parent 30fedc51ef
commit 400f0e87b9
14 changed files with 94 additions and 57 deletions

View File

@ -0,0 +1,20 @@
<?php
namespace tests\codeception\api\unit\request;
use api\request\RequestParser;
use tests\codeception\api\unit\TestCase;
class RequestParserTest extends TestCase {
public function testParse() {
$parser = new RequestParser();
$_POST = ['from' => 'post'];
$this->assertEquals(['from' => 'post'], $parser->parse('from=post', ''));
$this->assertEquals(['from' => 'post'], $parser->parse('', ''));
$_POST = [];
$this->assertEquals(['from' => 'json'], $parser->parse('{"from":"json"}', ''));
$this->assertEquals(['from' => 'body'], $parser->parse('from=body', ''));
$this->assertEquals(['onlykey' => ''], $parser->parse('onlykey', ''));
}
}