lixu / behat-pdo-extension
A simple PDO extension for behat.
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:behat-extension
pkg:composer/lixu/behat-pdo-extension
Requires
- php: >=5.4.0
- ext-pdo: *
- behat/behat: ~3.3.0
This package is auto-updated.
Last update: 2025-09-29 02:06:03 UTC
README
This is a simple PDO extension for behat.
Install
composer require behat/behat lixu/behat-pdo-extension --dev
behat.yml
Add following configuration items to your behat.yml.
default: suites: default: path: %paths.base%/features contexts: - FeatureContext - lixu\BehatPDOExtension\Context\PDOContext extensions: lixu\BehatPDOExtension: dsn: 'mysql:host=127.0.0.1;dbname=test;charset=UTF8' username: 'root' password: ''
Write a scenario
Here is a simple scenario:
Note: You have to implement the "When I eat one apple" step by yourself.
Scenario: Buy a product
Given there are following "fruits":
| name | stock_level |
| apple | 10 |
| orange | 5 |
When I eat one apple
Then there should be following "fruits":
| name | stock_level |
| apple | 9 |
| orange | 5 |
Use PDO in your feature class
If you want to use PDO in your feature class, you can simply extend your feature class from lixu\BehatPDOExtension\Context\PDOContext, and get the PDO instance by $this->getPDO().