Permalink
Browse files

Implement second step definition

$> vim src/Bossa/Bundle/TrainingBundle/Features/Context/StudentContext.php
$> vim app/config/routing.yml

In implementing the visiting pages step we recommend that you take advantage
of expressive route names. That forces us to add the route in the
configuration. Because no class is required, no specs are written. Making sure
you visit the url and that the route exists is not enough though. You need to
know that the status returned is 200. Which takes us to implementing the
controller that will handle that route.
  • Loading branch information...
1 parent 20b84cd commit 9558d9648d9904390951088b843118ade201d202 @MarcelloDuarte MarcelloDuarte committed Sep 14, 2012
Showing with 25 additions and 4 deletions.
  1. +7 −1 app/config/routing.yml
  2. +18 −3 src/Bossa/Bundle/TrainingBundle/Features/Context/StudentContext.php
View
@@ -1,8 +1,14 @@
bossa_bundle_training:
- resource: "@BossaBundleTrainingBundle/Controller/"
+ resource: "@BossaTrainingBundle/Controller/"
type: annotation
prefix: /
+courses:
+ pattern: /
+ defaults: { _controller: BossaTrainingBundle:Courses:list }
+ requirements:
+ _method: GET
+
# Internal routing configuration to handle ESI
#_internal:
# resource: "@FrameworkBundle/Resources/config/routing/internal.xml"
@@ -5,12 +5,17 @@
use Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\MinkExtension\Context\MinkAwareInterface;
+use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Behat\Mink\Mink;
-class StudentContext extends BehatContext implements MinkAwareInterface
+use Symfony\Component\HttpKernel\KernelInterface;
+
+class StudentContext extends BehatContext implements MinkAwareInterface,
+ KernelAwareInterface
{
private $mink;
private $minkParameters;
+ private $kernel;
public function setMink(Mink $mink)
{
@@ -22,6 +27,11 @@ public function setMinkParameters(array $parameters)
$this->minkParameters = $parameters;
}
+ public function setKernel(KernelInterface $kernel)
+ {
+ $this->kernel = $kernel;
+ }
+
/**
* @Given /^there are no courses scheduled$/
*/
@@ -32,9 +42,14 @@ public function thereAreNoCoursesScheduled()
/**
* @When /^I go to the "([^"]*)" page$/
*/
- public function iGoToThePage($arg1)
+ public function iGoToThePage($page)
{
- throw new PendingException();
+ $url = $this->kernel->getContainer()->get('router')->generate(
+ str_replace(' ', '_', $page), array(), false
+ );
+
+ $this->mink->getSession()->visit($url);
+ $this->mink->assertSession()->statusCodeEquals(200);
}
/**

0 comments on commit 9558d96

Please sign in to comment.