Implementation a microservice architecture with JSON-RPC 2.0 communication between backend and frontend https://www.jsonrpc.org/specification
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

74 lines
2.2 KiB

<?php
declare(strict_types=1);
namespace App\Tests\api\Method\Weather;
use App\Tests\ApiTester;
use Codeception\Example;
class GetHistoryMethodCest
{
private ApiTester $tester;
public function _before(ApiTester $tester): void
{
$this->tester = $tester;
}
/**
* @dataProvider dataApply
*/
public function testApply(Example $example): void
{
$this->tester->sendPost('/json-rpc', $example['body']);
$this->tester->seeResponseIsJson();
$this->tester->seeResponseContainsJson($example['seeResponseContainsJson']);
$this->tester->seeResponseMatchesJsonType($example['seeResponseMatchesJsonType']);
}
protected function dataApply(): array
{
return [
[
'body' => sprintf(
'[{"jsonrpc": "2.0", "method": "weather.getHistory", "params": {"lastDays": %d}, "id": 1}]',
random_int(1, 1000)
),
'seeResponseContainsJson' => ['jsonrpc' => '2.0', 'id' => 1],
'seeResponseMatchesJsonType' => [
'jsonrpc' => 'string',
'id' => 'integer',
'result' => 'array',
],
],
[
'body' => sprintf(
'[{"jsonrpc": "2.0", "method": "weather.getHistory", "params": {"lastDays": %d}, "id": 1}]',
random_int(-1000, 0)
),
'seeResponseContainsJson' => [
'jsonrpc' => '2.0',
'id' => 1,
],
'seeResponseMatchesJsonType' => [
'jsonrpc' => 'string',
'id' => 'integer',
'error' => 'array',
],
],
[
'body' => '[{"jsonrpc": "2.0", "method": "weather.getHistory", "params": [], "id": 1}]',
'seeResponseContainsJson' => [
'jsonrpc' => '2.0',
'id' => 1,
],
'seeResponseMatchesJsonType' => [
'jsonrpc' => 'string',
'id' => 'integer',
'error' => 'array',
],
],
];
}
}