Permalink
Browse files

Merge branch '2.2'

# Conflicts:
#	src/Codeception/Module/Db.php
  • Loading branch information...
DavertMik committed May 22, 2017
2 parents 754015a + 42e44f0 commit b54eaf4007484f36145c1dc8c64da1874adbc340
@@ -331,8 +331,8 @@ modules:
- \Helper\Acceptance
```
In order to run browser tests you will need Selenium Server or PhantomJS.
WebDriver module contains a manual on [how to start them](http://codeception.com/docs/modules/WebDriver#Local-Testing).
In order to run browser tests you will need Selenium Server or PhantomJS.
See [WebDriver Module](http://codeception.com/docs/modules/WebDriver) for details.
Please note that actions executed in a browser will behave differently. For instance, `seeElement` won't just check that the element exists on a page,
but it will also check that element is actually visible to the user:
@@ -343,7 +343,7 @@ $I->seeElement('#modal');
```
While WebDriver duplicates the functionality of PhpBrowser, it has its limitations: It can't check headers, since browsers don't provide APIs for that.
WebDriver also adds browser-specific functionality which will be listed in next sections.
WebDriver also adds browser-specific functionality:
#### Wait
@@ -496,4 +496,4 @@ with the help of the [Recorder extension](http://codeception.com/addons#Codecept
Writing acceptance tests with Codeception and PhpBrowser is a good start.
You can easily test your Joomla, Drupal, WordPress sites, as well as those made with frameworks.
Writing acceptance tests is like describing a tester's actions in PHP. They are quite readable and very easy to write.
Don't forget to repopulate the database on each test run.
If you need to access the database, you can use the [Db Module](http://codeception.com/docs/modules/Db).
View
@@ -1,7 +1,7 @@
# Db
Works with SQL database.
Access a database.
The most important function of this module is to clean a database before each test.
That's why this module was added to the global configuration file `codeception.yml`.
@@ -16,12 +16,12 @@ Don't forget to include `CREATE TABLE` statements in the dump.
Supported and tested databases are:
* MySQL
* SQLite (only file)
* SQLite (i.e. just one file)
* PostgreSQL
Supported but not tested.
* MSSQL
* MS SQL
* Oracle
Connection is done by database Drivers, which are stored in the `Codeception\Lib\Driver` namespace.
@@ -34,16 +34,16 @@ if you run into problems loading dumps and cleaning databases.
* stability:
- Mysql: **stable**
- SQLite: **stable**
- Postgres: **beta**
- MSSQL: **alpha**
- PostgreSQL: **beta**
- MS SQL: **alpha**
- Oracle: **alpha**
*Please review the code of non-stable modules and provide patches if you have issues.*
## Config
* dsn *required* - PDO DSN
* user *required* - user to access database
* user *required* - username to access database
* password *required* - password
* dump - path to database dump
* populate: true - whether the the dump should be loaded before the test suite is started
@@ -80,7 +80,7 @@ DELETE FROM `Order`;
```
## Query generation
seeInDatabase, dontSeeInDatabase, seeNumRecords, grabFromDatabase and grabNumRecords methods
`seeInDatabase`, `dontSeeInDatabase`, `seeNumRecords`, `grabFromDatabase` and `grabNumRecords` methods
accept arrays as criteria. WHERE condition is generated using item key as a field name and
item value as a field value.
@@ -95,9 +95,8 @@ Will generate:
```sql
SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com'
```
New addition to 2.1.9 is ability to use LIKE in condition. It is achieved by adding ' like' to column name.
Since version 2.1.9 it's possible to use LIKE in a condition, as shown here:
Example:
```php
<?php
$I->seeInDatabase('users', array('name' => 'Davert', 'email like' => 'davert%'));
View
@@ -70,42 +70,63 @@ Flushes changes to database and performs ->findOneBy() call for current reposito
Performs $em->flush();
### grabFromRepository
### grabEntitiesFromRepository
Selects field value from repository.
Selects entities from repository.
It builds query based on array of parameters.
You can use entity associations to build complex queries.
Example:
``` php
<?php
$email = $I->grabFromRepository('User', 'email', array('name' => 'davert'));
$users = $I->grabEntitiesFromRepository('User', array('name' => 'davert'));
?>
```
* `Available since` 1.1
* `param` $entity
* `param` $field
* `param array` $params
* `return` array
### grabEntitiesFromRepository
### grabEntityFromRepository
Selects entities from repository.
Selects a single entity from repository.
It builds query based on array of parameters.
You can use entity associations to build complex queries.
Example:
``` php
<?php
$users = $I->grabEntitiesFromRepository('User', array('name' => 'davert'));
$user = $I->grabEntityFromRepository('User', array('id' => '1234'));
?>
```
* `Available since` 1.1
* `param` $entity
* `param array` $params
* `return` array
### grabFromRepository
Selects field value from repository.
It builds query based on array of parameters.
You can use entity associations to build complex queries.
Example:
``` php
<?php
$email = $I->grabFromRepository('User', 'email', array('name' => 'davert'));
?>
```
* `Available since` 1.1
* `param` $entity
* `param` $field
* `param array` $params
* `return` array
View
@@ -7,30 +7,30 @@ New generation Selenium WebDriver module.
### Selenium
To run Selenium Server you will need Java and Chrome or Firefox browser installed.
To run Selenium Server you need [Java](https://www.java.com/) as well as Chrome or Firefox browser installed.
1. Download [Selenium Server](http://docs.seleniumhq.org/download/)
2. For Chrome browser install [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/getting-started), for Firefox browser install [GeckoDriver](https://github.com/mozilla/geckodriver).
3. Launch the server: `java -jar selenium-server-standalone-3.xx.xxx.jar`. To locate Chromedriver binary use `-Dwebdriver.chrome.driver=./chromedriver` option. For Geckodriver use `-Dwebdriver.gecko.driver=./geckodriver`.
4. Configure this module (in acceptance.suite.yml) by setting url and browser:
1. Download [Selenium Standalone Server](http://docs.seleniumhq.org/download/)
2. To use Chrome, install [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/getting-started). To use Firefox, install [GeckoDriver](https://github.com/mozilla/geckodriver).
3. Launch the Selenium Server: `java -jar selenium-server-standalone-3.xx.xxx.jar`. To locate Chromedriver binary use `-Dwebdriver.chrome.driver=./chromedriver` option. For Geckodriver use `-Dwebdriver.gecko.driver=./geckodriver`.
4. Configure this module (in `acceptance.suite.yml`) by setting `url` and `browser`:
```yaml
modules:
enabled:
- WebDriver:
url: 'http://localhost/'
browser: chrome
browser: chrome # 'chrome' or 'firefox'
```
### PhantomJS
PhantomJS is a headless alternative to Selenium Server that implements
PhantomJS is a [headless browser](https://en.wikipedia.org/wiki/Headless_browser) alternative to Selenium Server that implements
[the WebDriver protocol](https://code.google.com/p/selenium/wiki/JsonWireProtocol).
It allows you to run Selenium tests on a server without a GUI installed.
1. Download [PhantomJS](http://phantomjs.org/download.html)
2. Run PhantomJS in WebDriver mode: `phantomjs --webdriver=4444`
3. Configure this module (in acceptance.suite.yml) by setting url and `phantomjs` as browser:
3. Configure this module (in `acceptance.suite.yml`) by setting url and `phantomjs` as browser:
```yaml
modules:
@@ -40,6 +40,8 @@ It allows you to run Selenium tests on a server without a GUI installed.
browser: phantomjs
```
Since PhantomJS doesn't give you any visual feedback, it's probably a good idea to install [Codeception\Extension\Recorder](http://codeception.com/extensions#CodeceptionExtensionRecorder) which gives you screenshots of how PhantomJS "sees" your pages.
### Headless Selenium in Docker
Docker can ship Selenium Server with all its dependencies and browsers inside a single container.
@@ -121,7 +123,7 @@ you should use a tunnel application provided by a service.
* `browser` *required* - Browser to launch.
* `host` - Selenium server host (127.0.0.1 by default).
* `port` - Selenium server port (4444 by default).
* `restart` - Set to false (default) to share browser window between tests, or set to true to create a separate window for each test.
* `restart` - Set to `false` (default) to use the same browser window for all tests, or set to `true` to create a new window for each test. In any case, when all tests are finished the browser window is closed.
* `window_size` - Initial window size. Set to `maximize` or a dimension in the format `640x480`.
* `clear_cookies` - Set to false to keep cookies, or set to true (default) to delete all cookies between tests.
* `wait` - Implicit wait (default 0 seconds).
View
@@ -67,17 +67,16 @@ extensions:
[See Source](https://github.com/Codeception/Codeception/blob/2.3/ext/Recorder.php)
Saves screenshots of each step in acceptance tests and shows them as a slideshow.
Saves a screenshot of each step in acceptance tests and shows them as a slideshow on one HTML page.
Activated only for suites with WebDriver module enabled.
![recorder](http://codeception.com/images/recorder.gif)
Slideshows saves are saved into `tests/_output/record_*` directories.
Open `index.html` to see the slideshow.
The screenshots are saved to `tests/_output/record_*` directories, open `index.html` to see them as a slideshow.
#### Installation
Add to list of enabled extensions
Add this to the list of enabled extensions in `codeception.yml` or `acceptance.suite.yml`:
``` yaml
extensions:
@@ -87,8 +86,8 @@ extensions:
#### Configuration
* `delete_successful` (default: true) - delete records for successfully passed tests (log only failed and errored)
* `module` (default: WebDriver) - which module for screenshots to use. Set `AngularJS` if you want to use it with AngularJS module. Generally, module should implement `Codeception\Lib\Interfaces\ScreenshotSaver` interface.
* `delete_successful` (default: true) - delete screenshots for successfully passed tests (i.e. log only failed and errored tests).
* `module` (default: WebDriver) - which module for screenshots to use. Set `AngularJS` if you want to use it with AngularJS module. Generally, the module should implement `Codeception\Lib\Interfaces\ScreenshotSaver` interface.
#### Examples:
@@ -98,7 +97,7 @@ extensions:
enabled:
Codeception\Extension\Recorder:
module: AngularJS # enable for Angular
delete_successful: false # show successful reports
delete_successful: false # keep screenshots of successful tests
```
View
@@ -13,17 +13,16 @@
use Codeception\Util\Template;
/**
* Saves screenshots of each step in acceptance tests and shows them as a slideshow.
* Saves a screenshot of each step in acceptance tests and shows them as a slideshow on one HTML page.
* Activated only for suites with WebDriver module enabled.
*
* ![recorder](http://codeception.com/images/recorder.gif)
*
* Slideshows saves are saved into `tests/_output/record_*` directories.
* Open `index.html` to see the slideshow.
* The screenshots are saved to `tests/_output/record_*` directories, open `index.html` to see them as a slideshow.
*
* #### Installation
*
* Add to list of enabled extensions
* Add this to the list of enabled extensions in `codeception.yml` or `acceptance.suite.yml`:
*
* ``` yaml
* extensions:
@@ -33,8 +32,8 @@
*
* #### Configuration
*
* * `delete_successful` (default: true) - delete records for successfully passed tests (log only failed and errored)
* * `module` (default: WebDriver) - which module for screenshots to use. Set `AngularJS` if you want to use it with AngularJS module. Generally, module should implement `Codeception\Lib\Interfaces\ScreenshotSaver` interface.
* * `delete_successful` (default: true) - delete screenshots for successfully passed tests (i.e. log only failed and errored tests).
* * `module` (default: WebDriver) - which module for screenshots to use. Set `AngularJS` if you want to use it with AngularJS module. Generally, the module should implement `Codeception\Lib\Interfaces\ScreenshotSaver` interface.
*
*
* #### Examples:
@@ -44,7 +43,7 @@
* enabled:
* Codeception\Extension\Recorder:
* module: AngularJS # enable for Angular
* delete_successful: false # show successful reports
* delete_successful: false # keep screenshots of successful tests
* ```
*
*/
@@ -11,7 +11,7 @@
use Codeception\TestInterface;
/**
* Works with SQL database.
* Access a database.
*
* The most important function of this module is to clean a database before each test.
* That's why this module was added to the global configuration file `codeception.yml`.
@@ -26,12 +26,12 @@
* Supported and tested databases are:
*
* * MySQL
* * SQLite (only file)
* * SQLite (i.e. just one file)
* * PostgreSQL
*
* Also available:
*
* * MSSQL
* * MS SQL
* * Oracle
*
* Connection is done by database Drivers, which are stored in the `Codeception\Lib\Driver` namespace.
@@ -41,7 +41,7 @@
* ## Config
*
* * dsn *required* - PDO DSN
* * user *required* - user to access database
* * user *required* - username to access database
* * password *required* - password
* * dump - path to database dump
* * populate: false - whether the the dump should be loaded before the test suite is started
@@ -145,7 +145,7 @@
* ```
* ## Query generation
*
* seeInDatabase, dontSeeInDatabase, seeNumRecords, grabFromDatabase and grabNumRecords methods
* `seeInDatabase`, `dontSeeInDatabase`, `seeNumRecords`, `grabFromDatabase` and `grabNumRecords` methods
* accept arrays as criteria. WHERE condition is generated using item key as a field name and
* item value as a field value.
*
@@ -160,9 +160,8 @@
* ```sql
* SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com'
* ```
* New addition to 2.1.9 is ability to use LIKE in condition. It is achieved by adding ' like' to column name.
* Since version 2.1.9 it's possible to use LIKE in a condition, as shown here:
*
* Example:
* ```php
* <?php
* $I->seeInDatabase('users', array('name' => 'Davert', 'email like' => 'davert%'));
Oops, something went wrong.

0 comments on commit b54eaf4

Please sign in to comment.