Example #1
0
 /**
  * Test if deleteinfo returns correct data.
  */
 public function testGetDeleteInfoById()
 {
     // modify test data
     for ($i = 0; $i < 5; ++$i) {
         $contact = new Contact();
         $contact->setFirstName('Vorname ' . $i);
         $contact->setLastName('Nachname ' . $i);
         $contact->setMiddleName('Mittelname ' . $i);
         $contact->setFormOfAddress(0);
         $this->em->persist($contact);
         $accountContact = new AccountContact();
         $accountContact->setContact($contact);
         $accountContact->setAccount($this->account);
         $accountContact->setMain(true);
         $this->em->persist($accountContact);
         $this->account->addAccountContact($accountContact);
     }
     $this->em->flush();
     $numContacts = $this->account->getAccountContacts()->count();
     $client = $this->createAuthenticatedClient();
     $client->request('GET', '/api/accounts/' . $this->account->getId() . '/deleteinfo');
     $this->assertEquals('200', $client->getResponse()->getStatusCode());
     $response = json_decode($client->getResponse()->getContent());
     // number of returned contacts has to be less or equal 3
     $this->assertEquals(3, count($response->contacts));
     // return full number of contacts related to account
     $this->assertEquals($numContacts, $response->numContacts);
     // allowed if no subaccount exists
     $this->assertEquals(0, $response->numChildren);
 }