/**
  * @cover \app\Domain\Collectors\ClientCollector:attach
  * @cover \app\Domain\Collectors\ClientCollector:toArray
  */
 public function testGetCollectionMustReturnArray()
 {
     $collector = new ClientCollector();
     $client = new ClientEntity();
     $client->setId("1234");
     $client->setFirstName("Silex");
     $client->setLastName("Project");
     $client->setEmail("*****@*****.**");
     $client->setAge('1');
     $collector->add($client);
     $expected[] = ['id' => '1234', 'first_name' => 'Silex', 'last_name' => 'Project', 'email' => '*****@*****.**', 'age' => '1'];
     $this->assertEquals($expected, $collector->toArray());
 }
Esempio n. 2
1
 /**
  * @var \Domain\Entities\ClientEntity
  *
  * @return \Domain\Collectors\ClientCollector
  */
 public function search($client)
 {
     if (!$client instanceof ClientEntity) {
         throw new \InvalidArgumentException('Expected ClientEntity in saveClient');
     }
     $result = $this->repository->search($client);
     $clientCollector = new ClientCollector();
     foreach ($result as $users) {
         $clientEntity = new ClientEntity();
         $clientEntity->setId((string) $users['_id']);
         $clientEntity->setFirstName($users['first_name']);
         $clientEntity->setLastName($users['last_name']);
         $clientEntity->setEmail($users['email']);
         $clientEntity->setAge($users['age']);
         $clientCollector->add($clientEntity);
     }
     return $clientCollector;
 }