This is a fork of https://github.com/rkeet/behatch-contexts, which in turn is a fork of https://github.com/Behatch/contexts.
https://github.com/Behatch/contexts is abandoned and archived. Rkeet's fork above fixed a number of issues regarding PHP 8 compatibility:
- Reflection does not have a getClass function anymore
- PHP8 in combination with
symfony/property-access
5.3 means there's no more leniency about accessing elements in an array as an object, and viceversa. It now only works with objects. Fix for that.
We're forking here for two reasons: first, Rkeet's fork could disappear at any point as it seemingly is for his own use. Second, we needed to tag 4.1 as master (but not 4.0) contained the fixes for correctly working with symfony/property-access
.
Behatch contexts provide most common Behat tests.
This extension requires:
- Behat 3+
- Mink
- Mink extension
- Install Composer
- Require the package with Composer:
$ composer require --dev behatch/contexts
- Activate extension by specifying its class in your
behat.yml
:
# behat.yml
default:
# ...
extensions:
Behatch\Extension: ~
- Download the Behatch skeleton with composer:
$ php composer.phar create-project behatch/skeleton
Browser, json, table and rest step need a mink configuration, see Mink extension for more information.
In behat.yml
, enable desired contexts:
default:
suites:
default:
contexts:
- behatch:context:browser
- behatch:context:debug
- behatch:context:system
- behatch:context:json
- behatch:context:table
- behatch:context:rest
- behatch:context:xml
This project is self-tested, you can explore the features directory to find some examples.
browser
- more browser related steps (like mink)timeout
- default timeout
debug
- helper steps for debuggingscreenshotDir
- the directory where store screenshots
system
- shell related stepsroot
- the root directory of the filesystem
json
- JSON related stepsevaluationMode
- javascript "foo.bar" or php "foo->bar"
table
- play with HTML the tablesrest
- send GET, POST, ... requests and test the HTTP headersxml
- XML related steps
For example, if you want to change default directory to screenshots - you can do it this way:
default:
suites:
default:
contexts:
- behatch:context:debug:
screenshotDir: "var"