Permalink
Browse files

Finish describing controller

$> vim spec/Bossa/Bundle/TrainingBundle/Controller/CoursesController.php
$> bin/phpspec run
$> vim src/Bossa/Bundle/TrainingBundle/Controller/CoursesController.php
$> bin/phpspec run

We add final 3rd example to the controller specification. Which describes
how we bring the data into the view.
  • Loading branch information...
everzet committed Sep 14, 2012
1 parent b6bdd50 commit dbda4adfa324114bed3e8201b24892e5612f85ff
@@ -19,4 +19,14 @@ function it_should_render_list_of_courses()
array('courses' => array())
)->duringAction('list');
}
+
+ function it_should_pass_courses_from_domain_to_the_view($repository)
+ {
+ $repository->findAll()->willReturn(array('item1', 'item2'));
+
+ $this->controller->shouldRender(
+ 'BossaTrainingBundle:Courses:list.html.twig',
+ array('courses' => array('item1', 'item2'))
+ )->duringAction('list');
+ }
}
@@ -9,9 +9,14 @@ class CoursesController extends Controller
{
public function listAction()
{
+ $courses = $this->getDoctrine()
+ ->getManager()
+ ->getRepository('Bossa:Course')
+ ->findAll();
+
return $this->render(
'BossaTrainingBundle:Courses:list.html.twig',
- array('courses' => array())
+ array('courses' => $courses)
);
}
}

0 comments on commit dbda4ad

Please sign in to comment.