GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — codeception.github.com/docs/modules/Dbh.markdown at master · captbaritone/codeception.github.com

Expand file tree

/

Dbh.markdown

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
140 lines (82 loc) · 2.92 KB
/

Dbh.markdown

Copy path

File metadata and controls

140 lines (82 loc) · 2.92 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions
layout doc
title Dbh Module - Codeception - Documentation

Dbh Module

For additional reference, please review the source

This module replaces Db module for functional and unit testing, and requires PDO instance to be set. Be default it will cover all database queries into transaction and rollback it afterwards. The database should support nested transactions, in order to make cleanup work as expected.

Pass PDO instance to this module from within your bootstrap file.

In _bootstrap.php:

{% highlight php %}

{% endhighlight %}

This will make all queries in this connection run withing transaction and rolled back afterwards.

Note, that you can't use this module with MySQL. Or perhaps you don't use transactions in your project, then it's ok. Otherwise consider using ORMs like Doctrine, that emulate nested transactions, or switch to Db module.

Status

  • Maintainer: davert
  • Stability: stable
  • Contact: [email protected]

This module despite of it's stability may act unstable because of transactions issue. If test fails with fatal error and transaction is not finished, it may affect other transactions.

Please review the code of non-stable modules and provide patches if you have issues.

Configuration

  • cleanup: true - enable cleanups by covering all queries inside transaction.

Example

modules: 
   enabled: [Dbh]
   config:
      Dbh:
         cleanup: false

Actions

dontSeeInDatabase

Effect is opposite to ->seeInDatabase

Checks if there is no record with such column values in database. Provide table name and column values.

Example:

{% highlight php %}

dontSeeInDatabase('users', array('name' => 'Davert', 'email' => '[email protected]')); {% endhighlight %} Will generate: {% highlight yaml %} sql SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = '[email protected]' {% endhighlight %} Fails if such user was found. * param $table * param array $criteria #### getName __not documented__ #### grabFromDatabase Fetches a single column value from a database. Provide table name, desired column and criteria. Example: {% highlight php %} grabFromDatabase('users', 'email', array('name' => 'Davert')); {% endhighlight %} * version 1.1 * param $table * param $column * param array $criteria * return mixed #### seeInDatabase Checks if a row with given column values exists. Provide table name and column values. Example: {% highlight php %} seeInDatabase('users', array('name' => 'Davert', 'email' => '[email protected]')); {% endhighlight %} Will generate: {% highlight yaml %} sql SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = '[email protected]' {% endhighlight %} Fails if no such user found. * param $table * param array $criteria
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.