| @@ 40-79 (lines=40) @@ | ||
| 37 | ); |
|
| 38 | } |
|
| 39 | ||
| 40 | public function testPrivateEntityFields() |
|
| 41 | { |
|
| 42 | $response = $this->sendRequest( |
|
| 43 | self::createClient(), |
|
| 44 | '/test/private/', |
|
| 45 | [ |
|
| 46 | 'jsonrpc' => BankiruJsonRpcServerBundle::JSONRPC_VERSION, |
|
| 47 | 'method' => 'entity/private', |
|
| 48 | 'id' => 'test', |
|
| 49 | 'params' => [ |
|
| 50 | 'payload' => 'my-payload', |
|
| 51 | ], |
|
| 52 | ] |
|
| 53 | ); |
|
| 54 | ||
| 55 | self::assertTrue($response->isSuccessful()); |
|
| 56 | $content = json_decode($response->getContent()); |
|
| 57 | self::assertInstanceOf(\stdClass::class, $content); |
|
| 58 | ||
| 59 | $jsonResponse = new SyncResponse($content); |
|
| 60 | self::assertTrue($jsonResponse->isSuccessful(), json_encode($content, JSON_PRETTY_PRINT)); |
|
| 61 | self::assertTrue(isset($jsonResponse->getBody()->{'sample_payload'}), json_encode($content, JSON_PRETTY_PRINT)); |
|
| 62 | self::assertEquals( |
|
| 63 | 'my-payload', |
|
| 64 | $jsonResponse->getBody()->{'sample_payload'}, |
|
| 65 | json_encode($content, JSON_PRETTY_PRINT) |
|
| 66 | ); |
|
| 67 | ||
| 68 | if (static::$kernel->getContainer()->has('jms_serializer')) { |
|
| 69 | self::assertTrue( |
|
| 70 | isset($jsonResponse->getBody()->{'private_payload'}), |
|
| 71 | json_encode($content, JSON_PRETTY_PRINT) |
|
| 72 | ); |
|
| 73 | self::assertEquals( |
|
| 74 | 'secret-payload', |
|
| 75 | $jsonResponse->getBody()->{'private_payload'}, |
|
| 76 | json_encode($content, JSON_PRETTY_PRINT) |
|
| 77 | ); |
|
| 78 | } |
|
| 79 | } |
|
| 80 | ||
| 81 | public function testNestedContext() |
|
| 82 | { |
|
| @@ 81-120 (lines=40) @@ | ||
| 78 | } |
|
| 79 | } |
|
| 80 | ||
| 81 | public function testNestedContext() |
|
| 82 | { |
|
| 83 | $response = $this->sendRequest( |
|
| 84 | self::createClient(), |
|
| 85 | '/test/private/', |
|
| 86 | [ |
|
| 87 | 'jsonrpc' => BankiruJsonRpcServerBundle::JSONRPC_VERSION, |
|
| 88 | 'method' => 'entity/nested', |
|
| 89 | 'id' => 'test', |
|
| 90 | 'params' => [ |
|
| 91 | 'payload' => 'my-payload', |
|
| 92 | ], |
|
| 93 | ] |
|
| 94 | ); |
|
| 95 | ||
| 96 | self::assertTrue($response->isSuccessful()); |
|
| 97 | $content = json_decode($response->getContent()); |
|
| 98 | self::assertInstanceOf(\stdClass::class, $content); |
|
| 99 | ||
| 100 | $jsonResponse = new SyncResponse($content); |
|
| 101 | self::assertTrue($jsonResponse->isSuccessful(), json_encode($content, JSON_PRETTY_PRINT)); |
|
| 102 | self::assertTrue(isset($jsonResponse->getBody()->{'sample_payload'}), json_encode($content, JSON_PRETTY_PRINT)); |
|
| 103 | self::assertEquals( |
|
| 104 | 'my-payload', |
|
| 105 | $jsonResponse->getBody()->{'sample_payload'}, |
|
| 106 | json_encode($content, JSON_PRETTY_PRINT) |
|
| 107 | ); |
|
| 108 | ||
| 109 | if (static::$kernel->getContainer()->has('jms_serializer')) { |
|
| 110 | self::assertTrue( |
|
| 111 | isset($jsonResponse->getBody()->{'private_payload'}), |
|
| 112 | json_encode($content, JSON_PRETTY_PRINT) |
|
| 113 | ); |
|
| 114 | self::assertEquals( |
|
| 115 | 'secret-payload', |
|
| 116 | $jsonResponse->getBody()->{'private_payload'}, |
|
| 117 | json_encode($content, JSON_PRETTY_PRINT) |
|
| 118 | ); |
|
| 119 | } |
|
| 120 | } |
|
| 121 | } |
|
| 122 | ||