public function testArrayRequest() { $response = $this->sendRequest(self::createClient(), '/test/', ['jsonrpc' => JsonRpcBundle::VERSION, 'method' => 'array', 'id' => 'test', 'params' => ['payload' => 'my-payload']]); self::assertTrue($response->isSuccessful()); $content = json_decode($response->getContent()); self::assertInstanceOf(\stdClass::class, $content); $jsonResponse = new SyncResponse($content); self::assertTrue($jsonResponse->isSuccessful(), json_encode($content)); self::assertTrue(isset($jsonResponse->getBody()[0]->{'sample_payload'})); self::assertEquals('my-payload', $jsonResponse->getBody()[0]->{'sample_payload'}); }
public function testNestedContext() { $response = $this->sendRequest(self::createClient(), '/test/private/', ['jsonrpc' => JsonRpcBundle::VERSION, 'method' => 'entity/nested', 'id' => 'test', 'params' => ['payload' => 'my-payload']]); self::assertTrue($response->isSuccessful()); $content = json_decode($response->getContent()); self::assertInstanceOf(\stdClass::class, $content); $jsonResponse = new SyncResponse($content); self::assertTrue($jsonResponse->isSuccessful()); self::assertTrue(isset($jsonResponse->getBody()->{'sample_payload'})); self::assertEquals('my-payload', $jsonResponse->getBody()->{'sample_payload'}); self::assertTrue(isset($jsonResponse->getBody()->{'private_payload'}), json_encode($content, JSON_PRETTY_PRINT)); self::assertEquals('secret-payload', $jsonResponse->getBody()->{'private_payload'}); }