| @@ 18-46 (lines=29) @@ | ||
| 15 | } |
|
| 16 | ||
| 17 | ||
| 18 | public function testEntityLoading() |
|
| 19 | { |
|
| 20 | $repository = $this->getManager()->getRepository(TestEntity::class); |
|
| 21 | ||
| 22 | $this->getResponseMock()->append( |
|
| 23 | new Response( |
|
| 24 | 200, |
|
| 25 | [], |
|
| 26 | json_encode( |
|
| 27 | [ |
|
| 28 | 'jsonrpc' => '2.0', |
|
| 29 | 'id' => 'test', |
|
| 30 | 'result' => [ |
|
| 31 | 'id' => '1', |
|
| 32 | 'payload' => 'test-payload', |
|
| 33 | ], |
|
| 34 | ] |
|
| 35 | ) |
|
| 36 | ) |
|
| 37 | ); |
|
| 38 | ||
| 39 | /** @var TestEntity $entity */ |
|
| 40 | $entity = $repository->find(1); |
|
| 41 | ||
| 42 | self::assertInstanceOf(TestEntity::class, $entity); |
|
| 43 | self::assertEquals(1, $entity->getId()); |
|
| 44 | self::assertInternalType('int', $entity->getId()); |
|
| 45 | self::assertEquals('test-payload', $entity->getPayload()); |
|
| 46 | } |
|
| 47 | ||
| 48 | public function testInheritanceLoading() |
|
| 49 | { |
|
| @@ 48-76 (lines=29) @@ | ||
| 45 | self::assertEquals('test-payload', $entity->getPayload()); |
|
| 46 | } |
|
| 47 | ||
| 48 | public function testInheritanceLoading() |
|
| 49 | { |
|
| 50 | $repository = $this->getManager()->getRepository(SubEntity::class); |
|
| 51 | $this->getResponseMock()->append( |
|
| 52 | new Response( |
|
| 53 | 200, |
|
| 54 | [], |
|
| 55 | json_encode( |
|
| 56 | [ |
|
| 57 | 'jsonrpc' => '2.0', |
|
| 58 | 'id' => 'test', |
|
| 59 | 'result' => [ |
|
| 60 | 'id' => 2, |
|
| 61 | 'payload' => 'test-payload', |
|
| 62 | 'sub-payload' => 'sub-payload', |
|
| 63 | ], |
|
| 64 | ] |
|
| 65 | ) |
|
| 66 | ) |
|
| 67 | ); |
|
| 68 | ||
| 69 | /** @var SubEntity $entity */ |
|
| 70 | $entity = $repository->find(2); |
|
| 71 | ||
| 72 | self::assertInstanceOf(SubEntity::class, $entity); |
|
| 73 | self::assertEquals(2, $entity->getId()); |
|
| 74 | self::assertEquals('test-payload', $entity->getPayload()); |
|
| 75 | self::assertEquals('sub-payload', $entity->getSubPayload()); |
|
| 76 | } |
|
| 77 | ||
| 78 | public function testCompositeKeyLoading() |
|
| 79 | { |
|
| @@ 10-36 (lines=27) @@ | ||
| 7 | ||
| 8 | class IndirectFieldsTestAbstract extends AbstractEntityManagerTest |
|
| 9 | { |
|
| 10 | public function testIndirectId() |
|
| 11 | { |
|
| 12 | $repository = $this->getManager()->getRepository(IndirectIdEntity::class); |
|
| 13 | $this->getResponseMock()->append( |
|
| 14 | new Response( |
|
| 15 | 200, |
|
| 16 | [], |
|
| 17 | json_encode( |
|
| 18 | [ |
|
| 19 | 'jsonrpc' => '2.0', |
|
| 20 | 'id' => 'test', |
|
| 21 | 'result' => [ |
|
| 22 | 'some-long-api-field-name' => 241, |
|
| 23 | 'payload' => 'test', |
|
| 24 | ], |
|
| 25 | ] |
|
| 26 | ) |
|
| 27 | ) |
|
| 28 | ); |
|
| 29 | ||
| 30 | /** @var IndirectIdEntity $entity */ |
|
| 31 | $entity = $repository->find(241); |
|
| 32 | ||
| 33 | self::assertInstanceOf(IndirectIdEntity::class, $entity); |
|
| 34 | self::assertEquals(241, $entity->getId()); |
|
| 35 | self::assertEquals('test', $entity->getPayload()); |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| @@ 58-88 (lines=31) @@ | ||
| 55 | self::assertEquals(0, $this->getResponseMock()->count()); |
|
| 56 | } |
|
| 57 | ||
| 58 | public function testSimpleProxy() |
|
| 59 | { |
|
| 60 | $repository = $this->getManager()->getRepository(SubEntity::class); |
|
| 61 | ||
| 62 | $this->getResponseMock()->append( |
|
| 63 | new Response( |
|
| 64 | 200, |
|
| 65 | [], |
|
| 66 | json_encode( |
|
| 67 | [ |
|
| 68 | 'jsonrpc' => '2.0', |
|
| 69 | 'id' => 'test', |
|
| 70 | 'result' => [ |
|
| 71 | 'id' => 2, |
|
| 72 | 'payload' => 'test-payload', |
|
| 73 | 'sub-payload' => 'sub-payload', |
|
| 74 | ], |
|
| 75 | ] |
|
| 76 | ) |
|
| 77 | ) |
|
| 78 | ); |
|
| 79 | ||
| 80 | /** @var SubEntity|Proxy $entity */ |
|
| 81 | $entity = $repository->find(2); |
|
| 82 | ||
| 83 | //Test that we can obtain data and request was sent |
|
| 84 | self::assertInstanceOf(SubEntity::class, $entity); |
|
| 85 | self::assertEquals(2, $entity->getId()); |
|
| 86 | self::assertEquals('test-payload', $entity->getPayload()); |
|
| 87 | self::assertEquals('sub-payload', $entity->getSubPayload()); |
|
| 88 | } |
|
| 89 | ||
| 90 | protected function getClientNames() |
|
| 91 | { |
|