Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

Commit

Permalink
Fix #6 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon authored and Rodrigue Villetard committed Aug 4, 2016
1 parent 416382a commit ecdc2b1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ But, when you are testing a stateless system, chiefly an API, then the resulting


```bash
composer require gorghoa/scenariostate-behat-extension @RC
composer require --dev gorghoa/scenariostate-behat-extension @RC
```

Then update your project's `behat.yml` config file by loading the extension:
Expand Down Expand Up @@ -56,19 +56,12 @@ This interface declare one method to implement: `public function setScenarioStat

```php
use Gorghoa\ScenarioStateBehatExtension\Context\ScenarioStateAwareContext;
use Gorghoa\ScenarioStateBehatExtension\Context\ScenarioStateAwareTrait;
use Gorghoa\ScenarioStateBehatExtension\ScenarioStateInterface;
class FeatureContext implements ScenarioStateAwareContext
{
/**
* @var ScenarioStateInterface
*/
private $scenarioState;
public function setScenarioState(ScenarioStateInterface $scenarioState)
{
$this->scenarioState = $scenarioState;
}
use ScenarioStateAwareTrait;
}
```

Expand Down Expand Up @@ -106,9 +99,9 @@ The easiest way to consume state fragments provided to the scenario's state, is
public function giveBananaToGorilla($monkey, $scenarioBanana, Bonobo $scenarioBonobo)
{
// (note that PHPUnit is here only given as an example, feel free to use any asserter you want)
PHPUnit_Framework_Assert::assertEquals($monkey, 'gorilla');
PHPUnit_Framework_Assert::assertEquals($scenarioBanana, 'Yammy Banana');
PHPUnit_Framework_Assert::assertEquals($scenarioBonobo->getName(), 'Gerard');
\PHPUnit_Framework_Assert::assertEquals($monkey, 'gorilla');
\PHPUnit_Framework_Assert::assertEquals($scenarioBanana, 'Yammy Banana');
\PHPUnit_Framework_Assert::assertEquals($scenarioBonobo->getName(), 'Gerard');
}
```

Expand Down
30 changes: 30 additions & 0 deletions src/Context/ScenarioStateAwareTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the ScenarioStateBehatExtension project.
*
* (c) Rodrigue Villetard <rodrigue.villetard@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Gorghoa\ScenarioStateBehatExtension\Context;

use Gorghoa\ScenarioStateBehatExtension\ScenarioStateInterface;

/**
* @author Vincent Chalamon <vincentchalamon@gmail.com>
*/
trait ScenarioStateAwareTrait
{
private $scenarioState;

/**
* @param ScenarioStateInterface $scenarioState
*/
public function setScenarioState(ScenarioStateInterface $scenarioState)
{
$this->scenarioState = $scenarioState;
}
}

0 comments on commit ecdc2b1

Please sign in to comment.