Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function hydrate(array $data)
 {
     // TODO: make a factory
     $organization = new Organization();
     $organization->setId(isset($data['id']) ? $data['id'] : null);
     $organization->setName(isset($data['name']) ? $data['name'] : null);
     $organization->setDescription(isset($data['description']) ? $data['description'] : null);
     $organization->setEmail(isset($data['email']) ? $data['email'] : null);
     $organization->setAddress(isset($data['address']) ? $data['address'] : null);
     $organization->setLocation(isset($data['location']) ? $data['location'] : null);
     $organization->setNumberOfEmployees(isset($data['numberOfEmployees']) ? $data['numberOfEmployees'] : null);
     $organization->setTelephone(isset($data['telephone']) ? $data['telephone'] : null);
     return $organization;
 }
 /**
  * Test the creation of an Organization object in database.
  */
 public function testCreateOrganization()
 {
     // GIVEN
     $organization = new Organization();
     $organization->setName('organization');
     $organization->setNumberOfEmployees(42);
     $organization->setLocation('the world');
     $organization->setAddress('1600 Amphitheatre Parkway');
     $organization->setEmail('*****@*****.**');
     $organization->setDescription('This is a full description of a complex and well structured organization.');
     $organization->setTelephone('+1 650-253-0000');
     // WHEN
     $this->getOrganizationRepository()->save($organization);
     // THEN
     $testOrganization = $this->getOrganizationRepository()->find($organization->getId());
     $this->assertEquals('organization', $testOrganization->getName());
     $this->assertEquals(42, $testOrganization->getNumberOfEmployees());
     $this->assertEquals('the world', $testOrganization->getLocation());
     $this->assertEquals('1600 Amphitheatre Parkway', $testOrganization->getAddress());
     $this->assertEquals('*****@*****.**', $testOrganization->getEmail());
     $this->assertEquals('This is a full description of a complex and well structured organization.', $testOrganization->getDescription());
     $this->assertEquals('+1 650-253-0000', $testOrganization->getTelephone());
 }