Inheritance: implements Sulu\Bundle\MediaBundle\Entity\MediaInterface
 public function testAccountMediaDelete()
 {
     $client = $this->createAuthenticatedClient();
     $client->request('DELETE', '/api/accounts/' . $this->account->getId() . '/medias/' . $this->media2->getId());
     $this->assertEquals('204', $client->getResponse()->getStatusCode());
     $client->request('GET', '/api/accounts/' . $this->account->getId());
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals(0, count($response->medias));
 }
 public function setUpMediaEntities($contact)
 {
     $mediaType = new MediaType();
     $mediaType->setName('document');
     $mediaType->setDescription('This is a document');
     $imageType = new MediaType();
     $imageType->setName('image');
     $imageType->setDescription('This is an image');
     $videoType = new MediaType();
     $videoType->setName('video');
     $videoType->setDescription('This is a video');
     $audioType = new MediaType();
     $audioType->setName('audio');
     $audioType->setDescription('This is an audio');
     $media = new Media();
     $media->setType($imageType);
     $this->media = $media;
     $media2 = new Media();
     $media2->setType($imageType);
     $this->media2 = $media2;
     $contact->addMedia($media2);
     // create file
     $file = new File();
     $file->setVersion(1);
     $file->setMedia($media);
     $file2 = new File();
     $file2->setVersion(1);
     $file2->setMedia($media2);
     // create file version
     $fileVersion = new FileVersion();
     $fileVersion->setVersion(1);
     $fileVersion->setName('photo.jpeg');
     $fileVersion->setMimeType('image/jpg');
     $fileVersion->setFile($file);
     $fileVersion->setSize(1124214);
     $fileVersion->setDownloadCounter(2);
     $fileVersion->setStorageOptions('{"segment":"1","fileName":"photo.jpeg"}');
     $file->addFileVersion($fileVersion);
     // create file version
     $fileVersion = new FileVersion();
     $fileVersion->setVersion(1);
     $fileVersion->setName('photo.jpeg');
     $fileVersion->setMimeType('image/jpg');
     $fileVersion->setFile($file2);
     $fileVersion->setSize(1124214);
     $fileVersion->setDownloadCounter(2);
     $fileVersion->setStorageOptions('{"segment":"1","fileName":"photo.jpeg"}');
     $file2->addFileVersion($fileVersion);
     $collection = new Collection();
     $this->setUpCollection($collection);
     $media->setCollection($collection);
     $media2->setCollection($collection);
     $this->em->persist($media);
     $this->em->persist($media2);
     $this->em->persist($collection);
     $this->em->persist($file);
     $this->em->persist($file2);
     $this->em->persist($videoType);
     $this->em->persist($imageType);
     $this->em->persist($audioType);
     $this->em->persist($mediaType);
 }
