getId() public method

public getId ( )
示例#1
0
 public function testPrimaryAddressHandlingPut()
 {
     $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()], 'emails' => [['id' => $this->email->getId(), 'email' => '*****@*****.**', 'emailType' => ['id' => $this->emailType->getId(), 'name' => 'Private']]], 'addresses' => [['id' => $this->address->getId(), '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'], ['street' => 'Street 1', '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'], ['street' => 'Street 2', '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']], 'salutation' => 'Sehr geehrter John', 'formOfAddress' => ['id' => 0]]);
     $response = json_decode($client->getResponse()->getContent());
     usort($response->addresses, $this->sortAddressesPrimaryLast());
     $this->assertEquals(false, $response->addresses[0]->primaryAddress);
     $this->assertEquals(false, $response->addresses[1]->primaryAddress);
     $this->assertEquals(true, $response->addresses[2]->primaryAddress);
     $client->request('GET', '/api/contacts/' . $response->id);
     $response = json_decode($client->getResponse()->getContent());
     usort($response->addresses, $this->sortAddressesPrimaryLast());
     $this->assertEquals(false, $response->addresses[0]->primaryAddress);
     $this->assertEquals(false, $response->addresses[1]->primaryAddress);
     $this->assertEquals(true, $response->addresses[2]->primaryAddress);
 }
示例#2
0
 public function testPutWithEmptyPassword()
 {
     $client = $this->createAuthenticatedClient();
     $client->request('PUT', '/api/users/' . $this->user1->getId(), ['username' => 'manager', 'password' => '', 'locale' => 'en', 'contact' => ['id' => $this->contact1->getId()], 'userRoles' => [['id' => $this->user1->getId(), 'role' => ['id' => $this->role1->getId()], 'locales' => ['de', 'en']], ['id' => 2, 'role' => ['id' => $this->role2->getId()], 'locales' => ['en']]]]);
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals('manager', $response->username);
     $this->assertEquals('securepassword', $response->password);
     $this->assertEquals($this->contact1->getId(), $response->contact->id);
     $this->assertEquals('en', $response->locale);
     $this->assertEquals('Role1', $response->userRoles[0]->role->name);
     $this->assertEquals('de', $response->userRoles[0]->locales[0]);
     $this->assertEquals('en', $response->userRoles[0]->locales[1]);
     $this->assertEquals('Role2', $response->userRoles[1]->role->name);
     $this->assertEquals('en', $response->userRoles[1]->locales[0]);
     $refreshedUser = $this->em->getRepository('SuluSecurityBundle:User')->find($this->user1->getId());
     $this->assertEquals($this->user1->getSalt(), $refreshedUser->getSalt());
 }