- $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findByUser($this->getLoggedInUserId());
- $this->assertGreaterThan(count($newNbClients), count($nbClients));
+ $this->assertNull(
+ $em->getRepository('WallabagApiBundle:Client')->find($adminApiClient->getId()),
+ 'The client should have been removed'
+ );
+ }
+
+ /**
+ * @param string $username
+ *
+ * @return Client
+ */
+ private function createApiClientForUser($username)
+ {
+ $client = $this->getClient();
+ $em = $client->getContainer()->get('doctrine.orm.entity_manager');
+ $userManager = $client->getContainer()->get('fos_user.user_manager');
+ $user = $userManager->findUserBy(array('username' => $username));
+ $apiClient = new Client($user);
+ $apiClient->setName('My app');
+ $apiClient->setAllowedGrantTypes(['password']);
+ $em->persist($apiClient);
+ $em->flush();
+
+ return $apiClient;