Esempio n. 3
0
 public function testPut()
 {
     $client = $this->createAuthenticatedClient();
     $client->request('PUT', '/api/accounts/' . $this->account->getId(), ['name' => 'ExampleCompany', 'logo' => ['id' => $this->logo->getId()], 'urls' => [['id' => $this->url->getId(), 'url' => 'http://example.company.com', 'urlType' => ['id' => $this->urlType->getId(), 'name' => 'Private']], ['url' => 'http://test.company.com', 'urlType' => ['id' => $this->urlType->getId(), 'name' => 'Private']]], 'emails' => [['email' => '*****@*****.**', 'emailType' => ['id' => $this->emailType->getId(), 'name' => 'Private']], ['email' => '*****@*****.**', 'emailType' => ['id' => $this->emailType->getId(), 'name' => 'Private']]], 'phones' => [['phone' => '4567890', 'phoneType' => ['id' => $this->phoneType->getId(), 'name' => 'Private']], ['phone' => '789456123', 'phoneType' => ['id' => $this->phoneType->getId(), 'name' => 'Private']]], 'faxes' => [['fax' => '4567890-1', 'faxType' => ['id' => $this->faxType->getId(), 'name' => 'Private']], ['fax' => '789456123-1', 'faxType' => ['id' => $this->faxType->getId(), 'name' => 'Private']]], 'addresses' => [['street' => 'Bahnhofstraße', 'number' => '2', 'zip' => '0022', 'city' => 'Dornbirn', 'state' => 'state1', 'country' => ['id' => $this->country->getId(), 'name' => 'Musterland', 'code' => 'ML'], 'addressType' => ['id' => $this->addressType->getId(), 'name' => 'Private'], 'billingAddress' => true, 'primaryAddress' => true, 'deliveryAddress' => false, 'postboxCity' => 'Dornbirn', 'postboxPostcode' => '6850', 'postboxNumber' => '4711', 'note' => 'note'], ['street' => 'Rathausgasse', 'number' => '3', 'zip' => '2222', 'city' => 'Dornbirn', 'state' => 'state1', 'country' => ['id' => $this->country->getId(), 'name' => 'Musterland', 'code' => 'ML'], 'addressType' => ['id' => $this->addressType->getId(), 'name' => 'Private'], 'note' => 'note1']], 'notes' => [['value' => 'Note1'], ['value' => 'Note2']]]);
     //$this->assertEquals(200, $client->getResponse()->getStatusCode());
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals(200, $client->getResponse()->getStatusCode());
     $this->assertEquals('ExampleCompany', $response->name);
     $this->assertEquals(2, count($response->urls));
     $this->assertEquals('http://example.company.com', $response->urls[0]->url);
     $this->assertEquals('Private', $response->urls[0]->urlType->name);
     $this->assertEquals('http://test.company.com', $response->urls[1]->url);
     $this->assertEquals('Private', $response->urls[1]->urlType->name);
     $this->assertEquals(2, count($response->emails));
     $this->assertEquals('*****@*****.**', $response->emails[0]->email);
     $this->assertEquals('Private', $response->emails[0]->emailType->name);
     $this->assertEquals('*****@*****.**', $response->emails[1]->email);
     $this->assertEquals('Private', $response->emails[1]->emailType->name);
     $this->assertEquals(2, count($response->phones));
     $this->assertEquals('4567890', $response->phones[0]->phone);
     $this->assertEquals('Private', $response->phones[0]->phoneType->name);
     $this->assertEquals('789456123', $response->phones[1]->phone);
     $this->assertEquals('Private', $response->phones[1]->phoneType->name);
     $this->assertEquals(2, count($response->faxes));
     $this->assertEquals('4567890-1', $response->faxes[0]->fax);
     $this->assertEquals('Private', $response->faxes[0]->faxType->name);
     $this->assertEquals('789456123-1', $response->faxes[1]->fax);
     $this->assertEquals('Private', $response->faxes[1]->faxType->name);
     $this->assertEquals(2, count($response->notes));
     $this->assertEquals('Note1', $response->notes[0]->value);
     $this->assertEquals('Note2', $response->notes[1]->value);
     $this->assertObjectHasAttribute('logo', $response);
     $this->assertEquals($this->logo->getId(), $response->logo->id);
     $this->assertObjectHasAttribute('thumbnails', $response->logo);
     $this->assertObjectHasAttribute('100x100', $response->logo->thumbnails);
     $this->assertTrue(is_string($response->logo->thumbnails->{'100x100'}));
     if ($response->addresses[0]->street === 'Bahnhofstraße') {
         $this->assertEquals(2, count($response->addresses));
         $this->assertEquals('Bahnhofstraße', $response->addresses[0]->street);
         $this->assertEquals('2', $response->addresses[0]->number);
         $this->assertEquals('0022', $response->addresses[0]->zip);
         $this->assertEquals('Dornbirn', $response->addresses[0]->city);
         $this->assertEquals('state1', $response->addresses[0]->state);
         $this->assertEquals('note', $response->addresses[0]->note);
         $this->assertEquals('Musterland', $response->addresses[0]->country->name);
         $this->assertEquals('ML', $response->addresses[0]->country->code);
         $this->assertEquals('Private', $response->addresses[0]->addressType->name);
         $this->assertEquals(true, $response->addresses[0]->billingAddress);
         $this->assertEquals(true, $response->addresses[0]->primaryAddress);
         $this->assertEquals(false, $response->addresses[0]->deliveryAddress);
         $this->assertEquals('Dornbirn', $response->addresses[0]->postboxCity);
         $this->assertEquals('6850', $response->addresses[0]->postboxPostcode);
         $this->assertEquals('4711', $response->addresses[0]->postboxNumber);
         $this->assertEquals('Rathausgasse', $response->addresses[1]->street);
         $this->assertEquals('3', $response->addresses[1]->number);
         $this->assertEquals('2222', $response->addresses[1]->zip);
         $this->assertEquals('Dornbirn', $response->addresses[1]->city);
         $this->assertEquals('note1', $response->addresses[1]->note);
         $this->assertEquals('state1', $response->addresses[1]->state);
         $this->assertEquals('Musterland', $response->addresses[1]->country->name);
         $this->assertEquals('ML', $response->addresses[1]->country->code);
         $this->assertEquals('Private', $response->addresses[1]->addressType->name);
     } else {
         $this->assertEquals(2, count($response->addresses));
         $this->assertEquals('Bahnhofstraße', $response->addresses[1]->street);
         $this->assertEquals('2', $response->addresses[1]->number);
         $this->assertEquals('note', $response->addresses[1]->note);
         $this->assertEquals('0022', $response->addresses[1]->zip);
         $this->assertEquals('Dornbirn', $response->addresses[1]->city);
         $this->assertEquals('state1', $response->addresses[1]->state);
         $this->assertEquals('Musterland', $response->addresses[1]->country->name);
         $this->assertEquals('ML', $response->addresses[1]->country->code);
         $this->assertEquals('Private', $response->addresses[1]->addressType->name);
         $this->assertEquals(true, $response->addresses[1]->billingAddress);
         $this->assertEquals(true, $response->addresses[1]->primaryAddress);
         $this->assertEquals(false, $response->addresses[1]->deliveryAddress);
         $this->assertEquals('Dornbirn', $response->addresses[1]->postboxCity);
         $this->assertEquals('6850', $response->addresses[1]->postboxPostcode);
         $this->assertEquals('4711', $response->addresses[1]->postboxNumber);
         $this->assertEquals('Rathausgasse', $response->addresses[0]->street);
         $this->assertEquals('3', $response->addresses[0]->number);
         $this->assertEquals('2222', $response->addresses[0]->zip);
         $this->assertEquals('Dornbirn', $response->addresses[0]->city);
         $this->assertEquals('state1', $response->addresses[0]->state);
         $this->assertEquals('Musterland', $response->addresses[0]->country->name);
         $this->assertEquals('ML', $response->addresses[0]->country->code);
         $this->assertEquals('note1', $response->addresses[0]->note);
         $this->assertEquals('Private', $response->addresses[0]->addressType->name);
     }
     $client->request('GET', '/api/accounts/' . $this->account->getId());
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals(200, $client->getResponse()->getStatusCode());
     $this->assertEquals('ExampleCompany', $response->name);
     $this->assertEquals(2, count($response->urls));
     $this->assertEquals('http://example.company.com', $response->urls[0]->url);
     $this->assertEquals('Private', $response->urls[0]->urlType->name);
     $this->assertEquals('http://test.company.com', $response->urls[1]->url);
     $this->assertEquals('Private', $response->urls[1]->urlType->name);
     $this->assertEquals(2, count($response->emails));
     $this->assertEquals('*****@*****.**', $response->emails[0]->email);
     $this->assertEquals('Private', $response->emails[0]->emailType->name);
     $this->assertEquals('*****@*****.**', $response->emails[1]->email);
     $this->assertEquals('Private', $response->emails[1]->emailType->name);
     $this->assertEquals(2, count($response->phones));
     $this->assertEquals('4567890', $response->phones[0]->phone);
     $this->assertEquals('Private', $response->phones[0]->phoneType->name);
     $this->assertEquals('789456123', $response->phones[1]->phone);
     $this->assertEquals('Private', $response->phones[1]->phoneType->name);
     $this->assertEquals(2, count($response->faxes));
     $this->assertEquals('4567890-1', $response->faxes[0]->fax);
     $this->assertEquals('Private', $response->faxes[0]->faxType->name);
     $this->assertEquals('789456123-1', $response->faxes[1]->fax);
     $this->assertEquals('Private', $response->faxes[1]->faxType->name);
     $this->assertEquals(2, count($response->notes));
     $this->assertEquals('Note1', $response->notes[0]->value);
     $this->assertEquals('Note2', $response->notes[1]->value);
     $this->assertObjectHasAttribute('logo', $response);
     $this->assertEquals($this->logo->getId(), $response->logo->id);
     $this->assertObjectHasAttribute('thumbnails', $response->logo);
     $this->assertObjectHasAttribute('100x100', $response->logo->thumbnails);
     $this->assertTrue(is_string($response->logo->thumbnails->{'100x100'}));
     if ($response->addresses[0]->street === 'Bahnhofstraße') {
         $this->assertEquals(2, count($response->addresses));
         $this->assertEquals('Bahnhofstraße', $response->addresses[0]->street);
         $this->assertEquals('2', $response->addresses[0]->number);
         $this->assertEquals('0022', $response->addresses[0]->zip);
         $this->assertEquals('Dornbirn', $response->addresses[0]->city);
         $this->assertEquals('state1', $response->addresses[0]->state);
         $this->assertEquals('Musterland', $response->addresses[0]->country->name);
         $this->assertEquals('ML', $response->addresses[0]->country->code);
         $this->assertEquals('Private', $response->addresses[0]->addressType->name);
         $this->assertEquals(true, $response->addresses[0]->billingAddress);
         $this->assertEquals(true, $response->addresses[0]->primaryAddress);
         $this->assertEquals(false, $response->addresses[0]->deliveryAddress);
         $this->assertEquals('Dornbirn', $response->addresses[0]->postboxCity);
         $this->assertEquals('6850', $response->addresses[0]->postboxPostcode);
         $this->assertEquals('note', $response->addresses[0]->note);
         $this->assertEquals('4711', $response->addresses[0]->postboxNumber);
         $this->assertEquals('Rathausgasse', $response->addresses[1]->street);
         $this->assertEquals('3', $response->addresses[1]->number);
         $this->assertEquals('2222', $response->addresses[1]->zip);
         $this->assertEquals('Dornbirn', $response->addresses[1]->city);
         $this->assertEquals('state1', $response->addresses[1]->state);
         $this->assertEquals('Musterland', $response->addresses[1]->country->name);
         $this->assertEquals('ML', $response->addresses[1]->country->code);
         $this->assertEquals('Private', $response->addresses[1]->addressType->name);
         $this->assertEquals('note1', $response->addresses[1]->note);
     } else {
         $this->assertEquals(2, count($response->addresses));
         $this->assertEquals('Bahnhofstraße', $response->addresses[1]->street);
         $this->assertEquals('2', $response->addresses[1]->number);
         $this->assertEquals('0022', $response->addresses[1]->zip);
         $this->assertEquals('Dornbirn', $response->addresses[1]->city);
         $this->assertEquals('state1', $response->addresses[1]->state);
         $this->assertEquals('Musterland', $response->addresses[1]->country->name);
         $this->assertEquals('ML', $response->addresses[1]->country->code);
         $this->assertEquals('Private', $response->addresses[1]->addressType->name);
         $this->assertEquals(true, $response->addresses[1]->billingAddress);
         $this->assertEquals(true, $response->addresses[1]->primaryAddress);
         $this->assertEquals(false, $response->addresses[1]->deliveryAddress);
         $this->assertEquals('Dornbirn', $response->addresses[1]->postboxCity);
         $this->assertEquals('6850', $response->addresses[1]->postboxPostcode);
         $this->assertEquals('4711', $response->addresses[1]->postboxNumber);
         $this->assertEquals('note', $response->addresses[1]->note);
         $this->assertEquals('Rathausgasse', $response->addresses[0]->street);
         $this->assertEquals('3', $response->addresses[0]->number);
         $this->assertEquals('2222', $response->addresses[0]->zip);
         $this->assertEquals('Dornbirn', $response->addresses[0]->city);
         $this->assertEquals('state1', $response->addresses[0]->state);
         $this->assertEquals('Musterland', $response->addresses[0]->country->name);
         $this->assertEquals('ML', $response->addresses[0]->country->code);
         $this->assertEquals('Private', $response->addresses[0]->addressType->name);
         $this->assertEquals('note1', $response->addresses[0]->note);
     }
 }
