| Conditions | 1 |
| Paths | 1 |
| Total Lines | 33 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function testDeleteAction() |
||
| 11 | { |
||
| 12 | $em = $this->getEntityManager(); |
||
| 13 | $entity = new MyEntity('my-test-secret'); |
||
| 14 | $em->persist($entity); |
||
| 15 | $parent = new MyEntity('non-recursing-entity'); |
||
| 16 | $em->persist($parent); |
||
| 17 | $entity->setParent($parent); |
||
| 18 | $em->flush(); |
||
| 19 | $em->clear(); |
||
| 20 | |||
| 21 | $client = self::createClient(); |
||
| 22 | $client->request( |
||
| 23 | 'POST', |
||
| 24 | '/api/entity/my-entity/delete', |
||
| 25 | ['identifier' => $entity->getId()], |
||
| 26 | [], |
||
| 27 | ['HTTP_CONTENT_TYPE' => 'application/json'] |
||
| 28 | ); |
||
| 29 | $response = $client->getResponse(); |
||
| 30 | |||
| 31 | self::assertTrue($response->isSuccessful()); |
||
| 32 | $data = json_decode($response->getContent()); |
||
| 33 | |||
| 34 | self::assertEquals(JSON_ERROR_NONE, json_last_error()); |
||
| 35 | self::assertNull($data); |
||
| 36 | |||
| 37 | $em->clear(); |
||
| 38 | $parent = $em->find(MyEntity::class, $parent->getId()); |
||
| 39 | self::assertCount(0, $parent->getChildren()); |
||
| 40 | |||
| 41 | self::assertNull($em->find(MyEntity::class, $entity->getId())); |
||
| 42 | } |
||
| 43 | } |
||
| 44 |