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.getByDate", "params": {"date": "%s"}, "id": 1}]', (new DateTime())->format('Y-m-d') ), 'seeResponseContainsJson' => [ 'jsonrpc' => '2.0', 'id' => 1, ], 'seeResponseMatchesJsonType' => [ 'jsonrpc' => 'string', 'id' => 'integer', ], ], [ 'body' => sprintf( '[{"jsonrpc": "2.0", "method": "weather.getByDate", "params": {"date": "%s"}, "id": 1}]', '9999-01-01' ), 'seeResponseContainsJson' => [ 'jsonrpc' => '2.0', 'id' => 1, 'result' => [], ], 'seeResponseMatchesJsonType' => [ 'jsonrpc' => 'string', 'id' => 'integer', 'result' => 'array', ], ], [ 'body' => sprintf( '[{"jsonrpc": "2.0", "method": "weather.getByDate", "params": {"date": "%s"}, "id": 1}]', '01-01-9999' ), 'seeResponseContainsJson' => [ 'jsonrpc' => '2.0', 'id' => 1, ], 'seeResponseMatchesJsonType' => [ 'jsonrpc' => 'string', 'id' => 'integer', 'error' => 'array', ], ], [ 'body' => '[{"jsonrpc": "2.0", "method": "weather.getByDate", "params": [], "id": 1}]', 'seeResponseContainsJson' => [ 'jsonrpc' => '2.0', 'id' => 1, ], 'seeResponseMatchesJsonType' => [ 'jsonrpc' => 'string', 'id' => 'integer', 'error' => 'array', ], ], ]; } }