2017-05-31 05:40:22 +05:30
|
|
|
<?php
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\unit\request;
|
2017-05-31 05:40:22 +05:30
|
|
|
|
|
|
|
use api\request\RequestParser;
|
2019-02-21 01:28:52 +05:30
|
|
|
use api\tests\unit\TestCase;
|
2017-05-31 05:40:22 +05:30
|
|
|
|
|
|
|
class RequestParserTest extends TestCase {
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testParse(): void {
|
2017-05-31 05:40:22 +05:30
|
|
|
$parser = new RequestParser();
|
|
|
|
$_POST = ['from' => 'post'];
|
2019-02-26 04:56:02 +05:30
|
|
|
$this->assertSame(['from' => 'post'], $parser->parse('from=post', ''));
|
|
|
|
$this->assertSame(['from' => 'post'], $parser->parse('', ''));
|
2017-05-31 05:40:22 +05:30
|
|
|
$_POST = [];
|
2019-02-26 04:56:02 +05:30
|
|
|
$this->assertSame(['from' => 'json'], $parser->parse('{"from":"json"}', ''));
|
|
|
|
$this->assertSame(['from' => 'body'], $parser->parse('from=body', ''));
|
|
|
|
$this->assertSame(['onlykey' => ''], $parser->parse('onlykey', ''));
|
2017-05-31 05:40:22 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|