Esempio n. 4
0
 /**
  * Create a new media.
  *
  * @param $data
  * @param $user
  *
  * @return Media
  */
 protected function createMedia($data, $user)
 {
     $mediaEntity = new MediaEntity();
     $mediaEntity->setCreator($user);
     $mediaEntity->setChanger($user);
     $file = new File();
     $file->setCreator($user);
     $file->setChanger($user);
     $file->setVersion(1);
     $file->setMedia($mediaEntity);
     $fileVersion = new FileVersion();
     $fileVersion->setCreator($user);
     $fileVersion->setChanger($user);
     $fileVersion->setVersion(1);
     $fileVersion->setFile($file);
     $file->addFileVersion($fileVersion);
     $mediaEntity->addFile($file);
     $media = new Media($mediaEntity, $data['locale'], null);
     $media = $this->setDataToMedia($media, $data, $user);
     $fileVersion->setDefaultMeta($fileVersion->getMeta()->first());
     $mediaEntity = $media->getEntity();
     $this->em->persist($mediaEntity);
     $this->em->flush();
     return $media;
 }
Esempio n. 5
0
 protected function createMedia($name)
 {
     $media = new Media();
     $media->setType($this->imageType);
     // create file
     $file = new File();
     $file->setVersion(1);
     $file->setMedia($media);
     // create file version
     $fileVersion = new FileVersion();
     $fileVersion->setVersion(1);
     $fileVersion->setName($name . '.jpeg');
     $fileVersion->setMimeType('image/jpg');
     $fileVersion->setFile($file);
     $fileVersion->setSize(1124214);
     $fileVersion->setDownloadCounter(2);
     $fileVersion->setChanged(new \DateTime('1937-04-20'));
     $fileVersion->setCreated(new \DateTime('1937-04-20'));
     $fileVersion->setStorageOptions('{"segment":"1","fileName":"' . $name . '.jpeg"}');
     if (!file_exists(__DIR__ . '/../../uploads/media/1')) {
         mkdir(__DIR__ . '/../../uploads/media/1', 0777, true);
     }
     copy($this->getImagePath(), __DIR__ . '/../../uploads/media/1/' . $name . '.jpeg');
     // create meta
     $fileVersionMeta = new FileVersionMeta();
     $fileVersionMeta->setLocale('en-gb');
     $fileVersionMeta->setTitle($name);
     $fileVersionMeta->setDescription($this->mediaDefaultDescription);
     $fileVersionMeta->setFileVersion($fileVersion);
     $fileVersion->addMeta($fileVersionMeta);
     $fileVersion->setDefaultMeta($fileVersionMeta);
     $file->addFileVersion($fileVersion);
     $media->addFile($file);
     $media->setCollection($this->collection);
     $this->em->persist($media);
     $this->em->persist($file);
     $this->em->persist($fileVersionMeta);
     $this->em->persist($fileVersion);
     $this->em->flush();
     return $media;
 }
