Writing PHP code based on Gherkin
We will need PHP programs to represent the features and scenarios we created using Gherkin. The Behat framework will follow the features and scenarios we created in the previous section, but it will also look for PHP code that represents each feature and scenario. Within this PHP code, we can add any custom logic we want to interpret the features and scenarios into programs. Create the following files that the Behat framework needs to run our features and scenarios:
- First, we need to create a new context class. A context class is what Behat uses to represent Gherkin features into PHP programs.Create the following file with the content shown:
codebase/behat/features/bootstrap/HomeContext.php
<?php use Behat\Behat\Tester\Exception\PendingException; class HomeContext implements \Behat\Behat\Context\Context { }
- Then, after creating the
HomeContext.php
class, we also need to tell Behat that we have a...