ludofleury
7/18/2012 - 5:14 PM

Behat FeatureContext class using atoum asserter

Behat FeatureContext class using atoum asserter

<?php

// ...

class FeatureContext extends BehatContext
{ //...

    /**
     * @Then /^I should get a good response using my favorite "([^"]*)"$/
     */
    public function goodResponse($contentType)
    {
        $this->assert
            ->integer($response->getStatusCode())
                ->isIdenticalTo(200)
            ->string($response->getHeader('Content-Type'))
                ->isIdenticalTo($contentType);
    }
}
<?php

use Behat\Behat\Context\ClosuredContextInterface,
    Behat\Behat\Context\TranslatedContextInterface,
    Behat\Behat\Context\BehatContext,
    Behat\Behat\Exception\PendingException,
    Behat\Behat\Context\Step;
use Behat\Gherkin\Node\PyStringNode,
    Behat\Gherkin\Node\TableNode;

use mageekguy\atoum\asserter as Atoum; # import the atoum asserter

require_once __DIR__ . '/../../vendor/mageekguy/atoum/classes/autoloader.php';

/**
 * Features context.
 */
class FeatureContext extends BehatContext
{
    private $assert;

    /**
     * Initializes context.
     * Every scenario gets it's own context object.
     *
     * @param   array   $parameters     context parameters (set them up through behat.yml)
     */
    public function __construct(array $parameters)
    {
        $this->assert = new Atoum\generator();
    }
}