|
@@ 14-23 (lines=10) @@
|
| 11 |
|
class JsonRequestParserTest extends TestCase |
| 12 |
|
{ |
| 13 |
|
|
| 14 |
|
public function testGetQuery() |
| 15 |
|
{ |
| 16 |
|
$url = new UrlScript('https://portiny.org'); |
| 17 |
|
$httpRequest = new Request($url, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, function () { |
| 18 |
|
return '{"query": "some query", "variables": {}}'; |
| 19 |
|
}); |
| 20 |
|
$jsonRequestParser = new JsonRequestParser($httpRequest); |
| 21 |
|
|
| 22 |
|
$this->assertSame('some query', $jsonRequestParser->getQuery()); |
| 23 |
|
} |
| 24 |
|
|
| 25 |
|
|
| 26 |
|
public function testGetVariables() |
|
@@ 26-35 (lines=10) @@
|
| 23 |
|
} |
| 24 |
|
|
| 25 |
|
|
| 26 |
|
public function testGetVariables() |
| 27 |
|
{ |
| 28 |
|
$url = new UrlScript('https://portiny.org'); |
| 29 |
|
$httpRequest = new Request($url, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, function () { |
| 30 |
|
return '{"query": "some query", "variables": {"key": "value"}}'; |
| 31 |
|
}); |
| 32 |
|
$jsonRequestParser = new JsonRequestParser($httpRequest); |
| 33 |
|
|
| 34 |
|
$this->assertSame(['key' => 'value'], $jsonRequestParser->getVariables()); |
| 35 |
|
} |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
public function testEmptyData() |
|
@@ 38-48 (lines=11) @@
|
| 35 |
|
} |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
public function testEmptyData() |
| 39 |
|
{ |
| 40 |
|
$url = new UrlScript('https://portiny.org'); |
| 41 |
|
$httpRequest = new Request($url, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, function () { |
| 42 |
|
return ''; |
| 43 |
|
}); |
| 44 |
|
$jsonRequestParser = new JsonRequestParser($httpRequest); |
| 45 |
|
|
| 46 |
|
$this->assertSame('', $jsonRequestParser->getQuery()); |
| 47 |
|
$this->assertSame([], $jsonRequestParser->getVariables()); |
| 48 |
|
} |
| 49 |
|
|
| 50 |
|
} |
| 51 |
|
|