Ejemplo n.º 1
0
 public function testRenderShow()
 {
     $trip = new Trip('Praha (test)', 'Brno (test)');
     $service = new TripService($this->entityManager);
     $service->save($trip);
     $presenter = new TripPresenter();
     $request = new PresenterRequest('Trip', 'GET', array('action' => 'show', 'id' => $trip->id));
     $response = $presenter->run($request);
     $this->assertType('Nette\\Application\\RenderResponse', $response);
 }
Ejemplo n.º 2
0
 /**
  * locationsForm submit handler (trip saving).
  * @param Nette\Application\AppForm
  */
 public function submitLocationsForm(AppForm $form)
 {
     $values = $form->values;
     $service = new TripService($this->entityManager);
     try {
         $trip = $service->buildTrip($values['from'], $values['to'], new TripCurlMapper());
         $service->save($trip);
         $this->flashMessage('Trip successfully saved.');
         $this->redirect('Trip:show', array('id' => $trip->id));
     } catch (InvalidStateException $e) {
         $form->addError('Error occurred while getting directions. Please try again later.');
     }
 }