/** * Just Display the Home Page, with a list of hotels * @return ViewModel */ public function indexAction() { /** * Assume success, as we throw Exceptions in case of errors * Note that majority of our response are similar and have defaults */ $response = ['success' => true, 'hotels' => [], 'minPriceDefault' => $this->_config->minPriceDefault, 'maxPriceDefault' => $this->_config->maxPriceDefault]; try { $this->_zendRest = $this->getServiceLocator()->get('ZendRestClient'); $_hotel = new HotelRestClient($this->_config, $this->_zendRest); $response['hotels'] = $_hotel->findAll(); } catch (\Exception $exception) { /** * We don't pass $exception->getMessage() to the view. * User most likely will not understand what myriad of messages might mean. * * However it is important to log these messages * logging for custom exception is already happening * just before we throw . However, if some other exception is * caught here .. we must log it */ error_log($exception->getMessage()); $response['success'] = false; } return new ViewModel($response); }
public function testFindAll() { $hotels = $this->model->findAll(); $this->assertTrue(is_array($hotels)); $this->assertTrue(count($hotels) == 10); }