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', ], ], ]; } }