public function testItProperlyExtractsObjects()
 {
     $now = new \DateTime();
     $client = new Client(array('id' => 123, 'guid' => 456, 'wid' => 789, 'name' => 'Test name', 'at' => $now, 'notes' => 'Test notes', 'hrate' => 4.57, 'cur' => 'HRK'));
     $data = $this->hydrator->extract($client);
     $this->assertEquals($client->id, $data['id']);
     $this->assertEquals($client->guid, $data['guid']);
     $this->assertEquals($client->wid, $data['wid']);
     $this->assertEquals($client->name, $data['name']);
     $this->assertEquals($client->at->format('c'), $data['at']);
     $this->assertEquals($client->notes, $data['notes']);
     $this->assertEquals($client->hrate, $data['hrate']);
     $this->assertEquals($client->cur, $data['cur']);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function extract($object)
 {
     return $this->hydrator->extract($object);
 }
Example #3
0
 /**
  * Hydrate helper method
  *
  * @param \Marek\Toggable\API\Http\Response\ResponseInterface $response
  * @param object $object
  *
  * @return object
  */
 protected function hydrateDataFromArrayToObject(\Marek\Toggable\API\Http\Response\ResponseInterface $response, $object)
 {
     $data = $response->getBody()['data'];
     return $this->hydrator->hydrate($data, $object);
 }