Esempio n. 6
0
 /**
  * @param Media $media
  *
  * @return array
  *
  * @throws \Sulu\Bundle\MediaBundle\Media\Exception\ImageProxyMediaNotFoundException
  */
 protected function getMediaData($media)
 {
     $fileName = null;
     $storageOptions = null;
     $version = null;
     $mimeType = null;
     /** @var File $file */
     foreach ($media->getFiles() as $file) {
         $version = $file->getVersion();
         /** @var FileVersion $fileVersion */
         foreach ($file->getFileVersions() as $fileVersion) {
             if ($fileVersion->getVersion() == $version) {
                 $fileName = $fileVersion->getName();
                 $storageOptions = $fileVersion->getStorageOptions();
                 $mimeType = $fileVersion->getMimeType();
                 break;
             }
         }
         break;
     }
     if (!$fileName) {
         throw new ImageProxyMediaNotFoundException('Media file version was not found');
     }
     return [$fileName, $version, $storageOptions, $mimeType];
 }
 private function createFile($oldTitle, $newTitle, $collection = null)
 {
     $media = new Media();
     $media->setType($this->mediaType);
     $media->setCollection($collection ?: $this->collection);
     $file = new File();
     $file->setVersion(2);
     $file->setMedia($media);
     $this->createFileVersion($file, $oldTitle, 1);
     $this->createFileVersion($file, $newTitle, 2);
     $this->em->persist($file);
     $this->em->persist($media);
 }
