lixu/behat-pdo-extension

behat 的简单 PDO 扩展。

安装: 7

依赖: 0

建议者: 0

安全性: 0

星标: 1

关注者: 2

分支: 0

公开问题: 0

类型:behator-extension

dev-master 2017-01-01 07:35 UTC

This package is auto-updated.

Last update: 2024-09-29 04:42:37 UTC


README

这是一个为 behat 设计的简单 PDO 扩展。

安装

composer require behat/behat lixu/behat-pdo-extension --dev

behat.yml

将以下配置项添加到您的 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: ''

编写场景

以下是一个简单场景

注意:您必须自己实现 "当我吃一个苹果" 的步骤。

  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           |

在您的功能类中使用 PDO

如果您想在您的功能类中使用 PDO,您可以直接从 lixu\BehatPDOExtension\Context\PDOContext 扩展您的功能类,并通过 $this->getPDO() 获取 PDO 实例。