getId() public method

Get id.
public getId ( ) : integer
return integer
示例#1
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));
 }