public function testDeleteEntity()
 {
     $controller = new JsonApiController();
     $meta = $this->getMockBuilder("Doctrine\\ORM\\Mapping\\ClassMetadata")->setConstructorArgs(["NwApi\\Entities\\User"])->getMock();
     $di = Di::getInstance();
     $di->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $di->em->expects($this->any())->method('find')->willReturn(true);
     $meta->identifier = ['id'];
     $controller->deleteEntity($meta, [$this->faker->randomDigit()]);
 }
 private function addRoutesFromMeta(Slim $application, ClassMetadata $meta, Controller $controller)
 {
     $entitiesRoute = $this->getEntitiesRoute($meta);
     // Fetch entities route
     $application->get($entitiesRoute, function () use($meta, $controller) {
         $controller->getEntities($meta);
     });
     // Create entity
     $application->post($entitiesRoute, function () use($meta, $controller) {
         $controller->createEntity($meta);
     });
     $entityRoute = $this->getEntityRoute($meta, $entitiesRoute);
     // Get entity
     $application->get($entityRoute, function () use($meta, $controller) {
         $controller->getEntity($meta, func_get_args());
     });
     // Update entity
     $application->put($entityRoute, function () use($meta, $controller) {
         $controller->updateEntity($meta, func_get_args());
     });
     // Patch entity
     $application->patch($entityRoute, function () use($meta, $controller) {
         $controller->patchEntity($meta, func_get_args());
     });
     // Delete entity
     $application->delete($entityRoute, function () use($meta, $controller) {
         $controller->deleteEntity($meta, func_get_args());
     });
     // Handling associated entities
     foreach ($meta->getAssociationMappings() as $aName => $aData) {
         $aTargetClass = $meta->getAssociationTargetClass($aName);
         $aMeta = $this->getEntityMeta($aTargetClass);
         $aEntitiesRoute = $entityRoute . '/' . $aName;
         // Create associated entity
         // allow to create entity and link source together
         // POST /articles/1/tags will fetch article 1, create tag entity and
         // associate it to article 1
         $application->post($aEntitiesRoute, function () use($meta, $aMeta, $controller, $aData) {
             $controller->createEntity($aMeta, $aData['fieldName'], $meta, func_get_args());
         });
         // List associated entities
         $application->get($aEntitiesRoute, function () use($meta, $controller, $aData) {
             $controller->getAssociatedEntities($aData['fieldName'], $meta, func_get_args());
         });
         // Associate two entities
         // POST /articles/1/tags/2 will associate article 1 to tag 2
         $aEntityRoute = $this->getEntityRoute($aMeta, $aEntitiesRoute);
         $application->post($aEntityRoute, function () use($meta, $aMeta, $controller, $aData) {
             $controller->associateEntities($aMeta, $aData['fieldName'], $meta, func_get_args());
         });
     }
     return $application;
 }