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 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); } }
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)); }