Esempio n. 8
0
 public function testPut()
 {
     $client = $this->createTestClient();
     $client->request('PUT', '/api/contacts/' . $this->contact->getId(), ['firstName' => 'John', 'lastName' => 'Doe', 'title' => $this->contactTitle->getId(), 'position' => ['id' => $this->contactPosition->getId(), 'position' => $this->contactPosition->getPosition()], 'avatar' => ['id' => $this->avatar->getId()], 'emails' => [['id' => $this->email->getId(), 'email' => '*****@*****.**', 'emailType' => ['id' => $this->emailType->getId(), 'name' => 'Private']], ['email' => '*****@*****.**', 'emailType' => ['id' => $this->emailType->getId(), 'name' => 'Private']]], 'phones' => [['id' => $this->phone->getId(), 'phone' => '321654987', 'phoneType' => ['id' => $this->phoneType->getId(), 'name' => 'Private']], ['phone' => '789456123', 'phoneType' => ['id' => $this->phoneType->getId(), 'name' => 'Private']], ['phone' => '147258369', 'phoneType' => ['id' => $this->phoneType->getId(), 'name' => 'Private']]], 'faxes' => [['id' => $this->fax->getId(), 'fax' => '321654987-1', 'faxType' => ['id' => $this->faxType->getId(), 'name' => 'Private']], ['fax' => '789456123-1', 'faxType' => ['id' => $this->faxType->getId(), 'name' => 'Private']], ['fax' => '147258369-1', 'faxType' => ['id' => $this->faxType->getId(), 'name' => 'Private']]], 'addresses' => [['id' => $this->address->getId(), 'title' => 'work', 'street' => 'Street', 'number' => '2', 'zip' => '9999', 'city' => 'Springfield', 'state' => 'Colorado', 'country' => ['id' => $this->country->getId(), 'name' => 'Musterland', 'code' => 'ML'], 'addressType' => ['id' => $this->addressType->getId(), 'name' => 'Private'], 'billingAddress' => true, 'primaryAddress' => true, 'deliveryAddress' => false, 'postboxCity' => 'Dornbirn', 'postboxPostcode' => '6850', 'postboxNumber' => '4711', 'note' => 'note']], 'notes' => [['id' => $this->note->getId(), 'value' => 'Note 1_1']], 'salutation' => 'Sehr geehrter John', 'formOfAddress' => ['id' => 0], 'categories' => [['id' => $this->category->getId()], ['id' => $this->category2->getId()]]]);
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals('John', $response->firstName);
     $this->assertEquals('Doe', $response->lastName);
     $this->assertEquals('MSc', $response->title->title);
     $this->assertEquals('*****@*****.**', $response->emails[0]->email);
     $this->assertEquals('*****@*****.**', $response->emails[1]->email);
     $this->assertEquals('321654987', $response->phones[0]->phone);
     $this->assertEquals('789456123', $response->phones[1]->phone);
     $this->assertEquals('147258369', $response->phones[2]->phone);
     $this->assertEquals('321654987-1', $response->faxes[0]->fax);
     $this->assertEquals('789456123-1', $response->faxes[1]->fax);
     $this->assertEquals('147258369-1', $response->faxes[2]->fax);
     $this->assertEquals('Street', $response->addresses[0]->street);
     $this->assertEquals('2', $response->addresses[0]->number);
     $this->assertEquals('9999', $response->addresses[0]->zip);
     $this->assertEquals('Springfield', $response->addresses[0]->city);
     $this->assertEquals('Colorado', $response->addresses[0]->state);
     $this->assertEquals('Note 1_1', $response->notes[0]->value);
     $this->assertEquals(1, count($response->notes));
     $this->assertEquals('note', $response->addresses[0]->note);
     $this->assertEquals(true, $response->addresses[0]->billingAddress);
     $this->assertEquals(true, $response->addresses[0]->primaryAddress);
     $this->assertEquals(false, $response->addresses[0]->deliveryAddress);
     $this->assertEquals('Dornbirn', $response->addresses[0]->postboxCity);
     $this->assertEquals('6850', $response->addresses[0]->postboxPostcode);
     $this->assertEquals('4711', $response->addresses[0]->postboxNumber);
     $this->assertEquals(0, $response->formOfAddress);
     $this->assertEquals('Sehr geehrter John', $response->salutation);
     $this->assertObjectHasAttribute('avatar', $response);
     $this->assertObjectHasAttribute('thumbnails', $response->avatar);
     $this->assertObjectHasAttribute('100x100', $response->avatar->thumbnails);
     $this->assertTrue(is_string($response->avatar->thumbnails->{'100x100'}));
     $this->assertEquals(2, count($response->categories));
     $client->request('GET', '/api/contacts/' . $response->id);
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals('John', $response->firstName);
     $this->assertEquals('Doe', $response->lastName);
     $this->assertEquals('MSc', $response->title->title);
     $this->assertEquals('*****@*****.**', $response->emails[0]->email);
     $this->assertEquals('*****@*****.**', $response->emails[1]->email);
     $this->assertEquals('321654987', $response->phones[0]->phone);
     $this->assertEquals('789456123', $response->phones[1]->phone);
     $this->assertEquals('147258369', $response->phones[2]->phone);
     $this->assertEquals('321654987-1', $response->faxes[0]->fax);
     $this->assertEquals('789456123-1', $response->faxes[1]->fax);
     $this->assertEquals('147258369-1', $response->faxes[2]->fax);
     $this->assertEquals('Street', $response->addresses[0]->street);
     $this->assertEquals('2', $response->addresses[0]->number);
     $this->assertEquals('9999', $response->addresses[0]->zip);
     $this->assertEquals('Springfield', $response->addresses[0]->city);
     $this->assertEquals('Colorado', $response->addresses[0]->state);
     $this->assertEquals('Note 1_1', $response->notes[0]->value);
     $this->assertEquals(1, count($response->notes));
     $this->assertEquals('work', $response->addresses[0]->title);
     $this->assertEquals(true, $response->addresses[0]->billingAddress);
     $this->assertEquals(true, $response->addresses[0]->primaryAddress);
     $this->assertEquals(false, $response->addresses[0]->deliveryAddress);
     $this->assertEquals('Dornbirn', $response->addresses[0]->postboxCity);
     $this->assertEquals('6850', $response->addresses[0]->postboxPostcode);
     $this->assertEquals('4711', $response->addresses[0]->postboxNumber);
     $this->assertEquals(0, $response->formOfAddress);
     $this->assertEquals('Sehr geehrter John', $response->salutation);
     $this->assertObjectHasAttribute('avatar', $response);
     $this->assertObjectHasAttribute('thumbnails', $response->avatar);
     $this->assertObjectHasAttribute('100x100', $response->avatar->thumbnails);
     $this->assertTrue(is_string($response->avatar->thumbnails->{'100x100'}));
     $this->assertEquals(2, count($response->categories));
 }