init
This commit is contained in:
35
vendor/codeception/base/.gitattributes
vendored
Normal file
35
vendor/codeception/base/.gitattributes
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Denote text files explicitly, normalize line endings to LF on checkin and forbid conversion to CRLF on checkout
|
||||
# Without eol=lf, core.autocrlf might come in effect
|
||||
*.html eol=lf diff=html
|
||||
*.css eol=lf
|
||||
*.js eol=lf
|
||||
*.sql eol=lf
|
||||
*.php eol=lf diff=php
|
||||
*.yml eol=lf
|
||||
*.xml eol=lf
|
||||
*.dist eol=lf
|
||||
*.conf eol=lf
|
||||
*.json eol=lf
|
||||
*.lock eol=lf
|
||||
|
||||
# Denote all files that are truly binary and should not be modified.
|
||||
# Git would detect them automatically, but this will save the autodetection
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
*.gif binary
|
||||
*.ico binary
|
||||
*.zip binary
|
||||
*.jar binary
|
||||
*.docx binary
|
||||
*.docx binary
|
||||
*.dot binary
|
||||
*.xls binary
|
||||
*.otf binary
|
||||
*.eot binary
|
||||
*.ttf binary
|
||||
*.ttf binary
|
||||
*.woff binary
|
||||
*.phar binary
|
||||
41
vendor/codeception/base/.gitignore
vendored
Normal file
41
vendor/codeception/base/.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
.idea
|
||||
.roboci
|
||||
composer.phar
|
||||
composer.lock
|
||||
vendor
|
||||
package/codecept.phar
|
||||
package/codecept5.phar
|
||||
package/php54/codecept.phar
|
||||
tests/support/_generated
|
||||
tests/data/app/db
|
||||
tests/data/sandbox
|
||||
tests/_output/*
|
||||
tests/data/included/_log/*
|
||||
tests/data/included/jazz/tests/_log/*
|
||||
tests/data/included/jazz/pianist/tests/_log/*
|
||||
tests/data/included/shire/tests/_log/*
|
||||
tests/data/included_w/_log/*
|
||||
tests/data/included_w/src/foo/AcmePack/tests/_log/*
|
||||
tests/data/included_w/src/foo/AcmePack/tests/_support/_generated/*
|
||||
tests/data/included_mix/src/foo/AcmePack/tests/_log/*
|
||||
tests/data/included_mix/src/foo/AcmePack/tests/_support/_generated/*
|
||||
tests/data/included_mix/_log/*
|
||||
tests/data/included_mix/support/_generated/*
|
||||
tests/data/claypit/tests/_log/*
|
||||
tests/data/claypit/tests/_output/*
|
||||
tests/data/claypit/tests/_support/_generated/*
|
||||
tests/data/claypit/c3tmp
|
||||
tests/data/included/jazz/pianist/tests/_helpers/_generated/TestGuyActions.php
|
||||
tests/data/included/jazz/tests/_helpers/_generated/TestGuyActions.php
|
||||
tests/data/included/shire/tests/_helpers/_generated/TestGuyActions.php
|
||||
tests/data/included_w/src/bar/Sub/EwokPack/tests/_support/_generated/UnitTesterActions.php
|
||||
tests/data/included_w/src/bar/ToastPack/tests/_support/_generated/UnitTesterActions.php
|
||||
tests/data/included_w/src/foo/AcmePack/tests/_support/_generated/UnitTesterActions.php
|
||||
tests/data/params/tests/_support/_generated/DummyTesterActions.php
|
||||
tests/data/exception_in_before/tests/_support/_generated/UnitTesterActions.php
|
||||
tests/data/exception_in_before/tests/_output/
|
||||
tests/data/bundled_suites/_support/_generated/UnitTesterActions.php
|
||||
tests/data/bundled_suites/_output/
|
||||
.DS_Store
|
||||
robo.phar
|
||||
.env
|
||||
133
vendor/codeception/base/.travis.yml
vendored
Normal file
133
vendor/codeception/base/.travis.yml
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
sudo: false
|
||||
|
||||
language: php
|
||||
matrix:
|
||||
fast_finish: true
|
||||
php:
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
env:
|
||||
global:
|
||||
- XDEBUG=
|
||||
- SUITES=
|
||||
- FXP=
|
||||
- PECL=
|
||||
- TEST_PATH='framework-tests'
|
||||
- SYMFONY_DEPRECATIONS_HELPER=weak
|
||||
matrix:
|
||||
- FRAMEWORK=Codeception SUITES=cli,unit TEST_PATH=. XDEBUG=1 PECL=mongodb
|
||||
- FRAMEWORK=Yii2 TEST_REPO="https://github.com/Codeception/yii2-tests"
|
||||
- FRAMEWORK=Symfony VERSION=2.8 TEST_REPO='-b 2.1 https://github.com/Codeception/symfony-demo.git' SUITES=functional TEST_PATH=framework-tests/src/AppBundle
|
||||
- FRAMEWORK=Symfony VERSION=3.4 TEST_REPO='--recurse-submodules https://github.com/Naktibalda/codeception-symfony-tests'
|
||||
- FRAMEWORK=Symfony VERSION=4 TEST_REPO='https://github.com/Codeception/symfony-demo.git' SUITES=functional,unit
|
||||
- FRAMEWORK=Lumen TEST_REPO='-b codeception-2.2 https://github.com/codeception/codeception-lumen-sample.git'
|
||||
- FRAMEWORK=Laravel TEST_REPO='-b codeception-2.3 https://github.com/codeception/codeception-laravel5-sample.git'
|
||||
- FRAMEWORK=Phalcon TEST_REPO=https://github.com/Codeception/phalcon-demo.git
|
||||
- FRAMEWORK=Zend1 TEST_REPO='-b 2.2 --recurse-submodules https://github.com/Naktibalda/codeception-zf1-tests'
|
||||
- FRAMEWORK=Zend2 TEST_REPO='-b 2.2 --recurse-submodules https://github.com/Naktibalda/codeception-zf2-tests' SUITES=functional
|
||||
- FRAMEWORK=ZendExpressive TEST_REPO='-b 2.2 --recurse-submodules https://github.com/Naktibalda/codeception-zend-expressive-tests' SUITES=functional
|
||||
matrix:
|
||||
include:
|
||||
- php: 7.1
|
||||
env: FRAMEWORK=Codeception SUITES=cli,unit,coverage TEST_PATH=. XDEBUG=1 PECL=mongodb
|
||||
exclude:
|
||||
- php: 7.1
|
||||
env: FRAMEWORK=Codeception SUITES=cli,unit TEST_PATH=. XDEBUG=1 PECL=mongodb
|
||||
- php: 7.0
|
||||
env: FRAMEWORK=Symfony VERSION=2.8 TEST_REPO='-b 2.1 https://github.com/Codeception/symfony-demo.git' SUITES=functional TEST_PATH=framework-tests/src/AppBundle
|
||||
- php: 7.1
|
||||
env: FRAMEWORK=Symfony VERSION=2.8 TEST_REPO='-b 2.1 https://github.com/Codeception/symfony-demo.git' SUITES=functional TEST_PATH=framework-tests/src/AppBundle
|
||||
- php: 7.2
|
||||
env: FRAMEWORK=Symfony VERSION=2.8 TEST_REPO='-b 2.1 https://github.com/Codeception/symfony-demo.git' SUITES=functional TEST_PATH=framework-tests/src/AppBundle
|
||||
- php: 5.6
|
||||
env: FRAMEWORK=Symfony VERSION=3.4 TEST_REPO='--recurse-submodules https://github.com/Naktibalda/codeception-symfony-tests'
|
||||
- php: 7.0
|
||||
env: FRAMEWORK=Symfony VERSION=3.4 TEST_REPO='--recurse-submodules https://github.com/Naktibalda/codeception-symfony-tests'
|
||||
- php: 5.6
|
||||
env: FRAMEWORK=Symfony VERSION=4 TEST_REPO='https://github.com/Codeception/symfony-demo.git' SUITES=functional,unit
|
||||
- php: 7.0
|
||||
env: FRAMEWORK=Symfony VERSION=4 TEST_REPO='https://github.com/Codeception/symfony-demo.git' SUITES=functional,unit
|
||||
# - php: 7.1
|
||||
# env: FRAMEWORK=ZendExpressive TEST_REPO='-b 2.2 --recurse-submodules https://github.com/Naktibalda/codeception-zend-expressive-tests' functional
|
||||
# - php: 7.2
|
||||
# env: FRAMEWORK=ZendExpressive TEST_REPO='-b 2.2 --recurse-submodules https://github.com/Naktibalda/codeception-zend-expressive-tests' functional
|
||||
addons:
|
||||
postgresql: "9.2"
|
||||
|
||||
branches:
|
||||
except:
|
||||
- gh-pages
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- vendor
|
||||
- $HOME/.composer/cache
|
||||
|
||||
services:
|
||||
- mongodb
|
||||
- rabbitmq
|
||||
- postgresql
|
||||
- redis
|
||||
|
||||
before_install:
|
||||
- '$(php PruneTest.php)'
|
||||
- '[[ !(-z "$XDEBUG") ]] || phpenv config-rm xdebug.ini'
|
||||
- export INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||
- echo memory_limit = -1 >> $INI
|
||||
install:
|
||||
- '[[ -z "$CI_USER_TOKEN" ]] || composer config github-oauth.github.com ${CI_USER_TOKEN};'
|
||||
# Add extensions
|
||||
- '[[ -z "$PECL" ]] || (yes "" | pecl install -f $PECL)'
|
||||
# Clone test repository
|
||||
- '[[ "$FRAMEWORK" == "Codeception" ]] || git clone -q --depth=1 $TEST_REPO framework-tests'
|
||||
- '[[ "$FRAMEWORK" == "Codeception" ]] || git --git-dir framework-tests/.git log -n 1'
|
||||
- '[[ "$FRAMEWORK" != "Codeception" ]] || composer require mongodb/mongodb --no-update'
|
||||
- '[[ -z "$FXP" ]] || composer global require "fxp/composer-asset-plugin:~1.3.1"'
|
||||
- '[[ "$FRAMEWORK" != "Symfony" ]] || composer require symfony/finder=~$VERSION --no-update --ignore-platform-reqs'
|
||||
- '[[ "$FRAMEWORK" != "Symfony" ]] || composer require symfony/yaml=~$VERSION --no-update --ignore-platform-reqs'
|
||||
- '[[ "$FRAMEWORK" != "Symfony" ]] || composer require symfony/console=~$VERSION --no-update --ignore-platform-reqs'
|
||||
- '[[ "$FRAMEWORK" != "Symfony" ]] || composer require symfony/event-dispatcher=~$VERSION --no-update --ignore-platform-reqs'
|
||||
- '[[ "$FRAMEWORK" != "Symfony" ]] || composer require symfony/css-selector=~$VERSION --no-update --ignore-platform-reqs'
|
||||
- '[[ "$FRAMEWORK" != "Symfony" ]] || composer require symfony/dom-crawler=~$VERSION --no-update --ignore-platform-reqs'
|
||||
- '[[ "$FRAMEWORK" != "Symfony" ]] || composer require symfony/browser-kit=~$VERSION --no-update --ignore-platform-reqs'
|
||||
- '[[ "$FRAMEWORK" != "Symfony" ]] || composer require symfony/browser-kit=~$VERSION --no-update --ignore-platform-reqs'
|
||||
# Phalcon
|
||||
- '[[ "$FRAMEWORK" != "Phalcon" ]] || git clone -q --depth=1 https://github.com/phalcon/cphalcon.git'
|
||||
- '[[ "$FRAMEWORK" != "Phalcon" ]] || (cd cphalcon/build; bash ./install --phpize $(phpenv which phpize) --php-config $(phpenv which php-config) &>/dev/null && phpenv config-add ../tests/_ci/phalcon.ini &> /dev/null)'
|
||||
# Symfony
|
||||
#- '[[ "$FRAMEWORK$VERSION" != "Symfony3" ]] || composer require -d framework-tests symfony/symfony=~$VERSION --no-update'
|
||||
- '[[ -z "$FRAMEWORK" ]] || composer install'
|
||||
- '[[ "$FRAMEWORK" == "Codeception" ]] || [[ -z "$FRAMEWORK" ]] || composer update -d framework-tests --no-dev --prefer-dist'
|
||||
before_script:
|
||||
- '[[ "$TRAVIS_PHP_VERSION" == 7.* ]] || echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini'
|
||||
# preparing databases
|
||||
- '[[ "$FRAMEWORK" != "Codeception" ]] || mysql -e "create database codeception_test;"'
|
||||
- '[[ "$FRAMEWORK" != "Codeception" ]] || psql -c "create database codeception_test;" -U postgres'
|
||||
- '[[ "$FRAMEWORK" != "Symfony" ]] || mysql -e "create database symfony_test;"'
|
||||
# starting demo servers
|
||||
- '[[ "$FRAMEWORK" != "Codeception" ]] || php -S 127.0.0.1:8000 -t tests/data/app >/dev/null 2>&1 &'
|
||||
- '[[ "$FRAMEWORK" != "Codeception" ]] || php -S 127.0.0.1:8010 -t tests/data >/dev/null 2>&1 &'
|
||||
# Phalcon
|
||||
- '[[ "$FRAMEWORK" != "Phalcon" ]] || mysql -e "CREATE DATABASE phalcon_demo CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"'
|
||||
- '[[ "$FRAMEWORK" != "Phalcon" ]] || cat framework-tests/schemas/phalcon_demo.sql | mysql phalcon_demo'
|
||||
# Laravel 5
|
||||
- '[[ "$FRAMEWORK" != "Laravel" ]] || touch framework-tests/storage/testing.sqlite'
|
||||
- '[[ "$FRAMEWORK" != "Laravel" ]] || php framework-tests/artisan migrate --env=testing --database=sqlite_testing --force'
|
||||
# Lumen
|
||||
- '[[ "$FRAMEWORK" != "Lumen" ]] || cp framework-tests/.env.testing framework-tests/.env'
|
||||
- '[[ "$FRAMEWORK" != "Lumen" ]] || touch framework-tests/storage/testing.sqlite'
|
||||
- '[[ "$FRAMEWORK" != "Lumen" ]] || php framework-tests/artisan migrate --database=testing --force'
|
||||
# Symfony
|
||||
- '[[ "$FRAMEWORK$VERSION" != "Symfony2.8" ]] || php framework-tests/app/console doctrine:schema:create -n --env test'
|
||||
- '[[ "$FRAMEWORK$VERSION" != "Symfony2.8" ]] || php framework-tests/app/console doctrine:fixtures:load -n --env test'
|
||||
- '[[ "$FRAMEWORK$VERSION" != "Symfony3.4" ]] || php framework-tests/bin/console doctrine:schema:update --force -n'
|
||||
# ZF2
|
||||
- '[[ "$FRAMEWORK" != "Zend2" ]] || mysql -e "create database zf2_test;"'
|
||||
- '[[ "$FRAMEWORK" != "Zend2" ]] || php framework-tests/vendor/bin/doctrine-module orm:schema-tool:create'
|
||||
# Build
|
||||
- '[[ -z "$FRAMEWORK" ]] || php codecept build -c $TEST_PATH'
|
||||
script:
|
||||
# Run tests if $FRAMEWORK is not empty
|
||||
- '[[ -z "$FRAMEWORK" ]] || php codecept run $SUITES -c $TEST_PATH'
|
||||
346
vendor/codeception/base/CHANGELOG-2.0.md
vendored
Normal file
346
vendor/codeception/base/CHANGELOG-2.0.md
vendored
Normal file
@@ -0,0 +1,346 @@
|
||||
#### 2.0.15
|
||||
|
||||
* [Phalcon1] Fixed getting has more than one field by @sergeyklay #2010.
|
||||
* [PhpBrowser][Frameworks] Compute relative URIs against the effective request URI when there is a redirect. #2058 #2057
|
||||
* [PhpBrowser] Fixed Guzzle Connector headers by @valeriyaslovikovskaya #2028
|
||||
* [Symfony2] kernel is created for every test by @quaninte #2020
|
||||
* [WebDriver] Added WebDriver init settings `connection_timeout` and `request_timeout` by @n8whnp #2065
|
||||
* [MongoDb] added ability to change the database by @clarkeash #2015
|
||||
* [Doctrine2] Fixed issues after first request is made #2025 @AlexStansfield
|
||||
* [REST] Improved JsonArray to compare repeated values correctly by @Naktibalda #2070
|
||||
* [MongoDb] Remove not necessary config fields `user` and `password` by @nicklasos
|
||||
* `Stub::construct` can be used to set private/protected properties by @Naktibalda #2082
|
||||
* Fixed @before and @after hooks in Cest. _before method was executed on each call of method specified in @before annotation *2015-06-15*
|
||||
* [Laravel5] Fix for domains in `route()` helper. See #2000. *2015-06-04*
|
||||
* [REST] Fixed sending `JsonSerializable` object on POST by @Naktibalda and @andersonamuller. See #1988 #1994
|
||||
* [MongoDb] escaped filename shell argument for loading MongoDB by @christoph-hautzinger. #1998 *2015-06-03*
|
||||
* [Lumen] **Module added** by @janhenkgerritsen
|
||||
|
||||
#### 2.0.14
|
||||
|
||||
* Improved output *2015-05-22*
|
||||
* data providers print simplified
|
||||
* output respects console size with `tput` and tries to fit area
|
||||
* non-interactive environments for `tput` are ignored
|
||||
* [Frameworks][PhpBrowser][Symfony2] Fields are passed as PHP-array on form submission the same way as `Symfony\Component\DomCrawler\Form->getPhpValues()` does. Fixes fails of Symfony form tests *2015-05-22*
|
||||
* [Laravel4] Fixed bug with filters. See #1810. *2015-05-21*
|
||||
* [PhpBrowser][Frameworks] Fixed working associative array form fields (like `FooBar[bar]`). Fixes regression #1923 by @davertmik and @zbateson.
|
||||
* [PhpBrowser][Frameworks] Fixed cloning form nodes Codeception\Lib\InnerBrowser::getFormFromCrawler(): ID XXX already defined *2015-05-13*
|
||||
* [Laravel4] [Laravel5] Improved error message for `amOnRoute` and `amOnAction` methods if route or action does not exist *2015-05-04*
|
||||
* [Laravel4] Fixed issue with session configuration *2015-05-01*
|
||||
* [Laravel4] Partial rewrite of module *2015-05-01*
|
||||
* Added `getApplication()` method
|
||||
* Added `seeFormHasErrors()`, `seeFormErrorMessages(array $bindings)` and `seeFormErrorMessage($key, $errorMessage)` methods
|
||||
* Deprecated `seeSessionHasErrors()` and `seeSessionErrorMessage(array $bindings)` methods.
|
||||
* fixed stderr output messages in PHPStorm console *2015-04-26*
|
||||
* Allow following symlinks when searching for tests by @nechutny
|
||||
* Fixed `g:scenarios --single-file` missing linebreaks between scenarios by @Zifius Parially fixes #1866
|
||||
* [Frameworks][PhpBrowser] Fixed errors like `[ErrorException] Array to string conversion` when using strict locators. Fix by @neochief #1881
|
||||
* [Frameworks][PhpBrowser] Fix for URLs with query parameters not properly constructed for GET form submissions by @zbateson Fixes #1891
|
||||
* [Facebook] Updated Facebook SDK to 4.0 by @enginvardar. See #1896.
|
||||
* [DB] Quote table name in `Db::getPrimaryKeyColumn` and `Db::deleteQueryMethods` by @Naktibalda. See #1912
|
||||
* [Silex] Can be used for API functional testing. Improvement by @arduanov See #1945
|
||||
* [Doctrine2] Added new config option `symfony_em_service` to specify service name for Doctrine entity manager in Symfony DIC by @danieltuwien #1915
|
||||
* [Db] Reversed order of removing records with foreign keys created by `haveInDatabase`. Fixes #1942 by @satahippy
|
||||
* [Db] Quote names in PostgreSQL queries. Fix #1916 by @satahippy
|
||||
* [ZF1] Various improvements by @Naktibalda See #1924
|
||||
* [ZF2][ZF2] Improved passing request headers by @Naktibalda
|
||||
* [Phalcon1] Improved dependency injector container check by @sergeyklay #1967
|
||||
* [Yii2] Enabled logging by @TriAnMan #1539
|
||||
* Attribute `feature` added to xml reports in `Codeception\TestCase\Test` test report by @tankist. See #1964
|
||||
* Fixed #1779 by @Naktibalda
|
||||
* ...special thanks to @Naktibalda for creating demo [ZF1](https://github.com/Naktibalda/codeception-zf1-tests) and [ZF2](https://github.com/Naktibalda/codeception-zf2-tests) applications with api tests examples.
|
||||
|
||||
#### 2.0.13
|
||||
|
||||
* Updated to PHPUnit 4.6
|
||||
* [Db] fixed regression introduced in 2.0.11. `haveInDatabase` works in PostgreSQL on tables with 'id' as primary key. Fix by @akireikin #1846 #1761
|
||||
* added `--no-rebuild` option to disable automatic actor classes rebuilds *2015-04-24*
|
||||
* suppressed warnings on failed actor classes auto-rebuilds
|
||||
* enable group listener for grouping with annotation by @litpuvn Fixes #1830
|
||||
* unix terminals output improved by calculating screen size. Done by @DexterHD See #1858
|
||||
* [Yii2] Remove line to activate request parsers by @m8rge #1843
|
||||
* [PhpBrowser][Frameworks] Various `fillField`/`submitForm` improvements by @zbateson See #1840. Fixes #1828, #1689
|
||||
* Allow following symlinks when searching for tests by @nechutny #1862
|
||||
|
||||
#### 2.0.12
|
||||
|
||||
* [Laravel5] Fix for undefined method `Symfony\Component\HttpFoundation\Request::route()` by @janhenkgerritsen
|
||||
* [Yii2] Fix https support and verbose output added by @TriAnMan See #1770
|
||||
* [Yii2] `haveRecord` to insert insert unsafe attributes by @nkovacs. Fixes #1775
|
||||
* [Asserts] `assertSame` and `assertNotSame` added by @hidechae *2015-04-03*
|
||||
* [Laravel5] Add `packages` option for application packages by @jonathantorres #1782
|
||||
* [PhpBrowser][WebDriver][Frameworks] `seeInFormFields` method added for checking multiple form field values. See #1795 *2015-04-03*
|
||||
* [ZF2] Fixed setting Content-Type header by @Gorp See #1796 *2015-04-03*
|
||||
* [Yii2] Pass body request into yii2 request, allowing to send Xml payload by @m8rge. See #1806
|
||||
* Fixed conditional assertions firing TEST_AFTER event by @zbateson. Issues #1647 #1354 and #1111 *2015-04-03*
|
||||
* Fixing mocking Laravel models by removing `__mocked` property in classes created with Stub by @EVODelavega See #1785 *2015-04-03*
|
||||
* [WebDriver] `submitForm` allows array parameter values by @zbateson *2015-04-03*
|
||||
* [SOAP] Added `framework_collect_buffer` option to disable buffering output by @Noles *2015-04-03*
|
||||
* [Laravel4] added to run artisan commands by @bgetsug *2015-04-03*
|
||||
* [AMQP] add a routing key to a push to exchange by @jistok *2015-04-03*
|
||||
* Interactive console updated to work with namespaces by @jistok *2015-04-03*
|
||||
* [PhpBrowser] added deleteHeader method by @zbateson *2015-04-03*
|
||||
* Disabling loading of bootstrap files by setting `bootstrap: false` in globall settings or inside suite config. Fixes #1813 *2015-04-03*
|
||||
|
||||
#### 2.0.11
|
||||
|
||||
* Updated to PHPUnit 4.5 *2015-02-23*
|
||||
* [Laravel5] module added by @janhenkgerritsen *2015-02-23*
|
||||
* Fixed problem with extensions being always loaded with default options by @sjableka. Fixes #1716 *2015-02-23*
|
||||
* [Db] Cleanup now works for tables with primary is not named 'id'. Fix by @KennethVeipert See #1727 *2015-02-23*
|
||||
* [PhpBrowser][Frameworks] `submitForm` improvements by @zbateson: *2015-02-23*
|
||||
|
||||
Removed submitForm's reliance on using parse_str and parse_url to
|
||||
generate params (which caused unexpected side-effects like failing
|
||||
for values with ampersands).
|
||||
|
||||
Modified the css selector for input elements so disabled input
|
||||
elements don't get sent default values.
|
||||
|
||||
Modifications to ensure multiple values get sent correctly.
|
||||
|
||||
* [Laravel4] middleware is loaded on requests. Fixed #1680 by @jotweh *2015-02-23*
|
||||
* [Dbh] Begin transaction only unless transaction is already in progress by @thecatontheflat *2015-02-23*
|
||||
* [PhpBrowser][Frameworks] Fix quiet crash when crawler is null by @aivus. See #1714 *2015-02-23*
|
||||
* [Yii2] Fixed usage of PUT method by @miroslav-chandler *2015-02-23*
|
||||
|
||||
#### 2.1.0
|
||||
|
||||
* [WebDriver] Saving and restoring session snapshots implemented *2015-03-16*
|
||||
|
||||
#### 2.0.10
|
||||
|
||||
* **Console Improvement**: better formatting of test progress. Improved displaying of debug messages and PHP Fatal Errors.
|
||||
Codeception now uses features of interactive shell to print testing progress.
|
||||
In case of non-interactive shell (when running from CI like Jenkins) this feature is gracefully degraded to standard mode.
|
||||
You can turn off interactive printing manually by providing `--no-interaction` option or simply `-n`
|
||||
* `ExceptionWrapper` messages unpacked into normal and verbose exceptions.
|
||||
* HTML reports now allow to filter tests by status. Thanks to @raistlin
|
||||
* Added '_failed' hook for Cest tests. Fixes #1660 *2015-02-02*
|
||||
* [REST] fixed setting Host header. Issue #1650 *2015-02-02*
|
||||
* [Laravel4] Disconnecting from database after each test to prevent Too many connections exception #1665 by @mnabialek *2015-02-02*
|
||||
* [Symfony2] Fixed kernel reuse in #1656 by @hacfi *2015-02-01*
|
||||
* [REST] request params are now correctly saved to `$this->params` property. Fixes #1682 by @gmhenderson *2015-02-01*
|
||||
* Interactive shell updated: deprecated Symfony helpers replaced, printed output cleaned *2015-01-28*
|
||||
* [PhpBrowser][Frameworks] Fixed `matchOption` to return the option value in case there is no value attribute by @synchrone. See #1663 *2015-01-26*
|
||||
* Fixed remote context options on CodeCoverage by @synchrone. See #1664 *2015-01-26*
|
||||
* [MongoDb] `seeNumElementsInCollection` method added by @sahanh
|
||||
* [MongoDb] Added new methods: `grabCollectionCount`, `seeElementIsArray`, `seeElementIsObject` by @antoniofrignani
|
||||
* [WebDriver] Allow `selectOption()` to select options not inside forms by @n8whnp See #1638
|
||||
* [FTP] Added support for sftp connections with an RSA SSH key by @mattvot.
|
||||
* [PhpBrowser][WebDriver] allows to handle domain and path for cookies *2015-01-24*
|
||||
* [CLI] Allow CLI module to handle nonzero response codes without failing by @DevShep
|
||||
* [Yii2] Fix the bug with `session_id()`. See #1606 by @TriAnMan
|
||||
* [PhpBrowser][Frameworks] Fix double slashes in certain forms submitted by `submitForm` by @Revisor. See #1625
|
||||
* [Facebook] `grabFacebookTestUserId` method added by @ipalaus
|
||||
* Always eval error level settings passed from config file.
|
||||
|
||||
#### 2.0.9
|
||||
|
||||
* **Fixed Symfony 2.6 compatibility in Yaml::parse by @antonioribeiro**
|
||||
* Specific tests can be executed without adding .php extension by @antonioribeiro See #1531 *2014-12-20*
|
||||
|
||||
Now you can run specific test using shorter format:
|
||||
|
||||
```
|
||||
codecept run unit tests/unit/Codeception/TestLoaderTest
|
||||
codecept run unit Codeception
|
||||
codecept run unit Codeception:testAddCept
|
||||
|
||||
codecept run unit Codeception/TestLoaderTest.php
|
||||
codecept run unit Codeception/TestLoaderTest
|
||||
codecept run unit Codeception/TestLoaderTest.php:testAddCept
|
||||
codecept run unit Codeception/TestLoaderTest:testAddCept
|
||||
|
||||
codecept run unit tests/unit/Codeception
|
||||
codecept run unit tests/unit/Codeception:testAddCept
|
||||
codecept run unit tests/unit/Codeception/TestLoaderTest.php
|
||||
codecept run unit tests/unit/Codeception/TestLoaderTest.php:testAddCept
|
||||
codecept run unit tests/unit/Codeception/TestLoaderTest
|
||||
codecept run unit tests/unit/Codeception/TestLoaderTest:testAddCept
|
||||
```
|
||||
|
||||
* [Db] Remove table constraints prior to drop table in clean up for SqlSrv by @jonsa *2014-12-20*
|
||||
* [PhpBrowser][Frameworks] Fixed: submitForm with form using site-root relative paths may fail depending on configuration #1510 by @zbateson *2014-12-20*
|
||||
* [WebDriver][PhpBrowser][Frameworks] `seeInField` method to work for radio, checkbox and select fields. Thanks to @zbateson *2014-12-20*
|
||||
* Fixed usage of `--no-colors` flag by @zbateson. Issue #1562 *2014-12-20*
|
||||
* [REST] sendXXX methods now encode objects implementing JsonSerializable interfaces. *2014-12-19*
|
||||
* [REST] added methods to validate JSON structure *2014-12-19*
|
||||
|
||||
[seeResponseJsonMatchesJsonPath](http://codeception.com/docs/modules/REST#seeResponseJsonMatchesJsonPath) validates response JSON against [JsonPath](http://goessner.net/articles/JsonPath/).
|
||||
Usage of JsonPath requires library `flow/jsonpath` to be installed.
|
||||
|
||||
[seeResponseJsonMatchesXpath](http://codeception.com/docs/modules/REST#seeResponseJsonMatchesXpath) validates response JSON against XPath.
|
||||
It converts JSON structure into valid XML document and executes XPath for it.
|
||||
|
||||
[grabDataFromResponseByJsonPath](http://codeception.com/docs/modules/REST#grabDataFromResponseByJsonPath) method was added as well to grab data JSONPath.
|
||||
|
||||
* [REST] `grabDataFromJsonResponse` deprecated in favor of `grabDataFromResponseByJsonPath` *2014-12-19*
|
||||
* [PhpBrowser][Frameworks] fixed `Unreachable field` error while filling [] fields in input and textarea fields. Issues #1585 #1602 *2014-12-18*
|
||||
|
||||
#### 2.0.8
|
||||
|
||||
* Dependencies updated: facebook/php-webdriver 0.5.x and guzzle 5 *2014-11-17*
|
||||
* [WebDriver] Fixed selectOption and (dont)seeOptionIsSelected for multiple radio button groups by @MasonM. See #1467 *2014-11-18*
|
||||
* [WebDriver][PhpBrowser][Frameworks] Clicked submit button can be specified as 3rd parameter in `submitForm` method by @zbateson. See #1518
|
||||
* [ZF1] Format ZF response to Symfony\Component\BrowserKit\Response by @MOuli90. Fixes #1476
|
||||
* [PhpBrowser][Frameworks] fixed `grabValueFrom` method by @zbateson. See #1512
|
||||
* [Db] Fixed Postgresql error with schemas by @rafreis. Fixes #970
|
||||
* [PhpBrowser] Fix for meta refresh tags with interval by @zbateson. See #1515
|
||||
* [PhpBrowser][Frameworks] Fixed: `grabTextFrom` doesn't work with regex by @zbateson. See #1519
|
||||
* Cest tests support multiple `@before` and `@after` annotations. Thanks to @draculus and @zbateson. See #1517
|
||||
* [FTP] Stops test execution on failed connection by @yegortokmakov
|
||||
* [AMQP] Fix for purging queues on initialization stage. Check for open channel is not needed and it prevents from cleaning queue by @yegortokmakov
|
||||
* CodeCoverage remote context configuration added by @synchrone. See #1524 [Documentation updated](http://codeception.com/docs/11-Codecoverage#Remote-Context-Options)
|
||||
* Implemented better descriptions for error exception. Fix #1503
|
||||
* Added `c3_url` option to code coverage settings. `c3_url` allows to explicitly set url for index file with c3 included. See #1024
|
||||
* [PhpBrowser][Frameworks] Fixed selecting checkbock in a group of checkboxes #1535
|
||||
* [PhpBrowser][Frameworks] submitForm sends default values for radio buttons and checkboxes by @zbateson. Fixes #1507 *2014-11-3*
|
||||
* [ZF2] Close any open ZF2 sessions by @FnTm. See #1486 *2014-10-24*
|
||||
|
||||
#### 2.0.7
|
||||
|
||||
* [Db] Made the postgresql loader load $$ syntax correctly by @rtuin. See #1450 *2014-10-12*
|
||||
* [Yii1] fixed syntax typo in Yii1 Connector by @xt99 *2014-10-12*
|
||||
* [PhpBrowser][WebDriver] amOnUrl method added for opening absolute urls. This behavior taken from amOnPage method, initially introduced in 2.0.6 *2014-10-12*
|
||||
* Fixed usage of whitespaces in wantTo. See #1456 *2014-10-12*
|
||||
* [WebDriver][PhpBrowser][Frameworks] fillField is matching element by name, then by CSS. Fixes #1454 *2014-10-12*
|
||||
|
||||
#### 2.0.6
|
||||
|
||||
* Fixed list of executed suites while running included suites by @gureedo. See #1427 *2014-10-08*
|
||||
* [Frameworks] support files and request names containing square brackets, dots, spaces. See #1438. Thanks to @kkopachev *2014-10-08*
|
||||
* [PhpBrowser] array of files for Guzzle to support format: file[foo][bar]. Fixes #342 by @kkopachev *2014-10-07*
|
||||
* Added strict mode for XML generation. *2014-10-06*
|
||||
|
||||
In this mode only standard JUnit attributes are added to XML reports, so special attributes like `feature` won't be included. This improvement fixes usage XML reports with Jenkins #1408
|
||||
To enable strict xml generation add to `codeception.yml`:
|
||||
|
||||
```
|
||||
settings:
|
||||
strict_xml: true
|
||||
```
|
||||
|
||||
* Fixed retrieval of codecoverage reports on remote server #1379 *2014-10-06*
|
||||
* [PhpBrowser][Frameworks] Malformed XPath won't throw fatal error, but makes tests fail. Fixes #1409 *2014-10-06*
|
||||
* Build command generates actors for included suites. See #1267 *2014-10-03*
|
||||
* CodeCoverage throws error on unsuccessful requests (status code is not 200) to remote server. Fixes #346 *2014-10-03*
|
||||
* CodeCoverage can be disabled per suite. Fix #1249 *2014-10-02*
|
||||
* Fix: --colors and --no-colors options can override settings from config *2014-10-02*
|
||||
* [WebDriver] `waitForElement*` methods accept strict locators and WebDriverBy as parameters. See #1396 *2014-09-29*
|
||||
* [PhpBrowser] `executeInGuzzle` uses baseUrl set from config. Fixes #1416 *2014-09-29*
|
||||
* [Laravel4] fire booted callbacks between requests without kernel reboot. Fixes #1389, See #1415 *2014-09-29*
|
||||
* [WebDriver][PhpBrowser][Frameworks] `submitForm` accepts forms with document-relative paths. Fixes #1274 *2014-09-28*
|
||||
* [WebDriver][PhpBrowser][Frameworks] Fixed #1381: `fillField` fails for a form without a submit button by @zbateson *2014-09-28*
|
||||
* [PhpBrowser][WebDriver] `amOnPage` now accepts absolute urls *2014-09-27*
|
||||
* [Db] ignore errors from lastInsertId by @tomykaira *2014-09-27*
|
||||
* [WebDriver] saves HTML snapshot on fail *2014-09-27*
|
||||
* [WebDriver] fixed #1392: findField should select by id, css, then fall back on xpath *2014-09-27*
|
||||
* [WebDriver] Don't check for xpath if css selector is set, by @Danielss89 #1367 *2014-09-27*
|
||||
* Specify actor class for friends by @tomykaira. See #1394 *2014-09-27*
|
||||
|
||||
#### 2.0.5
|
||||
|
||||
* [Queue] module added with AWS, Iron.io, and Beanstalkd support. Thanks to @nathanmac *2014-08-21*
|
||||
* [WebDriver] fixed attachFile error message when file does not exists #1333 by @TroyRudolph *2014-08-21*
|
||||
* [Asserts] Added assertLessThan and assertLessThanOrEqual by @Great-Antique *2014-08-21*
|
||||
* [ZF2] fixed #1283 by @dkiselew *2014-08-21*
|
||||
* Added functionality to Stub to allow ConsecutiveCallStub. See #1300 by @nathanmac *2014-08-21*
|
||||
* Cest generator inserts object into _before and _after methods by @TroyRudolph *2014-08-21*
|
||||
* [PhpBrowser][Frameworks] Fixed #1304 - ->selectOption() fails if two submit buttons present by @fdjohnston *2014-08-21*
|
||||
* [WebDriver][PhpBrowser][Frameworks] seeNumberOfElements method added by @dynasource *2014-08-21*
|
||||
* recursive runner for included suites by @dynasource *2014-08-21*
|
||||
* Disabled skipped/incomplete tests logging in jUnit logger for smooth Bamboo integration by @ayastreb *2014-08-21*
|
||||
|
||||
#### 2.0.4
|
||||
|
||||
* [Laravel4] More functional, cli, and api tests added to demo application <https://github.com/Codeception/sample-l4-app> *2014-08-05*
|
||||
* Fix: GroupManager uses DIRECTORY_SEPARATOR for loaded tests *2014-08-05*
|
||||
* [Laravel4] Uses `app.url` config value for creating requests. Fixes #1095 *2014-08-04*
|
||||
* [Laravel4] `seeAuthenticated` / `dontSeeAuthenticated` assertions added to check that current user is authenticated *2014-08-04*
|
||||
* [Laravel4] `logout` action added *2014-08-04*
|
||||
* [Laravel4] `amLoggedAs` can login user by credentials *2014-08-04*
|
||||
* [Laravel4] Added `amOnRoute`, `amOnAction`, `seeCurrentRouteIs`, `seeCurrentActionIs` actions *2014-08-04*
|
||||
* [Laravel4] Added `haveEnabledFilters` and `haveDisabledFilters` actions to toggle filters in runtime *2014-08-04*
|
||||
* [Laravel4] Added `filters` option to enable filters on testing *2014-08-04*
|
||||
* [REST] seeResponseContainsJson should not take arrays order into account. See #1268 *2014-08-04*
|
||||
* [REST] grabDataFromJsonResponse accepts empty path to return entire json response *2014-08-04*
|
||||
* [REST] print_r replaced with var_export for better output on json comparison #1210 *2014-08-02*
|
||||
* [REST] Reset request variables in the before hook by @brutuscat #1232 *2014-08-01*
|
||||
* [Db] Oci driver for oracle database by @Sikolasol #1234 #1243 *2014-08-01*
|
||||
* [Laravel4] Unit testing and test environment are now configurable #1255 by @ipalaus *2014-08-01*
|
||||
* [Laravel4] Fixed Cest testing when using Laravel's Auth #1258 by @ipalaus *2014-08-01*
|
||||
* FIX #948 code coverage HTML: uncovered files missing by @RLasinski *2014-07-26*
|
||||
* [Laravel4] project root relative config parameter added by @kernio *2014-07-26*
|
||||
|
||||
#### 2.0.3
|
||||
|
||||
* [Symfony2] Symfony3 directory structure implemented by @a6software *2014-07-21*
|
||||
* Console: printing returned values *2014-07-21*
|
||||
* FIX: TAP and JSON logging should not be started when no option --json or --tap provided *2014-07-21*
|
||||
* [Doctrine2] FIXED: persisting transaction between Symfony requests *2014-07-19*
|
||||
* [Symfony2] created Symfony2 connector with persistent services *2014-07-19*
|
||||
* [Doctrine2] implemented haveInRepository method (previously empty) *2014-07-17*
|
||||
* When Cest fails @after method wont be executed *2014-07-17*
|
||||
* [Laravel4] App is rebooted before each test. Fixes #1205 *2014-07-15*
|
||||
* FIX: `codeception/specify` is now available in phar *2014-07-14*
|
||||
* FIX: Interactive console works again *2014-07-09*
|
||||
* `_bootstrap.php` is now loaded before `beforeSuite` module hooks.
|
||||
* FIX: Suite `_bootstrap.php` was loaded after test run by @samdark *2014-07-11*
|
||||
|
||||
#### 2.0.2
|
||||
|
||||
* [PhpBrowser][Frameworks] correctly send values when there are several submit buttons in a form by @TrustNik *2014-07-08*
|
||||
* [REST] fixed connection with framework modules *2014-07-06*
|
||||
* [PhpBrowser][Frameworks] `checkOption` now works for checkboxes with array[] name by @TrustNik
|
||||
* [PhpBrowser][Frameworks] FIX: `seeOptionIsSelected` and `dontSeeOptionIsSelected` now works with radiobuttons by @TrustNik *2014-07-05*
|
||||
* [FTP] MODULE ADDED by @nathanmac *2014-07-05*
|
||||
* [WebDriver] Enabled remote upload of local files to remote selenium server by @motin *2014-07-05*
|
||||
* [Yii2][Yii1] disabled logging for better functional test performance
|
||||
|
||||
#### 2.0.1
|
||||
|
||||
* [Phalcon1] Fixed connector
|
||||
* [WebDriver] added seeInPageSource and dontSeeInPageSource methods
|
||||
* [WebDriver] see method now checks only for visible BODY element by @artyfarty
|
||||
* [REST] added Bearer authentication by @dizews
|
||||
* removed auto added submit buttons in forms previously used as hook for DomCrawler
|
||||
* BUGFIX: PHP 5.4.x compatibility fixed. Sample error output: 'Method WelcomeCept.php does not exist' #1084 #1069 #1109
|
||||
* Second parameter of Cest method is treated as scenario variable on parse. Fix #1058
|
||||
* prints raw stack trace including codeception classes in -vvv mode
|
||||
* screenshots on fail are saved to properly named files #1075
|
||||
* [Symfony2] added debug config option to switch debug mode by @pmcjury
|
||||
|
||||
#### 2.0.0
|
||||
|
||||
* renamed `_logs` dir to `_output` by default
|
||||
* renamed `_helpers` dir to `_support` by default
|
||||
* Guy renamed to Tester
|
||||
* Bootstrap command got 3 installation modes: default, compat, setup
|
||||
* added --coverage-text option
|
||||
|
||||
#### 2.0.0-RC2
|
||||
|
||||
* removed fabpot/goutte, added Guzzle4 connector
|
||||
* group configuration can accept groups by patterns
|
||||
|
||||
#### 2.0.0-RC
|
||||
|
||||
* [WebDriver] makeScreenshot does not use filename of a test
|
||||
* added `grabAttributeFrom`
|
||||
* seeElement to accept attributes in second parameter: seeElement('input',['name'=>'login'])
|
||||
|
||||
#### 2.0.0-beta
|
||||
|
||||
* executeInGuzzle is back in PhpBrowser
|
||||
* environment can be accessed via ->env in test
|
||||
* before/after methods of Cest can take object
|
||||
* moved logger to extension
|
||||
* bootstrap files are loaded before suite only
|
||||
* extension can reconfigure global config
|
||||
* removed RefactorAddNamespace and Analyze commands
|
||||
* added options to set output files for xml, html reports, and coverage
|
||||
* added extension to rerun failed tests
|
||||
* webdriver upgraded to 0.4
|
||||
* upgraded to PHPUnit 4
|
||||
256
vendor/codeception/base/CHANGELOG-2.1.md
vendored
Normal file
256
vendor/codeception/base/CHANGELOG-2.1.md
vendored
Normal file
@@ -0,0 +1,256 @@
|
||||
#### 2.1.11
|
||||
|
||||
* [Yii1] Improved Yii connector. AR metadata is cleaned up between requests. `regenerateId` of session is disabled.
|
||||
* [REST][InnerBrowser] redirect is not triggered when Location header is set but response code is not 3xx. By @Naktibalda. Fixes #3171.
|
||||
* [PhpBrowser][Frameworks] checkboxes can be located by label by @dizzy7. See #3237
|
||||
* [PhpBrowser][Frameworks] field can be matched by its trimmed label value. See #3209. By @dizzy7
|
||||
* [WebDriver] fixed URL matching in WebDriver::seeLink
|
||||
* [WebDriver][InnerBrowser] Improved error messages of `seeLink` and `dontSeeLink`
|
||||
|
||||
#### 2.1.10
|
||||
|
||||
* PHPUnit version locked to <5.4
|
||||
* [Db] Added missing support for LIKE condition to SqlSrv driver
|
||||
|
||||
#### 2.1.9
|
||||
|
||||
* PHPUnit 5.4 compatibility for creating mocks using `Codeception\Util\Stub` by @davertmik. See #3093 and #3080
|
||||
* Updated dependencies to support Symfony 3.1
|
||||
* [Laravel5] Fixed issue where non-existing services were called in _before and _after methods. See #3028.
|
||||
* Fix self-update command to update only to stable versions by @MAXakaWIZARD
|
||||
* Added `settings: backup_global` to config, to disable backup_global option of PHPUnit by @mkeasling. See #3045. Fixes #3044
|
||||
* [PhpBrowser][Frameworks] `see` matches UTF-8 text case-insensitively by @Naktibalda. Fixes #3114
|
||||
* Fixed page object generation with namespaces by @eugene-manuilov and @Naktibalda. See #3126 Fixes #3012
|
||||
* `--steps` will not disable code coverage. By @Naktibalda. Fixes #2620
|
||||
* Suppress console coverage report with `--quiet` by @EspadaV8. See #2370
|
||||
* Improved multibyte output in console by @kt81. See #3130
|
||||
* [Lumen] Fixed: `initializeLumen()` method has been called twice on start by @kt81. See #3124 #2607
|
||||
* [Db] Allow INT Parameter SQL Binding by @davidcochrum . Fixes #3118
|
||||
* [Db] Support LIKE conditions in assertions.
|
||||
* [Db] Improved regex for parsing comments by @dima-stefantsov. See #3138
|
||||
* [Dbh] Fix `seeInDatabase` and `dontSeeInDatabase` with empty criteria. Closes #3116
|
||||
* [Symfony] Improve fail messages on seeInCurrentRoute and seeCurrentRouteIs
|
||||
* [Symfony] Improve route comparison on seeInCurrentRoute and seeCurrentRouteIs
|
||||
* [WebDriver] multi session testing with friends improved by @eXorus. Webdriver sessions are finished correctly; `leave()` method added to Friend class. See #3068
|
||||
* [PhpBrowser] added `handler` and `middleware` config options to customize Guzzle handlers and middleware
|
||||
* Added full support of phpunit-bridge features.
|
||||
* [Laravel] Fixed issue where non-existing services were called in _before and _after methods. See #3028.
|
||||
* [WebDriver] fixed using `saveSessionSnapshot` with codecoverage. Closes #2923
|
||||
* [ZF2] create new instance of Application for each request
|
||||
|
||||
#### 2.1.8
|
||||
|
||||
* `Util\Locator` added methods to create locators to match element at their position: `elementAt`, `firstElement`, `lastElement`
|
||||
* [Symfony] Refactor to unify service retrieval, avoid memleaks and reduce memory footprint. Closes #2938 and #2954.
|
||||
* [Symfony] New optoin `rebootable_client` that reboots client's kernel before each request.
|
||||
* [WebDriver] fixed `seeInField` for textarea with whitespaces before and after string. Closes #2921
|
||||
* [Symfony] Deprecated `grabServiceFromContainer` use `grabService` instead. For consistency with other frameworks.
|
||||
* [Asserts] More `assert*` methods from PHPUnit added
|
||||
* [Asserts] Added `expectException` method
|
||||
* `codecept self-update` works with proxy by @gr1ev0us
|
||||
* [Phalcon1 add params support for method amOnRoute by @MelnykDmitro
|
||||
|
||||
#### 2.1.7
|
||||
|
||||
* **PHPUnit 5.x support**
|
||||
* Global Bootstrap, Suite Bootstrap, Module Initialization happens before test loading. Fixes issues of autoloading TestCase classes introduced in 2.1.5, see #2872
|
||||
* Added option to skip PHP files validation in `codeception.yml` - `settings: lint: false`
|
||||
* [Facebook] Updated to facebook/php-sdk-v4 version 5 by @orhan-swe and @tigerseo #2828 #2415
|
||||
* [WebDriver] Added `scrollTo` action by @javigomez and @davertmik #2844
|
||||
* Fix encoding problems in PHP prior to 5.6 by @pejaycz. See #2831
|
||||
* [Queue] Fixed `clearQueue` for AmazonSQS by @mikitu #2805
|
||||
* [Db] Fixed loading files in Sqlite @mcustiel See #2812
|
||||
* [PhpBrowser] `amHttpAuthenticated` allows null, null as parameters to unset authentication. #2896
|
||||
* `Util\Locator` added `contains` method to easily locate any element containing a text.
|
||||
* [Laravel5] Added `guard` parameters to `seeAuthentication` and `dontSeeAuthentication` methods. By @janhenkgerritsen. See #2876
|
||||
* [Laravel5] Added functionality to disable/enable Laravel's exception handling. By @janhenkgerritsen. See #2763
|
||||
* [Laravel5] Authentication now persists between requests when calling `amLoggedAs` with an instance of `Authenticable`. See #2795
|
||||
* [REST] Fixed dontSeeXmlResponseMatchesXpath method #2825 by @mangust404
|
||||
* [ZF2] Fixed POST parameters #2814 by @Naktibalda
|
||||
* [ZF1] Call Zend_Registry::_unsetInstance in _after #2863 by @Naktibalda
|
||||
|
||||
#### 2.1.6
|
||||
|
||||
* Starting from 2.1.6 you can **download PHP 5.4 compatible phar build** at http://codeception.com/php54/codecept.phar by @Naktibalda. See [installation guide](http://codeception.com/install).
|
||||
* [WebDriver] Fixed uploading files with **PhantomJS** #1823 by @DavertMik and @Naktibalda. Please specify your browser name as `phantom` in WebDriver config in order to use PhantomJS-specific hooks.
|
||||
* Fixed parsing PHP files with spaces in name on PHP<7 by @acuthbert. Fixes #2647
|
||||
* [WebDriver] Fixed proxy error when using with Chrome #2651 by @vaikla
|
||||
* [Laravel5] Allow Laravel5 application URL to be set through config. By @gmhenderson. See #2676
|
||||
* [Laravel5] Mocked events should also return an array. Fix by @devinfd
|
||||
* Fixed using codecoverage with environments #2634
|
||||
* Various HHVM improvements by @Naktibalda, for instance, Asserts module issues has been fixed.
|
||||
* [REST] Fixes #2775 `seeResponseJsonMatchesXpath` when JSON contains ampersand. By @Naktibalda.
|
||||
* [Filesystem] Added `seeNumberNewLines` method to check the number of new lines in opened file. By @sergeyklay
|
||||
* [Symfony2] Added `seeCurrentRouteMatches` action by @laszlo-karpati See #2665
|
||||
* [Sequence] Added `sqs` function to generate unique sequences per suite. #2766 by @johnatannvmd
|
||||
* [FTP] Fixed various bugs by @k-serenade. See #2755
|
||||
* [Frameworks][PhpBrowser] Fixed #2733: `seeOptionIsSelected` sees first option as selected if none is selected by @Naktibalda
|
||||
* [Symfony2] Removed 'localhost' from getInternalDomains by @Naktibalda. Fixed #2717
|
||||
* Bugfix for using groups by directory on Windows by @tortuetorche See #2550 and #2551
|
||||
* [REST] Fixed failed message for `seeHttpHeader` and `dontSeeHttpHeader` from null to expected value #2697 by @zondor
|
||||
* [REST] Added methods to control redirect: `stopFollowingRedirects` and `startFollowingRedirects` by @brutuscat
|
||||
* [Recorder Extension] Added `animate_slides` config to disable left-right sliding animation between screenshots by @vml-rmott
|
||||
|
||||
#### 2.1.5
|
||||
|
||||
* **PHP7 support**
|
||||
* **Symfony3 support**
|
||||
* [ZendExpressive] **module added** by @Naktibalda
|
||||
* [Frameworks] **Internal Domains**: Framework modules now throw an `ExternalUrlException` when a test tries to open a URL that is not handled by the framework, i.e. an external URL. See #2396
|
||||
* Syntax check for tests. If PHP7 is used, `ParseException` handles syntax error, otherwise linting happens with `php -l`. @davertmik
|
||||
* Fixed Cest generation to not include "use" statements if no namespaces set
|
||||
* [REST] Modified JsonArray::sequentialArrayIntersect to return complete matches only by @Naktibalda. Fixes #2635
|
||||
* [REST] Fixes validation of several types with filters. See #2581 By @davertmik
|
||||
* [REST] JsonType improved URL filter to use `filter_var($value, FILTER_VALIDATE_URL)`
|
||||
* [REST] JsonType to support collections: all items in an array will be validates against JsonType. By @davertmik
|
||||
* [REST] Various fixes to JsonType: #2555 #2548 #2542
|
||||
* [REST] Hides binary request data in debug by @codemedic. Fixed #1884, See #2552
|
||||
* [WebDriver] Allow `appendField` to work with content editable div by @nsanden #2588
|
||||
* [WebDriver] Allows adding ssl proxy settings by @mjntan35.
|
||||
* [Symfony2] Config option `cache_router` added (disabled by default) by @raistlin.
|
||||
* [Doctrine] Fixed #2060: Too many connections error by @dranzd
|
||||
* [Symfony2] `services` part added to allow access Symfony DIC while wokring with WebDriver or PhpBrowser by @laszlo-karpati See #2629
|
||||
* [WebDriver][PhpBrowser] Unified setCookie "expires" param name by @davertmik. See #2582
|
||||
* [Memcache] add adaptive close call on `_after` by @pfz. See #2572
|
||||
* [Symfony2] Move kernel booting and container set up into _initialize() method by @Franua #2491
|
||||
* [WebDriver] Fixed `seeInField` for textareas by @nsanden
|
||||
* [Yii2][REST] Fixed using Yii2 as dependency for REST by @Naktibalda. See #2562
|
||||
* [Laravel5] Removed `enableMiddleware` and `enableEvents` methods. See #2602. By @janhenkgerritsen
|
||||
* [Laravel] Refactored modules. See #2602. By @janhenkgerritsen
|
||||
* [Laravel5] Fix bug for `seeCurrentRouteIs` when routes don't match. See #2593. By @maddhatter
|
||||
* [PhpBrowser] Set curl options for Guzzle6 correctly. See #2533. By @Naktibalda
|
||||
* Fixed usage of GroupObject by unit tests. GroupObjects can skip tests by @davetmik. See #2617
|
||||
|
||||
#### 2.1.4
|
||||
|
||||
* [PhpBrowser][Frameworks] Added `_getResponseContent` hidden method. By @Naktibalda
|
||||
* [PhpBrowser][Frameworks] Added `moveBack` method. By @Naktibalda
|
||||
* [WebDriver][PhpBrowser][Frameworks] Added `seeInSource`, `dontSeeInSource` methods to check raw HTML instead of stripped text in `see`/`dontSee`. By @zbateson in #2465
|
||||
* [WebDriver] print Selenium WebDriver logs on failure or manually with `debugWebDriverLogs` in debug mode. Config option `debug_log_entries` added. See #2471 By @MasonM and @DavertMik.
|
||||
* [ZF2] grabs service from container without reinitializing it. Fixes #2519 where Doctrine2 gets different instances of the entity manager everytime grabServiceFromContainer is called. By @dranzd
|
||||
* [REST] fixed usage of JsonArray and `json_last_error_msg` function on PHP 5.4. See #2535. By @Naktibalda
|
||||
* [REST] `seeResponseIsJsonType` can now validate emails with `string:email` definition. By @DavertMik
|
||||
* [REST] `seeResponseIsJsonType`: `string|null` as well as `null|string` can be used to match null type. #2522 #2500 By @vslovik
|
||||
* [REST] REST methods can be used to inspect result of the last request made by PhpBrowser or framework module. see #2507. By @Naktibalda
|
||||
* [Silex] Doctrine provider added. Doctrine2 module can be connected to Silex app with `depends: Silex` in config. By @arduanov #2503
|
||||
* [Laravel5] Removed `expectEvents` and added `seeEventTriggered` and `dontSeeEventTriggered`. By @janhenkgerritsen
|
||||
* [Laravel5] Fixed fatal error in `seeCurrentRouteIs` and `seeCurrentActionIs` methods. See #2517. By @janhenkgerritsen
|
||||
* [Laravel5] Improved the error messages for several methods. See #2476. By @janhenkgerritsen
|
||||
* [Laravel5] Improved form error methods. See #2432. By @janhenkgerritsen
|
||||
* [Laravel5] Added wrapper methods for Laravel 5 model factories. See #2442. By @janhenkgerritsen
|
||||
* [Phalcon] Added `amOnRoute` and `seeCurrentRouteIs` methods by @sergeyklay
|
||||
* [Phalcon] Added `seeSessionHasValues` by @sergeyklay
|
||||
* [Phalcon] Added `getApplication()` method by @sergeyklay
|
||||
* [Symfony2] Sets `xdebug.max_nesting_level` to 200 only if it is lower. Fixes error hiding #2462 by @mhightower
|
||||
* [Db] Save the search path when importing Postgres dumps #2441 by @EspadaV8
|
||||
* [Yii2] Fixed problems with transaction rollbacks when using the `cleanup` flag. See #2488. By @ivokund
|
||||
* [Yii2] Clean up previously uploaded files between tests by @tibee
|
||||
* Actor classes generation improved by @codemedic #2453
|
||||
* Added support for nested helper by @luka-zitnik #2494
|
||||
* Make `generate:suite` respect bootstrap setting in #2512. By @dmitrivereshchagin
|
||||
|
||||
#### 2.1.3
|
||||
|
||||
* [REST] **Added matching data types** by with new methods `seeResponseMatchesJsonType` and `dontSeeResponseMatchesJsonType`. See #2391
|
||||
* [PhpBrowser][Frameworks] added `_request` and `_loadPage` hidden API methods for performing arbitrary requests.
|
||||
* [PhpBrowser][Frameworks] Fixed `seeInField`, `dontSeeInField` for disabled fields #2378. See #2414.
|
||||
* Environment files can now be located in subfolders of `tests/_env` by @Zifius
|
||||
* [Symfony2] Fixed issue when accessing profiler when no request has been performed #652.
|
||||
* [Symfony2] Added `amOnRoute` and `seeCurrentRouteIs` methods by @raistlin
|
||||
* [ZF2] Added `amOnRoute` and `seeCurrentRouteIs` methods module, by @Naktibalda
|
||||
* Fixed issue with trailing slashes in `seeCurrentUrlEquals` and `dontSeeCurrentUrlEquals` methods #2324. By @janhenkgerritsen
|
||||
* Warning is displayed once using unconfigured environment.
|
||||
* Fixed loading environment configurations for Cept files by @splinter89
|
||||
* Fixed bootstrap with namespaces to inject namespaced actor classes properly.
|
||||
* [PhpBrowser][Frameworks] added hidden `_request()` method to send requests to backend from Helper classes.
|
||||
* [Laravel5] Added `disableEvents()`, `enableEvents()` and `expectEvents()` methods. By @janhenkgerritsen
|
||||
* [Laravel5] Added `dontSeeFormErrors()` method. By @janhenkgerritsen
|
||||
* [Db] Deleted Oracle driver (it existed by mistake, the real driver is Oci). By @Naktibalda
|
||||
* [Db] Implemented getPrimaryKey method for Sqlite, Mysql, Postgresql, Oracle and MsSql. By @Naktibalda
|
||||
* [Db] Implemented support for composite primary keys and tables without primary keys. By @Naktibalda
|
||||
* Fixed the scalarizeArray to be aware of NULL fields #2264. By @fbidu
|
||||
* [Soap] Fixed SOAP module #2296. By @relaxart
|
||||
* Fixed a bug where blank lines in a groups file would run every test in the project #2297. By @imjoehaines
|
||||
* [WebDriver] seeNumberOfElements should only count visible elements #2303. By @sascha-egerer
|
||||
* [PhpBrowser][Frameworks] Verbose output for all HTTP requests. By @Naktibalda
|
||||
* [PhpBrowser][Frameworks] Throw `Codeception\Exception\ExternalUrlException` when framework module tries to open an external URL #2328. By @Naktibalda
|
||||
* [PhpBrowser][Frameworks] Added `switchToIframe` method. By @Naktibalda
|
||||
* [Dbh] module deprecated
|
||||
|
||||
#### 2.1.2
|
||||
|
||||
* **Updated to PHPUnit 4.8**
|
||||
* Enhancement: **Wildcard includes enabled when testing [multiple applications](http://codeception.com/docs/08-Customization#One-Runner-for-Multiple-Applications)**. See #2016 By @nzod
|
||||
* [Symfony2] fixed Doctrine2 integration: Doctrine transactions will start before each test and rollback afterwards. *2015-08-08*
|
||||
* [Doctrine2] establishing connection and starting transaction is moved to `_before`. *2015-08-08*
|
||||
* [PhpBrowser] Removed disabled and file fields from form values. By @Naktibalda *2015-08-08*
|
||||
* [ZF2] Added grabServiceFromContainer function. By InVeX *2015-08-08*
|
||||
* [PhpBrowser][Guzzle6] Disabled strict mode of CookieJar #2234 By @Naktibalda *2015-08-04*
|
||||
* [Laravel5] Added `disableMiddleware()` and `enableMiddleware()` methods. By @janhenkgerritsen *2015-08-07*
|
||||
* Enhancement: If a specific *ActorActions trait does not exist in `tests/_support/_generated` directory, it will be created automatically before run.
|
||||
* Enhancement: do not execute all included suites if you run one specific suite *2015-08-08*
|
||||
* `Extension\Recorder` navigate over slides with left and right arrow keys, do not create screenshots for comment steps.
|
||||
* `Extension\Recorder` generates index html for all saved records.
|
||||
* `Extension\Recorder` fixed for creating directories twice. Fixed #2216
|
||||
* `Extension\Logger` fixed #2216
|
||||
* Fixed injection of Helpers into Cest and Test files. See #2222
|
||||
* `Stub::makeEmpty` on interfaces works again by @Naktibalda
|
||||
* Command `generate:scenarios` fixed for Cest files by @mkudenko See #1962
|
||||
* [Db] Quoted table name in Db::select, removed identical methods from child classes by @Naktibalda. See #2231
|
||||
* [WebDriver] added support for running tests on a remote server behind a proxy with `http_proxy` and `http_proxy_port` config options by @jdq22 *2015-07-29*
|
||||
* [Laravel] Fixed issue with error handling for `haveRecord()` method in Laravel modules #2217 by @janhenkgerritsen *2015-07-28*
|
||||
* Fixed displayed XML/HTML report path #2187 by @Naktibalda *2015-07-27*
|
||||
* [WebDriver] Fixed `waitForElementChange` fatal error by @stipsan
|
||||
* [Db] Enhanced dollar quoting ($$) processing in PostgreSQL driver by @YasserHassan *2015-07-20*
|
||||
* [REST] Created tests for file-upload with REST module. By @Naktibalda *2015-08-08*
|
||||
* [Lumen] Fixed issue where wrong request object was passed to the Lumen application by @janhenkgerritsen *2015-07-18*
|
||||
|
||||
#### 2.1.1
|
||||
|
||||
* [WebDriver] **Upgraded to facebook/webdriver 1.0** *2015-07-11*
|
||||
WebDriver classes were moved to `Facebook\WebDriver` namespace. Please take that into account when using WebDriver API directly.
|
||||
Till 2.2 Codeception will keep non-namespaced aliases of WebDriver classes.
|
||||
* Module Reference now contains documentation for hidden API methods which should be used in Helper classes
|
||||
* Skipped and Incomplete tests won't fire `test.before` and `test.after` events. For instance, WebDriver browser won't be started and Db cleanups won't be executed on incomplete or skipped tests.
|
||||
* Annotations `skip` and `incomplete` enabled in Cest files #2131
|
||||
* [WebDriver][PhpBrowser][Frameworks] `_findElements($locator)` method added to use in Helper classes *2015-07-11*
|
||||
Now you can use `$this->getModule('WebDriver')->findElements('.user');` in Helpers to match all elements with `user` class using WebDriver module
|
||||
* [PhpBrowser] Fixed `amOnUrl` method to open absolute URLs.
|
||||
* [PhpBrowser][Frameworks] Fix for `fillField` using values that contain ampersands by @GawainLynch and @zbateson Issue #2132
|
||||
* [WebDriver][PhpBrowser][Frameworks] Fixed missing HTTPS when trying to access protected pages #2141
|
||||
|
||||
#### 2.1.0
|
||||
|
||||
* [Recorder](https://github.com/Codeception/Codeception/tree/master/ext#codeceptionextensionrecorder) extension added. Shows acceptance test progress with a recorded slideshow.
|
||||
* **Updated to Guzzle 6**. Codeception can now work both with Guzzle v5 and Guzzle v6. PhpBrowser chooses right connector depending on Guzzle version installed. By @davertmik and @enumag
|
||||
* Annotations in Cept files.
|
||||
Instead of calling `$scenario->skip()`, `$scenario->group('firefox')`, etc, it is recommended to set scenario metadata with annotations `// @skip`, `// @group firefox`.
|
||||
Annotations can be parsed from line or block comments. `$scenario->skip()` and `$scenario->incomplete()` are still valid and can be executed inside conditional statements:
|
||||
```
|
||||
if (!extension_loaded('xdebug')) $scenario->skip('Xdebug required')
|
||||
```
|
||||
* **PSR-4**: all support classes moved to `tests/_support` by default. Actors, Helpers, PageObjects, StepObjects, GroupObjects to follow PSR-4 naming style. Autoloader implemented by @splinter89.
|
||||
* **Dependency Injection**: support classes can be injected into tests. Support classes can be injected into each other too. This happens by implementing method `_inject` and explicitly specifying class names as parameters. Implemented by @splinter89.
|
||||
* **Actor classes can be extended**, their generated parts were moved to special traits in `_generated` namespace. Each *Tester class can be updated with custom methods.
|
||||
* **Module config simplified**: Modules can be configured in `enabled` section of suite config.
|
||||
* **Conflicts**: module can define conflicts with each other by implementing `_conflicts` method
|
||||
* **Dependencies**: module can explicitly define dependencies and expect their injection by implementing `_inject` and `_depends` methods and relying on dependency injection container.
|
||||
* **Current** modules, environment, and test name can be received in scenario. Example: `$scenario->current('env')` returns current environment name. Fixes #1251
|
||||
* **Environment Matrix**: environments can be merged. Environment configs can be created in `tests/_envs`, environment generator added. Implemented by By @sjableka. See #1747
|
||||
* **Custom Printers**: XML, JSON, TAP, Report printers can be redefined in configuration. See #1425
|
||||
* [Db] Added `reconnect` option for long running tests, which will connect to database before the test and disconnect after. By @Naktibalda
|
||||
* Module parts. Actions of modules can be loaded partially in order to disable actions which are not used in current tests. For instance, disable web actions of framework modules in unit testsing.
|
||||
* **Kohana**, **Symfony1**, **Doctrine1** modules considered deprecated and moved to standalone packages.
|
||||
* `shuffle` added to settings. Randomizes order of running tests. See #1504
|
||||
* Console output improved: scenario stack traces contain files and lines of fail.
|
||||
* [Doctrine2][Symfony2] `symfony_em_service` config option moved from Doctrine2 to Symfony2 module and renamed to `em_service` *2015-06-03*
|
||||
* [PhpBrowser][Frameworks] Fixed cloning form nodes `Codeception\Lib\InnerBrowser::getFormFromCrawler(): ID XXX already defined` *2015-05-13*
|
||||
* [WebDriver] session snapshot implemented, allows to store cookies and load them, i.e., to keep user session between testss.
|
||||
* [WebDriver][PhpBrowser][Frameworks] Malformed XPath locators wil throw an exception #1441
|
||||
* `MODULE_INIT` event is fired before initializing modules #1370
|
||||
* Graceful tests termination using `pcntl_signal`. See #1286
|
||||
* Group classes renamed to GroupObjects; Base GroupObject class renamed to `Codeception\GroupObject`
|
||||
* Official extensions moved to `ext` dir; Base Extension class renamed to `Codeception\Extension`
|
||||
* Duplicate environment options won't cause Codeception to run environment tests twice
|
||||
* [Phalcon1] `haveServiceInDi` method implemented by @sergeyklay
|
||||
* [Db] `seeNumRecords` method added by @sergeyklay
|
||||
397
vendor/codeception/base/CHANGELOG-2.2.md
vendored
Normal file
397
vendor/codeception/base/CHANGELOG-2.2.md
vendored
Normal file
@@ -0,0 +1,397 @@
|
||||
|
||||
#### 2.2.12
|
||||
|
||||
* Don't skip other tests after a failed test #4226 by @Naktibalda
|
||||
* [REST] `seeResponseContainsJson` doesn't crash when json response is not an array by @Naktibalda
|
||||
* [PhpBrowser] Fixed redirecting to schemaless url by @Naktibalda #4218
|
||||
* [Doctrine2] Added `grabEntityFromRepository`, `grabEntitiesFromRepository` methods by @maximelebastard
|
||||
|
||||
#### 2.2.11
|
||||
|
||||
* [WebDriver] Added `_restart` method to restart browser with a new configuration.
|
||||
* [WebDriver] Added `_findClickable` to public API so can be used from helpers. By @tiger-seo
|
||||
* [WebDriver] `seeLink` compares relative links correctly #4182
|
||||
* [Webdriver] fixed attachFile messages when the file does not exist by @Naktibalda
|
||||
* Fixed setting paths in environments and using `--override` options. By @kusnir. See #4143
|
||||
* [Yii1] Allow to set only host in `url` config. #4172 by @SG5.
|
||||
* [Yii1] Allow to make requests end with slash. #4190 by @SG5
|
||||
* [Yii2] Allows use `InitDbFixture` feature #4201
|
||||
* [Yii2] Add missing YII2 lifecycle events. #4187
|
||||
* Don't run test if exception was thrown in `_before` of a module #4197 by @Naktibalda
|
||||
* [Mongo] Fixed parsing dbname. See #4186 by @retnek
|
||||
* [Mongo] Improved legacy driver check by @retnek. See #4178
|
||||
* [WebDriver][PhpBrowser][Frameworks] Added `grabPageSource` method by @Kolyunya
|
||||
* [PhpBrowser][REST] Add DELETE method to supported form data request methods in Guzzle6 by
|
||||
* [PhpBrowser][REST] Restore request headers in multi-session testing. Fixes #4157
|
||||
* Recorder Extension: Replace non-alphanumeric characters with underscores by @tiger-seo. Fixes Recorder on Windows
|
||||
* [REST] Documented different ways to upload files
|
||||
* Fixed `$scenario->current('name')` #4154 by @Naktibalda
|
||||
* [AMQP] Documented parameters of `declareQueue`, `declareExchange` by @Naktibalda
|
||||
* [Doctrine2] Safe prefix aliases for `buildAssociationQuery` by @jfxninja. See #4195
|
||||
* Fixed output of failed step by @Naktibalda #4135 http://phptest.club/t/seeelement-wierd-fail-message/1470
|
||||
* [WebDriver] fixed `friend->leave` method. Clearing base element on closing session. Fixes #4098
|
||||
* [Symfony] Make symfony bootstrap.php.cache optional for php version > 7 by @patrickjahns
|
||||
* Gherkin: Command `gherkin:snippets` to generate stub function name for non-english features. By @kuntashov
|
||||
* Gherkin: Steps with PyString and with inline string argument considered the same. Fixes #4121 by @kuntashov
|
||||
* [Db] `Oci::cleanup()` should be able to drop objects with case sensitive name. By @pavelkovar
|
||||
* [Db] loadDump reports sql statement which caused error, fixes regression from 2.2.10. See #4120. By @Naktibalda.
|
||||
* [Asserts] Add delta parameter to `assertEquals()` `assertNotEquals()` methods by @spideyfusion
|
||||
* [Yii2] Removed check and notification for environment other than `test` by @samdark
|
||||
* [Yii2] Unload fixtures only if `cleanup` configuration equals true. #4207 by @Faryshta
|
||||
* [ZF2] Removed `session_write_close()` from ZF2 module by @tasselchof. Fixes #4112
|
||||
* Fixed textual representation of can't steps by @Naktibalda
|
||||
* [Lumen] Added IoC methods from Laravel5 module: `haveBinding`, `haveSingleton`, `haveContextualBinding`, `haveInstance`, `haveApplicationHandler`, `clearApplicationHandlers`. By @kt81
|
||||
* [Lumen] Clear facade cache only when facade exists. Same change as #3124 for refactored Lumen module by @kt81
|
||||
* [ZendExpressive] Support Zend Expressive 2.0 by @Naktibalda
|
||||
* [Doctrine2] `haveFakeRepository` updated to work with Doctrine >= 2.5.7 by @laszlo-karpati #4212
|
||||
* Command `bootstrap` adds `support/_generated` to gitignore. By @Naktibalda
|
||||
|
||||
#### 2.2.10
|
||||
|
||||
* Prefer local composer installation if available. Solves issues with incompatibility between locally and globally installed or packaged in phar file Codeception dependencies. Fix by @Naktibalda See #3997
|
||||
* Added console completion by @gdscei. See [documentation](http://codeception.com/docs/07-AdvancedUsage#Shell-autocompletion)
|
||||
* [WebDriver] Fixed compatibility with `facebook/webdriver` 1.4.0 by @Naktibalda. See #4076 Fixes #4073
|
||||
* Run a suite by its path #4079
|
||||
|
||||
```
|
||||
codecept run tests/unit
|
||||
```
|
||||
Improves recent [PHPStorm integration](https://blog.jetbrains.com/phpstorm/2017/03/codeception-support-comes-to-phpstorm-2017-1/). Codeception tests can be started by running a suite directory.
|
||||
|
||||
* [WebDriver] Fixed using `performOn` with `ActionSequence`; supporting multiple actions of same kind. #4066 by @davertmik. Fixes #4044
|
||||
* [Laravel5] Added `haveApplicationHandler` and `clearApplicationHandlers` methods. See #4068. By @janhenkgerritsen
|
||||
* [Laravel5] Close all Laravel DB connections after test execution. Fixes #4031 by @rmblstrp
|
||||
* [Laravel5] Update Laravel5 `database_migrations_path` to by null by default by @timbroder. Fixes #3990
|
||||
* [DataFactory] Add `cleanup` option to skip auto cleanup. By @alexpts. See #3996
|
||||
* Fixed printScenarioFail with multiple feature scenarios by @gimler. See #3868
|
||||
* Fixed generating JUnit XML when Selenium server can’t be connected. Closes #3653 by @Naktibalda
|
||||
* Fixes running local suites (under tests folder) and included suite mixed (via include path). See #4063
|
||||
* [Db] Run the last statement in dump file even if it doesn't end with delimiter. #4071 by @Naktibalda. Fixes #4059
|
||||
* [Memcache] Fixed calling flush on null by @Jurigag. See #4074
|
||||
* [Yii2] Fixtures behavior compatibility with `yii2-codeception` by @leandrogehlen. See #4016
|
||||
* `g:suite` allows generate suites with uppercase names. Fixes #4072
|
||||
* Enabled incomplete/skipped/risky/warning settings for logger. See #3890. By @mario-naether
|
||||
|
||||
```yaml
|
||||
settings:
|
||||
report_useless_tests: false
|
||||
disallow_test_output: false
|
||||
be_strict_about_changes_to_global_state: false
|
||||
log_incomplete_skipped: false
|
||||
```
|
||||
* [WebDriver] Fixed double coverage cookie check by @boboldehampsink. See #2923 #4020
|
||||
* [WebDriver] Fixed `switchToIframe` regression from 2.2.9 by @lcobucci. PR #4000
|
||||
* Speed improvement for group lookup by @pitpit. See #4025
|
||||
* Added parse error to `TestParseException` in PHP7 by @Naktibalda. See #4007
|
||||
* Auto injection for `Codeception\Test\Unit` format #4070. Allows to customize injection of support objects into a testcase:
|
||||
|
||||
```php
|
||||
<?php
|
||||
public function _inject(UnitTester $unit)
|
||||
{
|
||||
$this->i = $unit;
|
||||
}
|
||||
```
|
||||
|
||||
#### 2.2.9
|
||||
|
||||
* [Laravel5] **Laravel 5.4 support** by @janhenkgerritsen
|
||||
* [WebDriver] Added `performOn` to wait for element, and run actions inside it. See [complete reference](http://codeception.com/docs/modules/WebDriver#performOn). #3986
|
||||
* [WebDriver] Improved error messages for `wait*` methods by @disc. See #3983
|
||||
* [REST] Binary responses support by @spikyjt #3993 #3985
|
||||
* `seeBinaryResponseEquals` assert that binary response matches a hash
|
||||
* `seeBinaryResponseEquals` assert that binary response doesn't match a hash
|
||||
* hide binary response on debug
|
||||
* [Laravel5] module fix error for applications that do not use a database. See #3954 by @janhenkgerritsen. Fixed #3942
|
||||
* [Laravel5] database seeders to be executed inside a transaction. See #3954 by @janhenkgerritsen. Fixed #3948 by @janhenkgerritsen
|
||||
* [Yii2] reverted #3834, closing transaction after each request. #3973 by @iRipVanWinkle. Fixes #3961
|
||||
* Added crap4j report support. Use `--coverage-crap4j` option and `codeception/c3` 2.0.10
|
||||
* [PhpBrowser][Frameworks] If form has no id, use action attribute as identifier by @Naktibalda. Fixes #3953
|
||||
* Fixed test coloring output when a Feature title has some special chars in it like `/` or `-`
|
||||
* [REST] Added missing @part `json` and `xml` to `deleteHeader` by @freezy-sk
|
||||
|
||||
#### 2.2.8
|
||||
|
||||
* [WebDriver] Added tab actions (not supported in PhantomJS):
|
||||
* `openNewTab` opens a new tab and switches to it
|
||||
* `closeTab` closes a tab and switches to previous
|
||||
* `switchToNextTab` switches to next tab
|
||||
* `switchToPreviousTab` switches to previous tab
|
||||
* [WebDriver] Added actions to click element by coordinates. Via @gimler
|
||||
* `clickWithLeftButton` clicks element with offset
|
||||
* `clickWithRightButton` right clicks on element with offset
|
||||
* [WebDriver] Added `js_error_logging` option to print JS logs in console and in HTML report by @ngraf. See #3821
|
||||
* [WebDriver] Improvements to `seeInField` by @gimler. See #3905
|
||||
* support option text in seeInField not only value
|
||||
* fix bug match with and without whitespaces
|
||||
* fix bug seeInField not working after selectOption
|
||||
* [Wedriver] `pageload_timeout` config option added. The amount of time to wait for a page load to complete before throwing an error. This patch allows to reduce issues from phantomjs random freezing. See #3874. Thanks to @oprudkyi
|
||||
* [WebDriver] `checkOption` can check option by name #3852. By @gimler
|
||||
* [WebDriver] Fixed clicking numerical links, like `<a href='/'>222</a>` (DOM Exception 12 errors). See #3865. By @gimler
|
||||
* [PhpBrowser][Frameworks] Fixed #3824 when submitForm used wrong value for `select` by @JorisVanEijden
|
||||
* [Laravel5] Added `seeNumRecords` and `grabNumRecords` methods. See #3816. By @dmoreno
|
||||
* Improved `@depends` to work with `@dataprovider`. Fixes #3862. Thanks @edno
|
||||
* Fixed relative paths for screenshots in HTML report. Fixes #3857
|
||||
* Improved error description when injecting invalid classes by @timtkachenko
|
||||
* Improved `--override` option to support deep configs. See #3820
|
||||
* [Yii2] Clear unloaded fixtures after test. Closes #3794
|
||||
* [PhpBrowser] Ensure sessions have independent cookies by @insightfuls. Fixes #3911
|
||||
* Implemented load params from php files by @arrilot. See #3914
|
||||
* [Yii2] Fixes #3916: Don't try to start transaction when working with non-transactional DBs by @samdark.
|
||||
* [REST] Removed broken xdebug_remote functionality by @Naktibalda. Fixes #3883
|
||||
* Added graceful termination by Ctrl-C in PHP 7.1 by @AdrianSkierniewski. See #3907
|
||||
* [Db] Disconnect after initializing when using reconnect, fixes #3903. By @insightfuls
|
||||
* [Phalcon] Fixed handling `$_SERVER` with Phalcon Connector by @sergeyklay
|
||||
* Avoid notice when checking width of terminal on Windows by @ashnazg. See #3893
|
||||
* [Filesystem] `dontSeeFileFound` searches in path by @Naktibalda. Fixes #3877
|
||||
* [PhpBrowser][Frameworks] `grabValueFrom` to work after `fillField` by @wumouse. Fix #3866
|
||||
* [Db] Oci driver to cleans up views #3881, and result set improvements #3840 by @ashnazg.
|
||||
* [Yii2] Close transaction created by the controller-action on interruption. See #3834. By @alex20465
|
||||
* [Yii2] Fixed using `part: init` with other modules like WebDriver. See #3876. By @margori
|
||||
* [REST] Implemented `dontSeeResponseJsonMatchesXpath` method by @Naktibalda. Closes #3843
|
||||
* [REST] Convert array having single element to XML correctly. Fixes #3827 by @Naktibalda
|
||||
* Linter to check `exec` function to be enabled before using it. By @Naktibalda. See #3886
|
||||
* Fixed #3922: division by zero in steps output on small terminal windows.
|
||||
* Improved getting terminal width from ENV variable (bash). Fixes #3788 by @schmunk42
|
||||
|
||||
#### 2.2.7
|
||||
|
||||
* **Config validation** with `codecept config:validate` command. Use it:
|
||||
|
||||
```
|
||||
codecept config:validate
|
||||
codecept config:validate acceptance
|
||||
```
|
||||
|
||||
This should help you next time you get messed with YAML formatting.
|
||||
|
||||
* Gherkin improvements:
|
||||
* multiple step definitions per method allowed (Fixes #3670).
|
||||
* regex validation for Gherkin steps; throws exception if invalid regex passed. Fixes #3676
|
||||
* currency chars supported in placeholders:
|
||||
|
||||
$,€,£ and other signs can be used before or after a number inside Gherkin scenario. This char will be ignored inside a PHP variable, so you receive only number.
|
||||
|
||||
```gherkin
|
||||
When I have 100$ => $num === 100
|
||||
And I have $100 => $num === 100
|
||||
```
|
||||
|
||||
* escaped strings can now be passed into placeholders. Fixes #3676.
|
||||
|
||||
* Codeception is tested with latest verision of HHVM
|
||||
* Extensions loader refactored:
|
||||
* Extensions can be **enabled for suite** in suite config.
|
||||
* Extensions can be loaded per suite and per environment.
|
||||
* Extensions configs can be done inside `enabled` section (as it is for modules):
|
||||
|
||||
```yaml
|
||||
extensions:
|
||||
enabled:
|
||||
Codeception\Extension\Recorder:
|
||||
delete_successful: false
|
||||
```
|
||||
|
||||
* **Added dataprovider to Cest** format by @endo. See [updated documentation](http://codeception.com/docs/07-AdvancedUsage#Examples).
|
||||
* Params loader refactored. Using `vlucas/phpdotenv` to parse .env files. Please install it if you don't have it yet.
|
||||
* Improved `generate:suite` command to generate actor file for suite.
|
||||
* HTML reporter: snapshot and screenshots paths made relative to make them accessible on CI. Fixes #3702
|
||||
* [WebDriver] added `protocol` and `path` config options by @sven-carstens-udg. See #3717
|
||||
* [PhpBrowser][Frameworks] Honour `<base href="">` meta tag by @Naktibalda. See #3764
|
||||
* [Yii2] Removed mockAssetManager by @githubjeka
|
||||
* [Yii2] Added procesing for native url formats of Yii2 #3725 by @githubjeka
|
||||
* [Yii2] Fixed unintentional DB connection drop during exception logging, #3696 by @ivokund
|
||||
* [Yii2] Fixed calling `_fixtures()` method of Cest class. See #3655, fixes #3612 by @primipilus
|
||||
* [Db] Fixed `removeInserted` for Sqlite by @Naktibalda. Fixes #3680
|
||||
* Allows to get groups from scenario by `$scenario->getGroups()`. By @frantzen. See #3675
|
||||
* Fixed #3225: incorrect steps shown for multiple canXXX conditional assertion failures. By @Mitrichius
|
||||
* [SOAP] Force string for debugSection output by @Noles. Fixes #3690
|
||||
* Fixed #3562 group files with exact test not working with `@example` on Windows by @Naktibalda.
|
||||
* [Laravel5] Added `vendor_dir` option. See #3775. By @AdrianSkierniewski
|
||||
* [Laravel5] Fixed error where custom service container bindings were not available on the first request. See #3728. By @janhenkgerritsen
|
||||
* [Lumen] Fixed error where a non-existing exception class was thrown. See #3729. By @janhenkgerritsen
|
||||
* [Phalcon] Added `services` part which can be used to `grabServiceFromContainer` and `addServiceToContainer` when conflicting module is used. By @sergeyklay
|
||||
* [Phalcon] **Refactored**. Moved in-memory session adapter to the separated namespace. By @sergeyklay
|
||||
* [Phalcon] Fixed overwriting server parameters on requests. By @sergeyklay
|
||||
* [Asserts] `assertCount` method added by @disc
|
||||
* Documentation improvements by @CJDennis
|
||||
|
||||
#### 2.2.6 (October 2016)
|
||||
|
||||
* Ability to update config on run with `--override` (`-o`) option. Usage Examples:
|
||||
* `codecept run -o "settings: shuffle: true"`: enable shuffle
|
||||
* `codecept run -o "settings: lint: false"`: disable linting
|
||||
* [WebDriver] **HTML report to include screenshots of failed tests.** See #3602
|
||||
* [PhpBrowser][Frameworks] HTML report to include HTML of failed tests. See #3602
|
||||
* [Apc] **Module added** to interact with the Alternative PHP Cache (APC) using either APCu or APC extension. By @sergeyklay
|
||||
* [Laravel5] Add `run_database_seeder` configuration option. See #3625 and #3630. By @Bouhnosaure
|
||||
* [Laravel5] Add `database_migrations_path` configuration option. See #3628. By @janhenkgerritsen
|
||||
* [Laravel5][Lumen] Fixed issue that caused the `have` and `haveMultiple` methods not being available when using the ORM part of the modules. See #3587. By @janhenkgerritsen
|
||||
* [PhpBrowser][Frameworks] Fixed clicking on a button inside the link
|
||||
* [PhpBrowser][Frameworks] Click on the first clickable item when clickBySelector is used
|
||||
* [PhpBrowser][Frameworks] Anchor is no longer sent to server
|
||||
* Removed tags from `see`/`dontSee` output and friends output
|
||||
* `--` separates options from arguments in `codecept run` by @Naktibalda. Fixes #3614. See #3615
|
||||
* Fixed terminating run process with Ctrl-C for PHP 7.0. Disabled graceful termination
|
||||
* [Yii2] fixed Yii2 logging complex data by @svoboda2010 Fixes #3452
|
||||
* [Yii2] `cleanup` set to true by default (as it was documented but not enabled).
|
||||
* [Yii2] Close db connections when running `haveFixtures` by @Ni-san. Fixes #3456. See #3586
|
||||
* [Yii2] Fixed loading fixtures from `_fixtures` method in testcase by @iRipVanWinkle. See #3565
|
||||
* [MongoDb] Added support for [mongofill](https://github.com/mongofill/mongofill), an alternative Mongo client in pure PHP. By @hlogeon at #3641
|
||||
* [MongoDb] Fixed data import using mongotype dump type by @hlogeon #3637
|
||||
* Fixed #3392 by normalizing namespace loading classes in DI getterby @Mitrichius at #3633
|
||||
* [Symfony] Fixed #3608 `[PHPUnit_Framework_Exception] implode()` while printing debug for security roles by @Prazmok.
|
||||
* [Yii1] Fix domain regex #3581 to return correct value by @amashigeseiji See #3597
|
||||
* [WebDriver] Improved tests stability when Selenium server is gone #3534 by @eXorus. Fixes #3531
|
||||
* [WebDriver] Tests are errored when Selenium server can't be connected. See #3603
|
||||
* MetaSteps are printed even with disabled xdebug by @niclopez. See #3600
|
||||
* [WebDriver] submit button in `submitForm` can be located by name or strict locator by @imjoehaines. See #3560
|
||||
* [SOAP][REST] removed module conflict by @eXorus.
|
||||
* Fixed #3571: error handler to call `registerDeprecationErrorHandler` method and `register_shutdown_function` on first SuiteEvent only. By @positronium. See #3572
|
||||
|
||||
#### 2.2.5 (September 2016)
|
||||
|
||||
* Support for PhpUnit 5.x.
|
||||
* [Lumen] Major refactoring of Lumen module. See #3533. By @janhenkgerritsen
|
||||
* [Laravel5] Removed calls to `Auth::logout()`, `Session::flush()` and `Cache::flush()` from after hook. See #3493. By @janhenkgerritsen
|
||||
* [Memcache] Updated `Memcache::seeInMemcached` to check if the key exists alone or with the desired value. By @sergeyklay
|
||||
* [Memcache] Added `Memcache::haveInMemcached`. By @sergeyklay
|
||||
* [Memcache] Fixed `Memcache::dontSeeInMemcached`. By @sergeyklay
|
||||
* [ZF2] Zend Framework 3 Support. Made `init_autoloader` optional, because ZF3 uses composer for autoloading #3525. By @Naktibalda
|
||||
* [ZF2] Fixed accessing Doctrine Entity Manager when client is not initialized. By @chris1312. See #3524
|
||||
* [Yii2] Allow to load fixtures from `_fixtures` method of a testcase. [See reference](http://codeception.com/docs/modules/Yii2#Fixtures). Fixes usage of nested transactions #3520. By @kalyabin and @davertmik
|
||||
* [Yii1] Fix private property accessible; allows to change urlManager class to subclass of CUrlManager. See @3287. By @amashigeseiji
|
||||
* Escaped tags in debug output by @Naktibalda. See #3507. Fixes #3495
|
||||
* Fixed #3410: Wrong subSteps rendering in HTML ResultPrinter by @niclopez
|
||||
* [WebDriver] Improved exception message thrown when click('name') does not match any element #3546 by @Naktibalda. Fixes #3528
|
||||
* [SOAP] Removed conflict with REST module. `seeResponseCodeIs` is deprecated in favor of `seeSoapResponseCodeIs` by @eXorus. See #3512. Fixes #3512
|
||||
* Fixed #3472: group Files not working with a non-empty data provider by @eXorus
|
||||
* [REST] Disabled resetting server parameters in _before. Fixed REST+Laravel usage: #3263. See #3539. By @janhenkgerritsen
|
||||
* [REST] Improved output of failed JsonType assertions #3480. By @Naktibalda. Fixes #2858
|
||||
* [REST] Requests are added to browser history #3446. Fixes regression #3197. By @Naktibalda
|
||||
* [REST] application/json header check made case insensitive. Fixes #3516. By @Naktibalda
|
||||
* Fix bug in Coverage Filter related to relative filepaths #3518. By @sbacic
|
||||
* [Db] PostgreSQL: fixed a problem when sequences are not a standard format (ie. table_id_seq). See #3506. By @alexjeen
|
||||
* [Symfony] Persist doctrine.dbal.backend_connection if Doctrine2 module is used #3500. Fixes #3479. By @Naktibalda
|
||||
* [Doctrine2] Using `Doctrine\ORM\EntityManagerInterface` as valid em instance #3467. Fixes #3459. By @akbwm
|
||||
* [MongoDb] Fixes `mongorestore` command syntax and adds --quiet option to config
|
||||
* [Facebook] Replaced `facebook/php-sdk-v4` library with `facebook/graph-sdk`.
|
||||
* Fixed #3433 detection of relative path when `codeception.yml` is not in project root. See #3434. By @loren-osborn
|
||||
* Handle deprecation messages according to `error_level` setting #3460. Fixes #3424. By @Naktibalda.
|
||||
|
||||
#### 2.2.4 (August 2016)
|
||||
|
||||
* Improved using complex params, nested params can be set using dot (`.`). See #3339
|
||||
* [Yii2] Mailer mock is now configured with options that make sense for it. Fixes #3382
|
||||
* [Yii2] Fixed creating `@webroot` directory on running functional tests. See #3387
|
||||
* [Yii2] Fixed regression in Yii 2 connector not allowing to work with output of error pages in functional tests. Fixes #3332
|
||||
* [Mongo] support of standard mongodump/mongorestore tools to populate mongo db database. Thanks @GSokol. Fixes #3427
|
||||
* [REST] `seeResponseIsJson` fails when response is empty. See #3401, closes #3400
|
||||
* [AMQP] Added `purgeQueue` and `purgeAllQueues` actions. By @niclopez
|
||||
* [DataFactory] `haveMultiple` fixed; corrected the order of arguments in `FactoryMuffin->seed`. See #3413 by @buffcode
|
||||
* [SOAP] Improved error reporting by @eXorus See #3426 #3422
|
||||
* [SOAP] Added `SOAPAction` config param to unset `SOAPAction` header in SOAP >= 1.2. See #3396
|
||||
* [REST] fixed digest authentication. See #3416
|
||||
* [Laravel5] Fixed an issue with error handling for Laravel 5.3. See #3420. By @bonsi.
|
||||
* [Laravel5] Fixed an issue with uploaded files. See #3417. By @torkiljohnsen.
|
||||
* [ZF2] Support for zend-mvc 3.0
|
||||
* [Db] Error is thrown if SQLite memory is used. #3319
|
||||
* [Frameworks] `REQUEST_TIME` server variable to be set on request. By @gimler. Fixes #3374
|
||||
|
||||
#### 2.2.3 (July 2016)
|
||||
|
||||
* [Yii2] Improvements:
|
||||
* Added `init` part to initialize Yii app for unit and acceptance testing.
|
||||
* added `entryScript` and `entryUrl` config values for acceptance testing.
|
||||
* Fixtures support: `haveFixtures`, `grabFixtures` methods.
|
||||
* Yii logs to be printed in debug mode.
|
||||
* added `amOnRoute` method.
|
||||
* added `amloggedInAs` method.
|
||||
* added `grabComponent` method.
|
||||
* added `seeEmailIsSent`, `grabLastSentEmail`, etc and email part.
|
||||
* assetManager disabled for unit/functional tests.
|
||||
* Fixed `@example` to `@group` defined in group files. By @eXorus. Fixes #3278
|
||||
* Added `ReqiuiresPackage` interface to set external dependencies for modules.
|
||||
* Fixed timing values in output. Closes #3331
|
||||
* Fixed merging module configs. Closes #3292
|
||||
* [Recorder Extension] Fixes saving of files on windows and with using examples.
|
||||
* [DataFactory] Fixed loading factories twice by @samusenkoiv. See #3314
|
||||
* [Laravel5] Added `run_database_migrations` configuration option. By @janhenkgerritsen.
|
||||
* [Laravel5] Added `callArtisan` method. By @janhenkgerritsen.
|
||||
* [Laravel5] Added `disableModelEvents()` method and `disable_model_events` configuration option. Fixes #2897.
|
||||
* [REST] Allow objects in files array #3298
|
||||
* [ZF2] Added addServiceToContainer method
|
||||
* [ZendExpressive] allow instances of UploadedFile in files array
|
||||
* [ZF2] Added addServiceToContainer method
|
||||
* Don't fail test validation when exec function is disabled by @Naktialda
|
||||
|
||||
#### 2.2.2
|
||||
|
||||
* Parameters can be applied to global `codeception.yml` config. See #3255 Thanks to @LeRondPoint
|
||||
* Fixed loading of parameters from `.env.*` files. See #3224. By @smotesko
|
||||
* Better failure diff messages by @k0pernikus
|
||||
* UTF-8 improvements (replaced with custom `ucfirst`, `strtoupper` => `mb_strtoupper`) by @Naktibalda. See #3211
|
||||
* Print execution time of non-successful tests by @Naktibalda. Fixes #3274
|
||||
* [WebDriver][PhpBrowser][Frameworks] Fixed created files on failure. Fixes #3207
|
||||
* [Frameworks][PhpBrowser] Adjacent forms submit improvements by @dizzy7. Fixes #2331
|
||||
* [WebDriver] Fixed adjacent `selectOption` with similar options by @eXorus. Fixes #3246
|
||||
* [DataFactory] fixed loading factories from relative paths. Fixes #3208
|
||||
* *Test\Gherkin* Added JUnit reporter #3273
|
||||
* *Test\Gherkin* Added support for multiple languages by @dizzy7. See #3203
|
||||
* *Test\Unit* Dependencies can pass and receive values the same way as it is done in PHPUnit. Fixes #3213
|
||||
* [Symfony] Fixed failing tests when the profiler is disabled by @dizzy7. See #3223
|
||||
* [REST] Added `Codecepion\Util\HttpCode` util class with HTTP code constants. See [class reference](https://github.com/Codeception/Codeception/blob/2.2/docs/reference/HttpCode.md)
|
||||
* [REST] Support simple key-value format for file uploads. See #3244
|
||||
* Bugfix with duplicate instances in the modules container #3219 by @dizzy7
|
||||
* [REST] Added `deleteHeader` method by @Naktibalda. Fixes #3161
|
||||
* [Yii1] `init` part added to avoid conflicts with `WebDriver`
|
||||
* `generate:snippets` can accept second parameter to generate snippets from a specific file or folder.
|
||||
* [Db] Added `grabNumRecords` method by @tocsick. See #3175
|
||||
* Fixed group events fire twice #3112. By @jstaudenmaier
|
||||
* [ZF2] Added services part which can be used to `grabServiceFromContainer` when conflicting module is used by @Naktibalda.
|
||||
* Improved Examples to be Traversable; Fixed console output for complex data structures.
|
||||
* [Laravel5] Added `haveBinding`, `haveSingleton`, `haveContextualBinding` and `haveInstance` methods. By @janhenkgerritsen. See #2904.
|
||||
* + changes from 2.1.11
|
||||
|
||||
#### 2.2.1
|
||||
|
||||
* PHPUnit 5.4 and PHPUnit/php-code-coverage 4.0 compatibility.
|
||||
|
||||
#### 2.2.0
|
||||
|
||||
* **Gherkin format support**. [Announcement](https://github.com/Codeception/Codeception/pull/2750#issue-129899745)
|
||||
* **Core Test Format Refactorings** Codeception becomes true multiformat testing platform. Format requires a [Loader](https://github.com/Codeception/Codeception/blob/master/src/Codeception/Test/Loader/LoaderInterface.php) and class extending [Test](https://github.com/Codeception/Codeception/blob/master/src/Codeception/Test/Test.php) class, implementing [TestInterface](https://github.com/Codeception/Codeception/blob/master/src/Codeception/TestInterface.php).
|
||||
* *Breaking* `Codeception\TestCase` replaced with `Codeception\TestInterface` in code and in module signatures.
|
||||
* *Breaking* Cept/Cest classes are no longer extending `PHPUnit_Framework_TestCase`, so they don't have `expectException`, `getMock`, etc.
|
||||
* Reduced stack trace for scenario-driven test formats. Codeception tests implement `PHPUnit_Framework_Test` instead of extending heavy `PHPUnit_Framework_TestCase` class.
|
||||
* *Breaking* **Conflicts API implemented** Frameworks + PhpBrowser + WebDriver can't be used together unless only non-conflicting part is used. [Announcement](http://codeception.com/03-05-2016/codeception-2.2.-upcoming-features.html#conflicts)
|
||||
* **Examples** as an alternative to Data Providers. [Announcement](http://codeception.com/03-10-2016/even-more-features-of-codeception.html#examples)
|
||||
* **Params** loading from yml, env files or environment. [Announcement](http://codeception.com/03-05-2016/codeception-2.2.-upcoming-features.html#params)
|
||||
* **Test dependencies** with `@depends` annotation. [Announcement](http://codeception.com/03-05-2016/codeception-2.2.-upcoming-features.html#test-dependencies)
|
||||
* **Custom Commands** inject your own commands as as simple as extension. [Announcement](http://codeception.com/03-10-2016/even-more-features-of-codeception.html#custom-commands)
|
||||
* `codecept dry-run` command added to show scenario steps without executing them.
|
||||
* *Breaking* [Dbh] module removed
|
||||
* *Breaking* [Laravel4] module removed. See #2866
|
||||
* *Breaking* [Laravel5] Minimum supported Laravel version is 5.1. See [#3243](https://github.com/Codeception/Codeception/issues/3243#issuecomment-227078266)
|
||||
* *Breaking* [Laravel5] Removed `createModel` method, use `have` method instead. See #2866
|
||||
* *Breaking* [Laravel5] Removed `makeModel` method. See #2866
|
||||
* *Breaking* [Laravel5] Renamed `haveModel` method to `have`. See #2866
|
||||
* *Breaking* [Symfony] public property `container` removed
|
||||
* *Breaking* [Asserts] removed deprecated `assertLessThen` and `assertGreaterThen`
|
||||
* *Breaking* mocks created with `Codeception\Util\Stub` are not verified in Cests. See #3005
|
||||
* *Breaking* [REST] `grabAttributeFrom` renamed to `grabAttributeFromXmlElement` to avoid conflicts
|
||||
* [WebDriver] allows getting current browser and capabilities in test. [Announcement](http://codeception.com/03-10-2016/even-more-features-of-codeception.html#Getting-current-browser-and-capabilities-in-tests)
|
||||
* [AngularJS] module added. Extends WebDriver module for AngularJS testing. [Announcement](http://codeception.com/03-10-2016/even-more-features-of-codeception.html#angularjs)
|
||||
* [DataFactory] module added. Performs data generation using FactoryMuffin library [Announcement](http://codeception.com/03-10-2016/even-more-features-of-codeception.html#datafactory)
|
||||
* [Redis] Module rewritten using Predis library as driver by @marcverney
|
||||
* [Laravel5] Added a `haveMultiple` method to create more than one model per call. See #2866
|
||||
* [Laravel5] [Lumen] The `haveRecord`, `seeRecord`, `dontSeeRecord` and `grabRecord` methods now also accept Eloquent model class names instead of only database table names. See #2866
|
||||
* [Symfony] module Symfony2 renamed to Symfony
|
||||
* [Phalcon] Merged `Phalcon1` and `Phalcon2` modules into one `Phalcon` due the fact that Phalcon Framework v1.3.x no longer supported at all
|
||||
* [Asserts] More `assert*` methods from PHPUnit added
|
||||
* [Asserts] Added `expectException` method
|
||||
* [WebDriver][Frameworks][PhpBrowser] `selectOption` can receive option as strict locator to exactly match option by text or by value. Use `['value' => 'myvalue']` or `['text' => 'optiontext']` to select a proper option. By @gdscei and @davertmik See #3003
|
||||
* Added config option to disable modules using `modules: disabled:`.
|
||||
* [Sequence] Changed the prefix value. Generated sequences to include id inside a prefix: `sq('user1') => 'user1_876asd8as87a'. Added `prefix` config option.
|
||||
* Deprecation errors won't fail tests but will be printed.
|
||||
* Official [Docker image](https://hub.docker.com/r/codeception/codeception/) introduced by @schmunk42
|
||||
200
vendor/codeception/base/CHANGELOG-2.3.md
vendored
Normal file
200
vendor/codeception/base/CHANGELOG-2.3.md
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
#### 2.3.9
|
||||
|
||||
* Added `Codeception\Step\Argument\PasswordArgument` to pass sensitive data into tests:
|
||||
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Step\Argument\PasswordArgument;
|
||||
|
||||
$I->amOnPage('/form/password_argument');
|
||||
$I->fillField('password', new PasswordArgument('thisissecret'));
|
||||
```
|
||||
|
||||
* [WebDriver] added `clearField` method to clean up input fields by @eknej
|
||||
* [DataFactory] added `make` method to create instances without saving them to database. But @ibpavlov
|
||||
* [REST] Fixed passing a file to `sendPOST()` without name, size or type parameter. BY @zebraf1
|
||||
* [REST] Add missing / to relative url from config by @bscheshirwork
|
||||
* Fixed HTML Report marks tests as succeeded by @mpgo13
|
||||
* `clean` command works recursively with included setups. By @davidnewcomb
|
||||
|
||||
|
||||
#### 2.3.8
|
||||
|
||||
* `Codeception\Util\Stub` moved to standalone package [Codeception\Stub](https://github.com/Codeception/Stub):
|
||||
* Use `Codeception\Stub` instead of `Codeception\Util\Stub`
|
||||
* Mocking methods `::once`, `::never`, etc moved to `Codeception\Stub\Expected` class
|
||||
* Calling mocking methods from `Codeception\Util\Stub` provides deprecation warning.
|
||||
* Non-static API is [recommended to use for mocking](http://codeception.com/docs/05-UnitTests)
|
||||
* [WebDriver] Added `executeAsyncJS` action to run asynchronous scripts.
|
||||
* [WebDriver] Added second parameter to `executeJS` to pass additional arguments into JavaScript function.
|
||||
* [Yii2] `setCookie` signs cookies when signing enabled. #4656 By @SamMousa
|
||||
* [Yii2] Method `createAndSetCsrfCookie` added. #4656 By @SamMousa
|
||||
* Compatibility with phpunit-mock-objects 5.* by @Naktibalda
|
||||
* [DataFactory] Removed dependency to `league/factory-muffin-faker` by @Naktibalda and @Insolita
|
||||
* Fixed auto-rebuilding Actor classes when dependencies are used. See #4694 by @stefankleff.
|
||||
* [Symfony] allows to use Symfony Dotenv component to parse `.env` files. Fix by @ebuildy
|
||||
* Added the ability to export the code coverage data in PHPUnit xml format by @tobiasstadler
|
||||
* `--coverage-phpunit` option added
|
||||
* Allows to use mutation testing with [Inflection](https://infection.github.io)
|
||||
* [ZendExpressive] Added Doctrine2 integration by @artmnv
|
||||
* [PhpBrowser][Frameworks] Added `_getResponseStatusCode` hidden method for using in helpers. By @FanchTheSystem
|
||||
* [Yii2] Use Yii DI to instantiate record class. Fixes #4762. By @bscheshirwork
|
||||
* Remote Code Coverage improvements #4768 by @bscheshirwork
|
||||
* Remove `:port` for cookie domain;
|
||||
* `->amOnPage('/');` executed when running code coverage with WebDriver
|
||||
* Fixed running single test with `include` config parameter. Fixes #4733 by @ppetpadriew
|
||||
* Fixed running single test when a custom suite path is configured (For instance, in single-suite setups).
|
||||
* `generate:test` command won't include `tester` property if actor is not set for this config.
|
||||
* [Facebook] Module is not maintained and is deprecated. If you are using it and you want to keep it, please contact us.
|
||||
|
||||
#### 2.3.7
|
||||
|
||||
* **Symfony 4 support** implemented by @VolCh.
|
||||
* Dependencies updated to support Symfony 4.x components.
|
||||
* [Symfony] Support for Symfony Flex directory and namespace structure
|
||||
* [Demo application](https://github.com/Codeception/symfony-demo) was updated to Symfony 4.0
|
||||
* [Db] `seeInDatabse`, `dontSeeInDatabase`, `grabFromDatabase` and other methods to support SQL comparison operators: `<`, `>`, `>=`, `<=`, `!=`, `like`. Thanks @susgo and @Naktibalda.
|
||||
* [Db] Fixed quoting around schema identifiers in MSSQL by @Naktibalda. See #4542.
|
||||
* [Db] Added SSL options for connection. Thanks @kossi84
|
||||
* [Db] Fix getting Database name from DSN in MSSQL by @yesdevnull.
|
||||
* [PhpBrowser] Fixed setting `User-Agent` in config via `headers`. Fixed #4576 by @Naktibalda.
|
||||
* [WebDriver] Implemented `dontSeeInPopup` by @kpascal.
|
||||
* [WebDriver] Allow to click a button located by its `title` attribute. See #4586 by @gimler.
|
||||
* [Silex] `app` property added to public API. Thanks @sky003
|
||||
* [Yii2] Pass DB to Yii application as early as possible to reuse old connection. By @SilverFire. See #4601
|
||||
* [Yii2] Resetting global event handlers after a test. See #4621 by @SamMousa
|
||||
* [Yii2] Recreate request object to reset headers and cookies before each request. Fixes #4587 by @erickskrauch
|
||||
* [MongoDb] Allowing `.tgz` files to be accepted for database dumps. #4611 by @Lukazar
|
||||
* [PhpBrowser][Frameworks] Fixed usage of `see` when source code contains `<=` JS operator. By @tobias-kuendig Fixes #4509.
|
||||
* [Queue] Added configuration parameter `endpoint` for AmazonSQS by @gitis.
|
||||
* Fixed signature error in `DummyCodeCoverage::stop` See #4665 by @network-spy
|
||||
* Throw exception if `exit(0)` was accidentally called. Fixes false-positive test reports. See #4604 by Fenikkusu.
|
||||
* Fixed using `path: tests: .` in configuration. Fixes #4432 by @marcovtwout
|
||||
* Fixed suite name containing slash in remote code coverage. #4612 by @bscheshirwork
|
||||
* Improved generated actions file by removing redundant `use` section. #4614 by @bscheshirwork
|
||||
* Don't skip last test if some test has missing dependency by @Naktibalda. Fixes #4598
|
||||
* Improved PHP 7.2 compatibility by @FanchTheSystem. See #4557
|
||||
* Implemented `Descriptor::getTestSignatureUnique` to create unique names for tests. See #4673 by @Tenzian. Fixes #4672
|
||||
* Fixed `setExpectedException()` default value for PHPUnit 5.7.23 by @MilesChou. See #4566
|
||||
* Fixed printing wrong failed step by @eXorus. See #4654
|
||||
* Fixed undefined `argv` warnings, added check for `register_argc_argv`. Fixes #4595 by @Naktibalda
|
||||
* Added `init` command to `codecept.phar` by @Naktibalda.
|
||||
|
||||
And many thanks to our awesome contributors! Thanks to @VolCh for upgrading to Symfony 4, thanks @Naktibalda for patches and reviews and
|
||||
thanks to @carusogabriel for refactoring tests.
|
||||
|
||||
#### 2.3.6
|
||||
|
||||
* **Laravel 5.5 compatibility**. Laravel5 module documentation updated.
|
||||
* [Doctrine2][DataFactory] Fixes using Doctrine2 with DataFactory module. See #4529. Fix by @samusenkoiv
|
||||
* [REST] Fixed JsonType crash when key 0 is not an array. Fixes #4517 by @Naktibalda
|
||||
* [PhpBrowser][Frameworks] `haveHttpHeader` enhanced to handle special characters. #4541 by @bnpatel1990
|
||||
* [WebDriver] Delete all cookies before loading session snapshot. Fix by @eXorus. See #4487
|
||||
* Added `suite_namespace` config option to suite config. Allows to set custom namespace for tests per suite. #4525 by @pohnean
|
||||
* [Db] Module enhancements by @eXorus:
|
||||
* added `updateInDatabase` method
|
||||
* added hidden `_insertInDatabase` to insert record without cleanup
|
||||
* [Yii2] Set transaction also in `backupConfig` when initializing yii2 module
|
||||
* [Yii2] Unload fixtures after rolling back database transaction. By @devonliu02 (#4497)
|
||||
* [Yii2] Use `andWhere` instead of `where` in Yii module's `findRecord()` by @SamMousa. See #4482
|
||||
* [REST] Added `amNTLMAuthenticated` for NTLM authentication using PhpBrowser. By @Tenzian
|
||||
* Inject exception file and line number frame into stack trace in case it is missing. By @rhl-jfm at #4491)
|
||||
* `Extension\RunFailed`. Added `fail-group` parameter to customize name of a failed group. By @ maxgorovenko
|
||||
* Added `\Codeception\Util\Fixtures::exists()` method by @eXorus
|
||||
* Added line number to `TestParseException` exception message by @gaainf. See #4446
|
||||
* Fixed `init` command: create the `_generated` folder before writing a `.gitignore` file there by @nstapelbroek. See #4449
|
||||
* Better failure messages for `@dataProvider` by @sh41. See #4439
|
||||
* Fixed aliasing issue with `Codeception/Verify` by @ddinchev
|
||||
|
||||
#### 2.3.5
|
||||
|
||||
* Fixed HTML report with unencoded HTML code by @mpgo13. See #3819 #4423
|
||||
* Made `assertArraySubset` protected across all modules by @guidocella
|
||||
* [WebDriver][PhpBrowser][Frameworks] Added support for associative arrays in `seeInFormFields` by @guidocella
|
||||
* [PhpBrowser][Frameworks] Submit default values of checkboxes. See #4411 by @guidocella
|
||||
* [PhpBrowser][Frameworks] Make `seeInField` check options' texts and trimmed texts. By @guidocella
|
||||
* [PhpBrowser] Prevents `submitForm` to submit inputs in disabled fieldsets. Fixes #4426 by @moebrowne
|
||||
* [PhpBrowser] Fixed `amOnUrl` with empty path component. If path component was empty, it used previous url. Fixes #4383 by @Naktibalda
|
||||
* [Db] Improved postgres cleanup (recreate schema) by @samusenkoiv
|
||||
* [Laravel5] Don't duplicate associative array fields on form submission. See #4414 by @guidocella
|
||||
* [WebDriver] Fixed `webDriver->getCapabilities()` for `facebook/php-webdriver` < 1.3 (could happen on PHP 5.4, 5.5). Fixes #4435
|
||||
* [WebDriver] Make `wait` accept fractional amount of seconds to wait for less than a second. By @gvlasov
|
||||
* [Laravel5] Changing params loader to use `$_SERVER` global instead of `$_ENV`. See #4401 by @EricTendian
|
||||
* [Mongo] Fixes `haveInCollection` using `__toString`. See #4442 by @samusenkoiv
|
||||
* Dereferencing variables for Steps output. Fixes #4402 by @alambe
|
||||
* [Symfony] Load persistent services before loading profiler. See #4437 by @samusenkoiv
|
||||
|
||||
#### 2.3.4
|
||||
|
||||
* Added `@prepare` annotation to make realtime configuration for tests in Cest and Test classes. [See documentation](http://codeception.com/docs/06-ModulesAndHelpers#Runtime-Configuration-of-a-Test).
|
||||
|
||||
Example: disabling Doctrine2 database transaction for a test
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**@prepare disableTransactions */
|
||||
function testDoctrine()
|
||||
{
|
||||
}
|
||||
|
||||
protected function disableTransactions(Doctrine2 $module)
|
||||
{
|
||||
$module->_reconfigure(['cleanup' => false]);
|
||||
}
|
||||
```
|
||||
* [WebDriver] **SmartWait**. Automatically waits for a few extra seconds for element to appear on a page before failing. Can reduce high usage of `wait*` methods. [See Documentation](http://codeception.com/docs/03-AcceptanceTests#SmartWait)
|
||||
* Added [RunProcess extension](http://codeception.com/extensions#RunProcess). Use it to start/stop Selenium (or other process) automatically for a test suite.
|
||||
* [WebDriver] Customization improvements:
|
||||
* added `start` option to disable autostart of a browser for tests. (can be useful for Cloud testing setups)
|
||||
* added `_capabilities` method for setting desired capabilities in runtime (can be combined with `@prepare` annotation)
|
||||
* `_initializeSession` and `_closeSession` can be used in Helpers to start and stop browser manually (combine with `start: false` config)
|
||||
* Fixed running a single test from a global config when using included configs. See #4366 by @zebraf1 (improves PhpStorm integration)
|
||||
* [Doctrine2][Laravel5][Yii2][Phalcon] Print debug information for started/stopped transactions in tests. See #4352
|
||||
* [PhpBrowser][Frameworks] click with context respects base tag #4330 by @Naktibalda.
|
||||
* [Yii2] Split `cleanup` configuration option (backward-compatible): (#4379 by @leandrogehlen)
|
||||
* `cleanup` - to cleanup loaded fixtures
|
||||
* `transaction` - wrap tes into transaction
|
||||
* [Asserts] Added `assertStringStartsWith` and `assertArraySubset` by @guidocella
|
||||
* [Db] Added `updateInDatabase` method by @eXorus. See #4385
|
||||
* In helpers and modules to check `$module::$excludeActions` property for existence before accessing it. Fixes #4381 by @CactusCoder
|
||||
* [Symfony] Fixed printing debug response when `Symfony::extractRawRoles()` failed on security collector (Symfony >= 3.3) #4309 by @Basster
|
||||
* [Laravel5] Fixed bug with `disable_exception_handling` functionality. See #4370. By @janhenkgerritsen
|
||||
* [Db] Added `grabColumnFromDatabase` to fetches values from the column in database. By @RebOOter
|
||||
|
||||
#### 2.3.3
|
||||
|
||||
* Fixed running with `--coverage`, `--xml`, `--html` options without parameters (Symfony Console 3.3 compatibility).
|
||||
* Removed `files` section from `composer.json` (regression from 2.3.2) to avoid unintentionally loading shim files. Fixes [Yii migration issue](https://github.com/yiisoft/yii2/issues/14226).
|
||||
* [WebDriver] `saveScreenshot` allows to save screenshots with no name passed in. See #4263 by @eXorus
|
||||
* [REST][PhpBrowser] Fixed #4287, using empty values for headers by @tobiastom.
|
||||
* Phar `self-update` downloads php5.4 build if php version <7.0. Fixes #4269
|
||||
|
||||
#### 2.3.2
|
||||
|
||||
* [Db] Fixed: Database has been cleaned up between tests even with `cleanup: false`.
|
||||
* [Db] Made `dump` optional if `populator` is set. Fixes #4247
|
||||
* Fixed `generate:suite` command to create a directory for the suite. Fixes #4251
|
||||
* Fixed composer autoloading with PHPUnit 6 by @enumag. See #4262
|
||||
|
||||
#### 2.3.1
|
||||
|
||||
* Updated composer constraints to include PHPUnit 6.x
|
||||
|
||||
#### 2.3.0
|
||||
|
||||
* **PHPUnit 6.x** support #4142 by @MontealegreLuis. Class aliases are used, so PHPUnit 4.x and 5.x (for PHP <7) are still supported as well.
|
||||
* Suite customization. [Announcement](/05-22-2017/codeception-2-3.html#configuration-improvements)
|
||||
* Installation Templates. [Announcement](/05-22-2017/codeception-2-3.html#installation-templates)
|
||||
* DotReporter introduced. Use it with
|
||||
```
|
||||
codecept run --ext DotReporter
|
||||
```
|
||||
* `--ext` parameter added to load extensions dynamically.
|
||||
* Db Populator [Announcement](/05-22-2017/codeception-2-3.html#db-populator) by @brutuscat
|
||||
* [Db] New configuration defaults, cleanups are disabled: `cleanup: false`, `populate: false`. Enable them to load dumps between tests.
|
||||
* [Redis] New configuration defaults, cleanups are disabled: `cleanupBefore: 'never'` by @hchonan
|
||||
* Command `generate:phpunit` removed.
|
||||
* Bootstrap `_bootstrap.php` files are disabled by default.
|
||||
* Configuration changes: `actor` replaced with `actor_suffix` in global config
|
||||
* Configuration changes: `class_name` replaced with `actor` in suite config
|
||||
|
||||
101
vendor/codeception/base/CHANGELOG-2.4.md
vendored
Normal file
101
vendor/codeception/base/CHANGELOG-2.4.md
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
#### 2.4.5
|
||||
|
||||
* Fixed PHPUnit 7.2 compatibility.
|
||||
* Introduced **RunBefore** extension to execute scripts before running tests. See #5049 by @aashmelev.
|
||||
* [Db] Added two options for MySQL by @bangertz
|
||||
* `ssl_cipher` - list of one or more permissible ciphers to use for SSL encryption
|
||||
* `ssl_verify_server_cert` - disables certificate CN verification
|
||||
* [Db] Always disconnect before connect when `reconnect` is set. By @ashnazg
|
||||
* [Db] More explicit PDO closing upon destruction and close opened transactions by @ashnazg.
|
||||
* [Recorder Extension] Improved error logging by @OneEyedSpaceFish. See #5101
|
||||
* [Lumen] Fixed file uploads via REST module. By @retnek.
|
||||
* Fixed: function getMetadata() may not exist, results in fatal error. See #4913 by @marcovtwout
|
||||
|
||||
#### 2.4.4
|
||||
|
||||
* Recently added `extends` property in the `codeception.yml` and `*.suite.yml` files now support absolute paths; by @silverfire
|
||||
* Fixed absolute paths handling on Windows in ParamLoader; by @silverfire
|
||||
* [Yii2] Refactored database connection handling by @SamMousa. Database connections should now always be closed after tests no matter how you have opened them or who is holding references to them. See #5045
|
||||
* [Symfony] Email handling improved by @mbohal. Fixes #5058.
|
||||
* Added optional argument `$expectedCount` to `seeEmailIsSent`
|
||||
* Added `dontSeeEmailIsSent`
|
||||
* [Recorder Extension] Added `ignore_steps` option to disable recording of specific steps. By @sspat.
|
||||
* [WebDriver] Fixed "No Session Timeout" fatal error by @davertmik.
|
||||
* [WebDriver] Added ability to locate clickable element by its title. See #5065 by @gimler
|
||||
* [Db] Add `waitlock` config option for the database session to wait for lock in Oracle. By @ashnazg. See #5069
|
||||
* [REST] Fixed `seeXmlResponseEquals` by @Voziv
|
||||
|
||||
#### 2.4.3
|
||||
|
||||
* [Create your own test formats](https://codeception.com/docs/07-AdvancedUsage#Formats) (e.g., Cept, Cest, ...); by @mlambley
|
||||
* [Symfony] Fixed a bug in order to use multiple Kernels; by @alefcastelo
|
||||
* [Asserts] Added new methods `assertNotTrue` and `assertNotFalse` methods; by @johannesschobel
|
||||
* [REST][PhpBrowser][Frameworks] Added new methods to check for `Http Status Ranges` with nice "wrappers" (e.g., `seeHttpStatusCodeIsSuccessful()` checks the code between 200 and 299); by @johannesschobel
|
||||
* Improved the docs; by community
|
||||
|
||||
#### 2.4.2
|
||||
|
||||
* Added support for `extends` in the `codeception.yml` and `*.suite.yml` files; by @johannesschobel.
|
||||
Allows to inherit current config from a provided file. See example for `functional.suite.yml`:
|
||||
|
||||
```yml
|
||||
actor: FunctionalTester
|
||||
extends: shared.functional.suite.yml
|
||||
modules:
|
||||
enabled:
|
||||
- \App\Modules\X\Tests\Helper\Functional
|
||||
```
|
||||
|
||||
* [Yii2] Restore null check for client in Yii2 by @wkritzinger. See #4940
|
||||
* [Yii2] Resetting Yii application in `_after`. By @SamMousa. See #4928
|
||||
* [Yii2] **Breaking** `$settings['configFile']` now supports absolute paths. In you have defined relative path to config in absolute manner
|
||||
* [WebDriverIO] Added `deleteSessionSnapshot` by @vi4o
|
||||
* [Symfony] Added support for custom kernel names with `kernel_class` config option. By @omnilight.
|
||||
* [Asserts] Better exception message for `expectException` by @Slamdunk
|
||||
* [REST] Decode all non-arrays to array. See #4946 by @Amunak, fixes #4944.
|
||||
* [ZF2] Fixed compatibility with ZF2 ServiceManager by @omnilight.
|
||||
* [Laravel5] Fixed memory leak when using Laravel factories inside Codeception. See #4971 by @AdrianSkierniewski
|
||||
* [Db] Added support for `null` values in MSSQL driver by @philek
|
||||
* Handle absolute paths in ParamsLoader by @SilverFire
|
||||
* Fix error on single file test. See #4986 by @mikbox74
|
||||
* Upgraded to Codeception/Stub 2.0 by @Naktibalda, fixed compatibility.
|
||||
|
||||
|
||||
#### 2.4.1
|
||||
|
||||
* Fixed "Uncaught Error: Call to undefined method Codeception\Test\Descriptor::getTestDataSetIndex()" error when filtering tests.
|
||||
* Better support of PHPUnit warning status by @edno:
|
||||
* support PHPUnit addWarning()
|
||||
* display 'W' instead of success for warning test cases
|
||||
* Fixed Running test with invalid dataprovider by @okneloper. Fixed #4888 by @edno
|
||||
* [Yii2] **Request flow and database transactions refactored** (by @sammousa):
|
||||
* **Breaking** Application is no longer available in helpers via `$this->getModule('Yii2'')->app`, now you must use `\Yii::$app` everywhere
|
||||
* Multiple databases are now supported
|
||||
* More reliable application state before and during test execution
|
||||
* Fixtures method is now configurable
|
||||
* Subset of misconfigurations are now detected and informative messages created
|
||||
* Fixed using `$settings['path']` in `Codeception\Configuration::suiteSettings()` on Windows by @olegpro
|
||||
(starting with `/`), you must change it. @silverfire
|
||||
* [Laravel5] Added Laravel 5.4+ (5.1+ backward compatible) support for `callArtisan` method in Laravel5 module. See #4860 by @mohamed-aiman
|
||||
* Fixed #4854: unnecessary escaping in operation arguments logging by @nicholascus
|
||||
* Fixed humanizing steps for utf8 strings by @nicholascus. See #4850
|
||||
* Fixed parsing relative urls in `parse_url`. See #4853 by @quantum-x
|
||||
|
||||
#### 2.4.0
|
||||
|
||||
* **PHPUnit 7.x compatibility**
|
||||
* **Dropped PHP 5.4 and PHP 5.5** support (PHP 5.5 still may work)
|
||||
* Internal API refactored:
|
||||
* Modern PHP class names used internally
|
||||
* Moved PHPUnit related classes to [codeception/phpunit-wrapper](https://github.com/Codeception/phpunit-wrapper) package.
|
||||
* Removed `shims` for underscore PHPUnit classes > namespaced PHP classes
|
||||
* Cest hooks behavior changed (by @fffilimonov):
|
||||
* `_failed` called when test fails
|
||||
* `_passed` called when tests is successful
|
||||
* `_after` is called for failing and successful tests
|
||||
|
||||
**Upgrade Notice**: If you face issues with underscore PHPUnit class names (like PHPUnit_Framework_Assert) you have two options:
|
||||
|
||||
* Lock version for PHPUnit in composer.json: "phpunit/phpunit":"^5.0.0"
|
||||
* Update your codebase and replace underscore PHPUnit class names to namespaced (PHPUnit 6+ API)
|
||||
|
||||
29
vendor/codeception/base/CONTRIBUTING.md
vendored
Normal file
29
vendor/codeception/base/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# How to contribute
|
||||
|
||||
At Codeception we are glad to receive contributions and patches from the community. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
|
||||
|
||||
Please check the guide for sending your contributions with Github at
|
||||
https://github.com/Codeception/Codeception/wiki/Git-workflow-for-Codeception-contributors
|
||||
|
||||
## Coding Standards
|
||||
All contributions must follow [PSR-2](http://www.php-fig.org/psr/psr-2/) coding standard.
|
||||
|
||||
## Code
|
||||
**Bugfixes should be sent to to current stable branch, which is the same as major version number.**
|
||||
|
||||
Breaking features and major improvements should be sent into `master`. When you send PRs to master, they will be added to release cycle only when the next stable branch is started.
|
||||
|
||||
## Tests
|
||||
|
||||
Check the [tests/README.md](tests/README.md) to learn how to run and write internal tests.
|
||||
We encourage you to write a test for a patch you are implementing. If this doesn't seem possible, such PRs are stil valid and can be accepted.
|
||||
|
||||
We also encourage to submit bug reports with a failing test or test environment (3rd party repo with Codeception installation) with demonstration of a failure. That makes easier to us to find the cause and fix it.
|
||||
|
||||
## Documentation
|
||||
|
||||
### Guides
|
||||
If you want to contribute documentation to the guides you are asked to send your changes to the /docs/ folder: https://github.com/Codeception/Codeception/tree/2.2/docs. Theses files are the source for the codeception website guides: http://codeception.com/docs/01-Introduction. Remind to send your documentation improvements to the right "repository branch" depending on the Codeception version you are working with: 2.2, master,...
|
||||
|
||||
### Modules Documentation
|
||||
The documentation for each module is directly generated from the corresponding docblock which can be found in each module (src/Codeception/Module/*.php).
|
||||
54
vendor/codeception/base/Dockerfile
vendored
Normal file
54
vendor/codeception/base/Dockerfile
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
FROM php:7.2-cli
|
||||
|
||||
MAINTAINER Tobias Munk tobias@diemeisterei.de
|
||||
|
||||
# Install required system packages
|
||||
RUN apt-get update && \
|
||||
apt-get -y install \
|
||||
git \
|
||||
zlib1g-dev \
|
||||
libssl-dev \
|
||||
--no-install-recommends && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# Install php extensions
|
||||
RUN docker-php-ext-install \
|
||||
bcmath \
|
||||
zip
|
||||
|
||||
# Install pecl extensions
|
||||
RUN pecl install \
|
||||
mongodb \
|
||||
xdebug-2.6.0beta1 && \
|
||||
docker-php-ext-enable \
|
||||
mongodb.so \
|
||||
xdebug
|
||||
|
||||
# Configure php
|
||||
RUN echo "date.timezone = UTC" >> /usr/local/etc/php/php.ini
|
||||
|
||||
# Install composer
|
||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- \
|
||||
--filename=composer \
|
||||
--install-dir=/usr/local/bin
|
||||
RUN composer global require --optimize-autoloader \
|
||||
"hirak/prestissimo"
|
||||
|
||||
# Prepare application
|
||||
WORKDIR /repo
|
||||
|
||||
# Install vendor
|
||||
COPY ./composer.json /repo/composer.json
|
||||
RUN composer install --prefer-dist --optimize-autoloader
|
||||
|
||||
# Add source-code
|
||||
COPY . /repo
|
||||
|
||||
ENV PATH /repo:${PATH}
|
||||
ENTRYPOINT ["codecept"]
|
||||
|
||||
# Prepare host-volume working directory
|
||||
RUN mkdir /project
|
||||
WORKDIR /project
|
||||
26
vendor/codeception/base/ISSUE_TEMPLATE.md
vendored
Normal file
26
vendor/codeception/base/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
#### What are you trying to achieve?
|
||||
|
||||
#### What do you get instead?
|
||||
|
||||
> Provide console output if related. Use `-vvv` mode for more details.
|
||||
|
||||
```bash
|
||||
# paste output here
|
||||
```
|
||||
> Provide test source code if related
|
||||
|
||||
```php
|
||||
// paste test
|
||||
```
|
||||
### Details
|
||||
|
||||
* Codeception version:
|
||||
* PHP Version:
|
||||
* Operating System:
|
||||
* Installation type: Phar || Composer
|
||||
* List of installed packages (`composer show`)
|
||||
* Suite configuration:
|
||||
|
||||
```yml
|
||||
# paste suite config here
|
||||
```
|
||||
21
vendor/codeception/base/LICENSE
vendored
Normal file
21
vendor/codeception/base/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011 Michael Bodnarchuk and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
66
vendor/codeception/base/PruneTest.php
vendored
Normal file
66
vendor/codeception/base/PruneTest.php
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file allows for tests to be skipped.
|
||||
* For now conditions are simple.
|
||||
* We check if changes in the source with respect to the configured branch are limited to framework files,
|
||||
* if that is the case and the current framework isn't one with changed files then we skip it.
|
||||
*/
|
||||
$branch ="2.4";
|
||||
|
||||
|
||||
function stderr($message)
|
||||
{
|
||||
fwrite(STDERR, $message . "\n");
|
||||
}
|
||||
|
||||
$currentFramework = getenv('FRAMEWORK');
|
||||
|
||||
if ($currentFramework === 'Codeception') {
|
||||
stderr('Codeception tests are always executed');
|
||||
die();
|
||||
}
|
||||
$files = [];
|
||||
exec("git diff --name-only $branch", $files);
|
||||
|
||||
// Regexes for frameworks:
|
||||
$regexes = [
|
||||
'Yii2' => '/.*Yii2.*/',
|
||||
'Lumen' => '/.*(Lumen|LaravelCommon).*/',
|
||||
'Laravel' => '/.*Laravel.*/',
|
||||
'Phalcon' => '/.*Phalcon.*/',
|
||||
'Symfony' => '/.*Symfony.*/',
|
||||
'Yii1' => '/.*Yii1.*/',
|
||||
'ZendExpressive' => '/.*ZendExpressive.*/',
|
||||
'Zend1' => '/.*ZF1.*/',
|
||||
'Zend2' => '/.*ZF2.*/',
|
||||
];
|
||||
|
||||
// First check if changes include files that are not framework files.
|
||||
$frameworkOnly = true;
|
||||
$frameworks = [];
|
||||
foreach ($files as $file) {
|
||||
$match = false;
|
||||
foreach ($regexes as $framework => $regex) {
|
||||
if (preg_match($regex, $file)) {
|
||||
$match = true;
|
||||
$frameworks[$framework] = $framework;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$match) {
|
||||
$frameworkOnly = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($frameworkOnly) {
|
||||
stderr('Changes limited to frameworks: ' . implode(', ', $frameworks));
|
||||
if (!isset($frameworks[$currentFramework])) {
|
||||
stderr("Skipping test for framework: $currentFramework");
|
||||
echo "export FRAMEWORK=\n";
|
||||
echo "export PECL=\n";
|
||||
echo "export FXP=\n";
|
||||
echo "export CI_USER_TOKEN=\n";
|
||||
}
|
||||
}
|
||||
977
vendor/codeception/base/RoboFile.php
vendored
Normal file
977
vendor/codeception/base/RoboFile.php
vendored
Normal file
@@ -0,0 +1,977 @@
|
||||
<?php
|
||||
require_once __DIR__.'/vendor/autoload.php';
|
||||
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Robo\Task\Development\GenerateMarkdownDoc as Doc;
|
||||
|
||||
class RoboFile extends \Robo\Tasks
|
||||
{
|
||||
const STABLE_BRANCH = '2.4';
|
||||
const REPO_BLOB_URL = 'https://github.com/Codeception/Codeception/blob';
|
||||
|
||||
public function release()
|
||||
{
|
||||
$this->say("CODECEPTION RELEASE: ".\Codeception\Codecept::VERSION);
|
||||
$this->update();
|
||||
$this->buildDocs();
|
||||
$this->publishDocs();
|
||||
$this->buildPhar();
|
||||
$this->buildPhar5();
|
||||
$this->publishPhar();
|
||||
$this->publishGit();
|
||||
$this->publishBase(null, \Codeception\Codecept::VERSION);
|
||||
$this->versionBump();
|
||||
$this->update(); //update dependencies after release, because buildPhar5 set them to old versions
|
||||
}
|
||||
|
||||
public function versionBump($version = '')
|
||||
{
|
||||
if (!$version) {
|
||||
$versionParts = explode('.', \Codeception\Codecept::VERSION);
|
||||
$versionParts[count($versionParts)-1]++;
|
||||
$version = implode('.', $versionParts);
|
||||
}
|
||||
$this->say("Bumping version to $version");
|
||||
$this->taskReplaceInFile('src/Codeception/Codecept.php')
|
||||
->from(\Codeception\Codecept::VERSION)
|
||||
->to($version)
|
||||
->run();
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$this->clean();
|
||||
$this->taskComposerUpdate()->dir('tests/data/claypit')->run();
|
||||
$this->taskComposerUpdate()->run();
|
||||
}
|
||||
|
||||
public function changed($change)
|
||||
{
|
||||
$this->taskChangelog()
|
||||
->version(\Codeception\Codecept::VERSION)
|
||||
->change($change)
|
||||
->run();
|
||||
}
|
||||
|
||||
protected function server()
|
||||
{
|
||||
$this->taskServer(8000)
|
||||
->background()
|
||||
->dir('tests/data/app')
|
||||
->run();
|
||||
}
|
||||
|
||||
public function testPhpbrowser($args = '', $opt = ['test|t' => null])
|
||||
{
|
||||
$test = $opt['test'] ? ':'.$opt['test'] : '';
|
||||
$this->server();
|
||||
$this->taskCodecept('./codecept')
|
||||
->args($args)
|
||||
->test('tests/unit/Codeception/Module/PhpBrowserTest.php'.$test)
|
||||
->run();
|
||||
}
|
||||
|
||||
public function testRestBrowser($args = '', $opt = ['test|t' => null])
|
||||
{
|
||||
$test = $opt['test'] ? ':'.$opt['test'] : '';
|
||||
$this->taskServer(8010)
|
||||
->background()
|
||||
->dir('tests/data')
|
||||
->run();
|
||||
|
||||
$this->taskCodecept('./codecept')
|
||||
->test('tests/unit/Codeception/Module/PhpBrowserRestTest.php'.$test)
|
||||
->args($args)
|
||||
->run();
|
||||
}
|
||||
|
||||
public function testCoverage()
|
||||
{
|
||||
$this->server();
|
||||
$this->taskSymfonyCommand(new \Codeception\Command\Run('run'))
|
||||
->arg('suite', 'coverage')
|
||||
->run();
|
||||
}
|
||||
|
||||
public function testWebdriver($args = '', $opt = ['test|t' => null])
|
||||
{
|
||||
$test = $opt['test'] ? ':'.$opt['test'] : '';
|
||||
|
||||
$this->taskServer(8000)
|
||||
->dir('tests/data/app')
|
||||
->background()
|
||||
->host('0.0.0.0')
|
||||
->run();
|
||||
|
||||
$this->taskCodecept('./codecept')
|
||||
->suite('web')
|
||||
->args($args)
|
||||
->run();
|
||||
}
|
||||
|
||||
public function testLaunchServer()
|
||||
{
|
||||
$this->taskServer(8010)
|
||||
->background()
|
||||
->dir('tests/data/rest')
|
||||
->run();
|
||||
$this->taskServer(8000)
|
||||
->dir('tests/data/app')
|
||||
->run();
|
||||
}
|
||||
|
||||
public function testCli()
|
||||
{
|
||||
$this->taskSymfonyCommand(new \Codeception\Command\Run('run'))
|
||||
->arg('suite', 'cli')
|
||||
->run();
|
||||
|
||||
$this->taskSymfonyCommand(new \Codeception\Command\Run('run'))
|
||||
->arg('suite', 'tests/unit/Codeception/Command')
|
||||
->run();
|
||||
}
|
||||
|
||||
private function installDependenciesForPhp5()
|
||||
{
|
||||
$this->taskReplaceInFile('composer.json')
|
||||
->regex('/"platform": \{.*?\}/')
|
||||
->to('"platform": {"php": "5.6.0"}')
|
||||
->run();
|
||||
|
||||
$this->taskComposerUpdate()->run();
|
||||
}
|
||||
|
||||
private function installDependenciesForPhp70()
|
||||
{
|
||||
$this->taskReplaceInFile('composer.json')
|
||||
->regex('/"platform": \{.*?\}/')
|
||||
->to('"platform": {"php": "7.0.0"}')
|
||||
->run();
|
||||
|
||||
$this->taskComposerUpdate()->run();
|
||||
}
|
||||
|
||||
private function revertComposerJsonChanges()
|
||||
{
|
||||
$this->taskReplaceInFile('composer.json')
|
||||
->regex('/"platform": \{.*?\}/')
|
||||
->to('"platform": {}')
|
||||
->run();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc creates codecept.phar
|
||||
* @throws Exception
|
||||
*/
|
||||
public function buildPhar()
|
||||
{
|
||||
$this->installDependenciesForPhp70();
|
||||
$this->packPhar('package/codecept.phar');
|
||||
$code = $this->taskExec('php codecept.phar')->dir('package')->run()->getExitCode();
|
||||
if ($code !== 0) {
|
||||
throw new Exception("There was problem compiling phar");
|
||||
}
|
||||
$this->revertComposerJsonChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc creates codecept.phar with Guzzle 5.3 and Symfony 2.8
|
||||
* @throws Exception
|
||||
*/
|
||||
public function buildPhar5()
|
||||
{
|
||||
if (!file_exists('package/php54')) {
|
||||
mkdir('package/php54');
|
||||
}
|
||||
$this->installDependenciesForPhp5();
|
||||
$this->packPhar('package/codecept5.phar');
|
||||
$this->_copy('package/codecept5.phar', 'package/php54/codecept.phar');
|
||||
$code = $this->taskExec('php codecept.phar')->dir('package/php54')->run()->getExitCode();
|
||||
if ($code !== 0) {
|
||||
throw new Exception("There was problem compiling phar");
|
||||
}
|
||||
$this->revertComposerJsonChanges();
|
||||
}
|
||||
|
||||
private function packPhar($pharFileName)
|
||||
{
|
||||
$pharTask = $this->taskPackPhar($pharFileName)
|
||||
->compress()
|
||||
->stub('package/stub.php');
|
||||
|
||||
$finder = Finder::create()
|
||||
->ignoreVCS(true)
|
||||
->name('*.php')
|
||||
->name('*.tpl.dist')
|
||||
->name('*.html.dist')
|
||||
->in('src');
|
||||
|
||||
foreach ($finder as $file) {
|
||||
$pharTask->addFile('src/'.$file->getRelativePathname(), $file->getRealPath());
|
||||
}
|
||||
|
||||
$finder = Finder::create()
|
||||
->ignoreVCS(true)
|
||||
->name('*.php')
|
||||
->in('ext');
|
||||
|
||||
foreach ($finder as $file) {
|
||||
$pharTask->addFile('ext/'.$file->getRelativePathname(), $file->getRealPath());
|
||||
}
|
||||
|
||||
$finder = Finder::create()->files()
|
||||
->ignoreVCS(true)
|
||||
->name('*.php')
|
||||
->name('*.css')
|
||||
->name('*.png')
|
||||
->name('*.js')
|
||||
->name('*.css')
|
||||
->name('*.eot')
|
||||
->name('*.svg')
|
||||
->name('*.ttf')
|
||||
->name('*.wof')
|
||||
->name('*.woff')
|
||||
->name('*.woff2')
|
||||
->name('*.png')
|
||||
->name('*.tpl.dist')
|
||||
->name('*.html.dist')
|
||||
->exclude('videlalvaro')
|
||||
->exclude('php-amqplib')
|
||||
->exclude('pheanstalk')
|
||||
->exclude('phpseclib')
|
||||
->exclude('codegyre')
|
||||
->exclude('monolog')
|
||||
->exclude('phpspec')
|
||||
->exclude('squizlabs')
|
||||
->exclude('Tests')
|
||||
->exclude('tests')
|
||||
->exclude('benchmark')
|
||||
->exclude('demo')
|
||||
->in('vendor');
|
||||
|
||||
|
||||
foreach ($finder as $file) {
|
||||
$pharTask->addStripped('vendor/'.$file->getRelativePathname(), $file->getRealPath());
|
||||
}
|
||||
|
||||
$pharTask->addFile('autoload.php', 'autoload.php')
|
||||
->addFile('codecept', 'package/bin')
|
||||
->addFile('shim.php', 'shim.php');
|
||||
|
||||
if (file_exists(__DIR__ .'phpunit5-loggers.php')) {
|
||||
$pharTask->addFile('phpunit5-loggers.php', 'phpunit5-loggers.php');
|
||||
}
|
||||
|
||||
$pharTask->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc generates modules reference from source files
|
||||
*/
|
||||
public function buildDocs()
|
||||
{
|
||||
$this->say('generating documentation from source files');
|
||||
$this->buildDocsModules();
|
||||
$this->buildDocsUtils();
|
||||
$this->buildDocsCommands();
|
||||
$this->buildDocsStub();
|
||||
$this->buildDocsApi();
|
||||
$this->buildDocsExtensions();
|
||||
}
|
||||
|
||||
public function buildDocsModules()
|
||||
{
|
||||
$this->taskCleanDir('docs/modules')->run();
|
||||
$this->say("Modules");
|
||||
$modules = Finder::create()->files()->name('*.php')->in(__DIR__ . '/src/Codeception/Module');
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$moduleName = basename(substr($module, 0, -4));
|
||||
$className = 'Codeception\Module\\' . $moduleName;
|
||||
$source = "https://github.com/Codeception/Codeception/tree/"
|
||||
.self::STABLE_BRANCH."/src/Codeception/Module/$moduleName.php";
|
||||
|
||||
$this->taskGenDoc('docs/modules/' . $moduleName . '.md')
|
||||
->docClass($className)
|
||||
->prepend('# '.$moduleName)
|
||||
->append('<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="'.$source.'">Help us to improve documentation. Edit module reference</a></div>')
|
||||
->processClassSignature(false)
|
||||
->processClassDocBlock(function (\ReflectionClass $c, $text) {
|
||||
return "$text\n## Actions";
|
||||
})->processProperty(false)
|
||||
->filterMethods(function (\ReflectionMethod $method) use ($className) {
|
||||
if ($method->isConstructor() or $method->isDestructor()) {
|
||||
return false;
|
||||
}
|
||||
if (!$method->isPublic()) {
|
||||
return false;
|
||||
}
|
||||
if (strpos($method->name, '_') === 0) {
|
||||
$doc = $method->getDocComment();
|
||||
try {
|
||||
$doc = $doc . $method->getPrototype()->getDocComment();
|
||||
} catch (\ReflectionException $e) {
|
||||
}
|
||||
|
||||
if (strpos($doc, '@api') === false) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
return true;
|
||||
})->processMethod(function (\ReflectionMethod $method, $text) use ($className, $moduleName) {
|
||||
$title = "\n### {$method->name}\n";
|
||||
if (strpos($method->name, '_') === 0) {
|
||||
$text = str_replace("@api\n", '', $text);
|
||||
$text = "\n*hidden API method, expected to be used from Helper classes*\n" . $text;
|
||||
$text = str_replace("{{MODULE_NAME}}", $moduleName, $text);
|
||||
};
|
||||
|
||||
if (!trim($text)) {
|
||||
return $title . "__not documented__\n";
|
||||
}
|
||||
|
||||
$text = str_replace(
|
||||
['@since', '@version'],
|
||||
[' * `Available since`', ' * `Available since`'],
|
||||
$text
|
||||
);
|
||||
$text = str_replace('@part ', ' * `[Part]` ', $text);
|
||||
$text = str_replace("@return mixed\n", '', $text);
|
||||
$text = preg_replace('~@return (.*?)~', ' * `return` $1', $text);
|
||||
$text = preg_replace("~^@(.*?)([$\s])~", ' * `$1` $2', $text);
|
||||
$result = $title . $text;
|
||||
return preg_replace('/\n(\s*\n){2,}/', "\n\n", $result);
|
||||
})->processMethodSignature(false)
|
||||
->reorderMethods('ksort')
|
||||
->run();
|
||||
}
|
||||
}
|
||||
|
||||
public function buildDocsUtils()
|
||||
{
|
||||
$this->say("Util Classes");
|
||||
$utils = ['Autoload', 'Fixtures', 'Locator', 'XmlBuilder', 'JsonType', 'HttpCode'];
|
||||
|
||||
foreach ($utils as $utilName) {
|
||||
$className = '\Codeception\Util\\' . $utilName;
|
||||
$source = self::REPO_BLOB_URL."/".self::STABLE_BRANCH."/src/Codeception/Util/$utilName.php";
|
||||
|
||||
$this->documentApiClass('docs/reference/' . $utilName . '.md', $className, $source);
|
||||
}
|
||||
}
|
||||
|
||||
public function buildDocsStub()
|
||||
{
|
||||
$this->say("Stub Classes");
|
||||
|
||||
$this->taskGenDoc('docs/reference/Stub.md')
|
||||
->docClass('Codeception\Stub')
|
||||
->filterMethods(function(\ReflectionMethod $method) {
|
||||
if ($method->isConstructor() or $method->isDestructor()) return false;
|
||||
if (!$method->isPublic()) return false;
|
||||
if (strpos($method->name, '_') === 0) return false;
|
||||
return true;
|
||||
})
|
||||
->processMethodDocBlock(
|
||||
function (\ReflectionMethod $m, $doc) {
|
||||
$doc = str_replace(array('@since'), array(' * available since version'), $doc);
|
||||
$doc = str_replace(array(' @', "\n@"), array(" * ", "\n * "), $doc);
|
||||
return $doc;
|
||||
})
|
||||
->processProperty(false)
|
||||
->run();
|
||||
|
||||
$mocksDocumentation = <<<EOF
|
||||
# Mocks
|
||||
|
||||
Declare mocks inside `Codeception\Test\Unit` class.
|
||||
If you want to use mocks outside it, check the reference for [Codeception/Stub](https://github.com/Codeception/Stub) library.
|
||||
EOF;
|
||||
|
||||
$this->taskGenDoc('docs/reference/Mock.md')
|
||||
->docClass('Codeception\Test\Feature\Stub')
|
||||
->docClass('Codeception\Stub\Expected')
|
||||
->processClassDocBlock(false)
|
||||
->processClassSignature(false)
|
||||
->prepend($mocksDocumentation)
|
||||
->filterMethods(function(\ReflectionMethod $method) {
|
||||
if ($method->isConstructor() or $method->isDestructor()) return false;
|
||||
if (!$method->isPublic()) return false;
|
||||
if (strpos($method->name, '_') === 0) return false;
|
||||
if (strpos($method->name, 'stub') === 0) return false;
|
||||
return true;
|
||||
})
|
||||
->run();
|
||||
}
|
||||
|
||||
public function buildDocsApi()
|
||||
{
|
||||
$this->say("API Classes");
|
||||
$apiClasses = ['Codeception\Module', 'Codeception\InitTemplate'];
|
||||
|
||||
foreach ($apiClasses as $apiClass) {
|
||||
$name = (new ReflectionClass($apiClass))->getShortName();
|
||||
$this->documentApiClass('docs/reference/' . $name . '.md', $apiClass, true);
|
||||
}
|
||||
}
|
||||
|
||||
public function buildDocsCommands()
|
||||
{
|
||||
$this->say("Commands");
|
||||
|
||||
$commands = Finder::create()->files()->name('*.php')->depth(0)->in(__DIR__ . '/src/Codeception/Command');
|
||||
|
||||
$commandGenerator = $this->taskGenDoc('docs/reference/Commands.md');
|
||||
foreach ($commands as $command) {
|
||||
$commandName = basename(substr($command, 0, -4));
|
||||
$className = '\Codeception\Command\\' . $commandName;
|
||||
$commandGenerator->docClass($className);
|
||||
}
|
||||
$commandGenerator
|
||||
->prepend("# Console Commands\n")
|
||||
->processClassSignature(function ($r, $text) {
|
||||
return "## ".$r->getShortName();
|
||||
})
|
||||
->filterMethods(function (ReflectionMethod $r) {
|
||||
return false;
|
||||
})
|
||||
->run();
|
||||
}
|
||||
|
||||
public function buildDocsExtensions()
|
||||
{
|
||||
$this->say('Extensions');
|
||||
|
||||
$extensions = Finder::create()->files()->sortByName()->name('*.php')->in(__DIR__ . '/ext');
|
||||
|
||||
$extGenerator= $this->taskGenDoc(__DIR__.'/ext/README.md');
|
||||
foreach ($extensions as $extension) {
|
||||
$extensionName = basename(substr($extension, 0, -4));
|
||||
$className = '\Codeception\Extension\\' . $extensionName;
|
||||
$extGenerator->docClass($className);
|
||||
}
|
||||
$extGenerator
|
||||
->prepend("# Official Extensions\n")
|
||||
->processClassSignature(function (ReflectionClass $r, $text) {
|
||||
$name = $r->getShortName();
|
||||
return "## $name\n\n[See Source](" . self::REPO_BLOB_URL."/".self::STABLE_BRANCH. "/ext/$name.php)";
|
||||
})
|
||||
->filterMethods(function (ReflectionMethod $r) {
|
||||
return false;
|
||||
})
|
||||
->filterProperties(function ($r) {
|
||||
return false;
|
||||
})
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc publishes generated phar to codeception.com
|
||||
*/
|
||||
public function publishPhar()
|
||||
{
|
||||
$this->cloneSite();
|
||||
$version = \Codeception\Codecept::VERSION;
|
||||
if (strpos($version, self::STABLE_BRANCH) === 0) {
|
||||
$this->say("publishing to release branch");
|
||||
copy('../codecept.phar', 'codecept.phar');
|
||||
if (!is_dir('php54')) {
|
||||
mkdir('php54');
|
||||
}
|
||||
copy('../php54/codecept.phar', 'php5/codecept.phar');
|
||||
$this->taskExec('git add codecept.phar')->run();
|
||||
$this->taskExec('git add php5/codecept.phar')->run();
|
||||
}
|
||||
|
||||
$this->taskFileSystemStack()
|
||||
->mkdir("releases/$version")
|
||||
->mkdir("releases/$version/php54")
|
||||
->copy('../codecept.phar', "releases/$version/codecept.phar")
|
||||
->copy('../php54/codecept.phar', "releases/$version/php54/codecept.phar")
|
||||
->run();
|
||||
|
||||
$this->taskGitStack()->add('-A')->run();
|
||||
|
||||
$sortByVersion = function (\SplFileInfo $a, \SplFileInfo $b) {
|
||||
return version_compare($a->getBaseName(), $b->getBaseName());
|
||||
};
|
||||
|
||||
$releases = array_reverse(
|
||||
iterator_to_array(Finder::create()->depth(0)->directories()->sort($sortByVersion)->in('releases'))
|
||||
);
|
||||
$branch = null;
|
||||
$releaseFile = $this->taskWriteToFile('builds.markdown')
|
||||
->line('---')
|
||||
->line('layout: page')
|
||||
->line('title: Codeception Builds')
|
||||
->line('---')
|
||||
->line('');
|
||||
|
||||
|
||||
foreach ($releases as $release) {
|
||||
$releaseName = $release->getBasename();
|
||||
$downloadUrl = "http://codeception.com/releases/$releaseName/codecept.phar";
|
||||
|
||||
list($major, $minor) = explode('.', $releaseName);
|
||||
if ("$major.$minor" != $branch) {
|
||||
$branch = "$major.$minor";
|
||||
$releaseFile->line("\n## $branch");
|
||||
if ($major < 2) {
|
||||
$releaseFile->line("*Requires: PHP 5.3 and higher + CURL*\n");
|
||||
} elseif ($major == 2 && $minor < 4) {
|
||||
$releaseFile->line("*Requires: PHP 5.4 and higher + CURL*\n");
|
||||
} else {
|
||||
$releaseFile->line("*Requires: PHP 5.6 and higher + CURL*\n");
|
||||
}
|
||||
$releaseFile->line("* **[Download Latest $branch Release]($downloadUrl)**");
|
||||
}
|
||||
$versionLine = "* [$releaseName]($downloadUrl)";
|
||||
|
||||
if (file_exists("releases/$releaseName/php54/codecept.phar")) {
|
||||
$downloadUrl = "http://codeception.com/releases/$releaseName/php54/codecept.phar";
|
||||
if (version_compare($releaseName, '2.4.0', '>=')) {
|
||||
$versionLine .= ", [for PHP 5.6]($downloadUrl)";
|
||||
} elseif (version_compare($releaseName, '2.3.0', '>=')) {
|
||||
$versionLine .= ", [for PHP 5.4 - 5.6]($downloadUrl)";
|
||||
} else {
|
||||
$versionLine .= ", [for PHP 5.4 or 5.5]($downloadUrl)";
|
||||
}
|
||||
}
|
||||
|
||||
$releaseFile->line($versionLine);
|
||||
}
|
||||
$releaseFile->run();
|
||||
|
||||
$this->publishSite();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates docs on codeception.com
|
||||
*
|
||||
*/
|
||||
public function publishDocs()
|
||||
{
|
||||
if (strpos(\Codeception\Codecept::VERSION, self::STABLE_BRANCH) !== 0) {
|
||||
$this->say("The ".\Codeception\Codecept::VERSION." is not in release branch. Site is not build");
|
||||
return;
|
||||
}
|
||||
$this->say('building site...');
|
||||
|
||||
$this->cloneSite();
|
||||
$this->taskCleanDir('docs')
|
||||
->run();
|
||||
$this->taskFileSystemStack()
|
||||
->mkdir('docs/reference')
|
||||
->mkdir('docs/modules')
|
||||
->run();
|
||||
|
||||
chdir('../..');
|
||||
|
||||
$this->say('building changelog');
|
||||
$this->taskWriteToFile('package/site/changelog.markdown')
|
||||
->line('---')
|
||||
->line('layout: page')
|
||||
->line('title: Codeception Changelog')
|
||||
->line('---')
|
||||
->line('')
|
||||
->line(
|
||||
'<div class="alert alert-warning">Download specific version at <a href="/builds">builds page</a></div>'
|
||||
)
|
||||
->line('')
|
||||
->line('# Changelog')
|
||||
->line('')
|
||||
->line($this->processChangelog())
|
||||
->run();
|
||||
|
||||
$docs = Finder::create()->files('*.md')->sortByName()->in('docs');
|
||||
|
||||
$modules = [];
|
||||
$api = [];
|
||||
$reference = [];
|
||||
foreach ($docs as $doc) {
|
||||
$newfile = $doc->getFilename();
|
||||
$name = substr($doc->getBasename(), 0, -3);
|
||||
$contents = $doc->getContents();
|
||||
if (strpos($doc->getPathname(), 'docs'.DIRECTORY_SEPARATOR.'modules') !== false) {
|
||||
$newfile = 'docs/modules/' . $newfile;
|
||||
$modules[$name] = '/docs/modules/' . $doc->getBasename();
|
||||
$contents = str_replace('## ', '### ', $contents);
|
||||
$buttons = [
|
||||
'source' => self::REPO_BLOB_URL."/".self::STABLE_BRANCH."/src/Codeception/Module/$name.php"
|
||||
];
|
||||
// building version switcher
|
||||
foreach (['master', '2.3', '2.2', '2.1', '2.0', '1.8'] as $branch) {
|
||||
$buttons[$branch] = self::REPO_BLOB_URL."/$branch/docs/modules/$name.md";
|
||||
}
|
||||
$buttonHtml = "\n\n".'<div class="btn-group" role="group" style="float: right" aria-label="...">';
|
||||
foreach ($buttons as $link => $url) {
|
||||
if ($link == self::STABLE_BRANCH) {
|
||||
$link = "<strong>$link</strong>";
|
||||
}
|
||||
$buttonHtml.= '<a class="btn btn-default" href="'.$url.'">'.$link.'</a>';
|
||||
}
|
||||
$buttonHtml .= '</div>'."\n\n";
|
||||
$contents = $buttonHtml . $contents;
|
||||
} elseif (strpos($doc->getPathname(), 'docs'.DIRECTORY_SEPARATOR.'reference') !== false) {
|
||||
$newfile = 'docs/reference/' . $newfile;
|
||||
$reference[$name] = '/docs/reference/' . $doc->getBasename();
|
||||
} else {
|
||||
$newfile = 'docs/'.$newfile;
|
||||
$api[substr($name, 3)] = '/docs/'.$doc->getBasename();
|
||||
}
|
||||
|
||||
copy($doc->getPathname(), 'package/site/' . $newfile);
|
||||
|
||||
$highlight_languages = implode('|', ['php', 'html', 'bash', 'yaml', 'json', 'xml', 'sql', 'gherkin']);
|
||||
$contents = preg_replace(
|
||||
"~```\s?($highlight_languages)\b(.*?)```~ms",
|
||||
"{% highlight $1 %}\n$2\n{% endhighlight %}",
|
||||
$contents
|
||||
);
|
||||
$contents = str_replace('{% highlight %}', '{% highlight yaml %}', $contents);
|
||||
$contents = preg_replace("~```\s?(.*?)```~ms", "{% highlight yaml %}\n$1\n{% endhighlight %}", $contents);
|
||||
// set default language in order not to leave unparsed code inside '```'
|
||||
|
||||
$matches = [];
|
||||
$title = $name;
|
||||
$contents = "---\nlayout: doc\ntitle: ".($title!="" ? $title." - " : "")
|
||||
."Codeception - Documentation\n---\n\n".$contents;
|
||||
|
||||
file_put_contents('package/site/' .$newfile, $contents);
|
||||
}
|
||||
chdir('package/site');
|
||||
$guides = array_keys($api);
|
||||
foreach ($api as $name => $url) {
|
||||
$filename = substr($url, 6);
|
||||
$doc = file_get_contents('docs/'.$filename)."\n\n\n";
|
||||
$i = array_search($name, $guides);
|
||||
if (isset($guides[$i+1])) {
|
||||
$next_title = $guides[$i+1];
|
||||
$next_url = $api[$guides[$i+1]];
|
||||
$next_url = substr($next_url, 0, -3);
|
||||
$doc .= "\n* **Next Chapter: [$next_title >]($next_url)**";
|
||||
}
|
||||
|
||||
if (isset($guides[$i-1])) {
|
||||
$prev_title = $guides[$i-1];
|
||||
$prev_url = $api[$guides[$i-1]];
|
||||
$prev_url = substr($prev_url, 0, -3);
|
||||
$doc .= "\n* **Previous Chapter: [< $prev_title]($prev_url)**";
|
||||
}
|
||||
|
||||
$this->taskWriteToFile('docs/'.$filename)
|
||||
->text($doc)
|
||||
->run();
|
||||
}
|
||||
|
||||
|
||||
$guides_list = '';
|
||||
foreach ($api as $name => $url) {
|
||||
$url = substr($url, 0, -3);
|
||||
$name = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\\1 \\2', $name);
|
||||
$name = preg_replace('/([a-z\d])([A-Z])/', '\\1 \\2', $name);
|
||||
$guides_list .= '<li><a href="'.$url.'">'.$name.'</a></li>';
|
||||
}
|
||||
file_put_contents('_includes/guides.html', $guides_list);
|
||||
|
||||
$this->say("Building Guides index");
|
||||
$this->taskWriteToFile('_includes/guides.html')
|
||||
->text($guides_list)
|
||||
->run();
|
||||
|
||||
$this->taskWriteToFile('docs/index.html')
|
||||
->line('---')
|
||||
->line('layout: doc')
|
||||
->line('title: Codeception Documentation')
|
||||
->line('---')
|
||||
->line('')
|
||||
->line("<h1>Codeception Documentation Guides</h1>")
|
||||
->line('')
|
||||
->text($guides_list)
|
||||
->run();
|
||||
|
||||
/**
|
||||
* Align modules in two columns like this:
|
||||
* A D
|
||||
* B E
|
||||
* C
|
||||
*/
|
||||
$modules_cols = 2;
|
||||
$modules_rows = ceil(count($modules) / $modules_cols);
|
||||
$module_names_chunked = array_chunk(array_keys($modules), $modules_rows);
|
||||
$modules_list = '';
|
||||
for ($i = 0; $i < $modules_rows; $i++) {
|
||||
for ($j = 0; $j < $modules_cols; $j++) {
|
||||
if (isset($module_names_chunked[$j][$i])) {
|
||||
$name = $module_names_chunked[$j][$i];
|
||||
$url = substr($modules[$name], 0, -3);
|
||||
$modules_list .= '<li><a href="'.$url.'">'.$name.'</a></li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
file_put_contents('_includes/modules.html', $modules_list);
|
||||
|
||||
$reference_list = '';
|
||||
foreach ($reference as $name => $url) {
|
||||
if ($name == 'Commands') {
|
||||
continue;
|
||||
}
|
||||
if ($name == 'Configuration') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$url = substr($url, 0, -3);
|
||||
$reference_list .= '<li><a href="'.$url.'">'.$name.'</a></li>';
|
||||
}
|
||||
file_put_contents('_includes/reference.html', $reference_list);
|
||||
|
||||
$this->say("Writing extensions docs");
|
||||
$this->taskWriteToFile('_includes/extensions.md')
|
||||
->textFromFile(__DIR__.'/ext/README.md')
|
||||
->run();
|
||||
|
||||
$this->publishSite();
|
||||
$this->taskExec('git add')->args('.')->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc creates a new version tag and pushes to github
|
||||
* @param null $branch
|
||||
* @param array $opt
|
||||
*/
|
||||
public function publishGit($branch = null, $opt = ['tag|t' => null])
|
||||
{
|
||||
$version = isset($opt['tag']) ? $opt['tag'] : \Codeception\Codecept::VERSION;
|
||||
$this->say('creating new tag for '.$version);
|
||||
if (!$branch) {
|
||||
$branch = explode('.', $version);
|
||||
array_pop($branch);
|
||||
$branch = implode('.', $branch);
|
||||
}
|
||||
$this->taskExec("git tag $version")->run();
|
||||
$this->taskExec("git push origin $branch --tags")->run();
|
||||
}
|
||||
|
||||
protected function processChangelog()
|
||||
{
|
||||
$sortByVersionDesc = function (\SplFileInfo $a, \SplFileInfo $b) {
|
||||
$pattern = '/^CHANGELOG-(\d+\.\d+).md$/';
|
||||
if (preg_match($pattern, $a->getBasename(), $matches1) && preg_match($pattern, $b->getBasename(), $matches2)) {
|
||||
return version_compare($matches1[1], $matches2[1]) * -1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
$changelogFiles = Finder::create()->name('CHANGELOG-*.md')->in('.')->depth(0)->sort($sortByVersionDesc);
|
||||
$changelog = '';
|
||||
foreach ($changelogFiles as $file) {
|
||||
$changelog .= $file->getContents();
|
||||
}
|
||||
|
||||
//user
|
||||
$changelog = preg_replace('~\s@([\w-]+)~', ' **[$1](https://github.com/$1)**', $changelog);
|
||||
|
||||
//issue
|
||||
$changelog = preg_replace(
|
||||
'~#(\d+)~',
|
||||
'[#$1](https://github.com/Codeception/Codeception/issues/$1)',
|
||||
$changelog
|
||||
);
|
||||
|
||||
//module
|
||||
$changelog = preg_replace('~\s\[(\w+)\]\s~', ' **[$1]** ', $changelog);
|
||||
|
||||
return $changelog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc cleans all log and temp directories
|
||||
*/
|
||||
public function clean()
|
||||
{
|
||||
$this->taskCleanDir([
|
||||
'tests/log',
|
||||
'tests/data/claypit/tests/_output',
|
||||
'tests/data/included/_log',
|
||||
'tests/data/included/jazz/tests/_log',
|
||||
'tests/data/included/shire/tests/_log',
|
||||
])->run();
|
||||
|
||||
$this->taskDeleteDir([
|
||||
'tests/data/claypit/c3tmp',
|
||||
'tests/data/sandbox'
|
||||
])->run();
|
||||
}
|
||||
|
||||
public function buildActors()
|
||||
{
|
||||
$build = 'php codecept build';
|
||||
$this->taskExec($build)->run();
|
||||
$this->taskExec($build)->args('-c tests/data/claypit')->run();
|
||||
$this->taskExec($build)->args('-c tests/data/included')->run();
|
||||
$this->taskExec($build)->args('-c tests/data/included/jazz')->run();
|
||||
$this->taskExec($build)->args('-c tests/data/included/shire')->run();
|
||||
$this->taskExec($build)->args('-c tests/data/included/jazz')->run();
|
||||
}
|
||||
|
||||
protected function cloneSite()
|
||||
{
|
||||
@mkdir("package/site");
|
||||
$this->taskExec('git clone')
|
||||
->args('git@github.com:Codeception/codeception.github.com.git')
|
||||
->args('package/site/')
|
||||
->run();
|
||||
chdir('package/site');
|
||||
}
|
||||
|
||||
protected function publishSite()
|
||||
{
|
||||
$this->taskGitStack()
|
||||
->add('-A')
|
||||
->commit('auto updated documentation')
|
||||
->push()
|
||||
->run();
|
||||
|
||||
chdir('..');
|
||||
sleep(2);
|
||||
$this->taskDeleteDir('site')->run();
|
||||
chdir('..');
|
||||
$this->say("Site build succesfully");
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes Codeception base
|
||||
* @param null $branch
|
||||
* @param null $tag
|
||||
*/
|
||||
public function publishBase($branch = null, $tag = null)
|
||||
{
|
||||
if (!$branch) {
|
||||
$branch = self::STABLE_BRANCH;
|
||||
}
|
||||
|
||||
$this->say("Updating Codeception Base distribution");
|
||||
|
||||
$tempBranch = "tmp".uniqid();
|
||||
|
||||
$this->taskGitStack()
|
||||
->checkout("-b $tempBranch")
|
||||
->run();
|
||||
|
||||
$this->taskReplaceInFile('composer.json')
|
||||
->from('"codeception/codeception"')
|
||||
->to('"codeception/base"')
|
||||
->run();
|
||||
|
||||
$this->taskReplaceInFile('composer.json')
|
||||
->regex('~^\s+"facebook\/webdriver".*$~m')
|
||||
->to('')
|
||||
->run();
|
||||
|
||||
$this->taskReplaceInFile('composer.json')
|
||||
->regex('~^\s+"guzzlehttp\/guzzle".*$~m')
|
||||
->to('')
|
||||
->run();
|
||||
|
||||
$this->taskComposerUpdate()->run();
|
||||
$this->taskGitStack()
|
||||
->add('composer.json')
|
||||
->commit('auto-update')
|
||||
->exec("push -f base $tempBranch:$branch")
|
||||
->run();
|
||||
|
||||
if ($tag) {
|
||||
$this->taskGitStack()
|
||||
->exec("tag -d $tag")
|
||||
->exec("push base :refs/tags/$tag")
|
||||
->exec("tag $tag")
|
||||
->push('base', $tag)
|
||||
->run();
|
||||
}
|
||||
|
||||
$this->taskGitStack()
|
||||
->checkout('-- composer.json')
|
||||
->checkout($branch)
|
||||
->exec("branch -D $tempBranch")
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks Codeception code style
|
||||
* Most useful values for `report` option: `full`, `summary`, `diff`
|
||||
*
|
||||
* @param array $opt
|
||||
*/
|
||||
public function codestyleCheck($opt = ['report|r' => 'summary'])
|
||||
{
|
||||
$this->say("Checking code style");
|
||||
|
||||
$this->taskExec('php vendor/bin/phpcs')
|
||||
->arg('.')
|
||||
->arg('--standard=ruleset.xml')
|
||||
->arg('--report=' . $opt['report'])
|
||||
->arg('--ignore=tests,vendor,package,docs')
|
||||
->run();
|
||||
}
|
||||
|
||||
public function codestyleFix()
|
||||
{
|
||||
$this->taskExec('php vendor/bin/phpcbf')
|
||||
->arg('.')
|
||||
->arg('--standard=ruleset.xml')
|
||||
->arg('--ignore=tests,vendor,package,docs')
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file
|
||||
* @param $className
|
||||
* @param $source
|
||||
*/
|
||||
protected function documentApiClass($file, $className, $all = false)
|
||||
{
|
||||
$uri = str_replace('\\', '/', $className);
|
||||
$source = self::REPO_BLOB_URL."/".self::STABLE_BRANCH."/src/$uri.php";
|
||||
|
||||
$this->taskGenDoc($file)
|
||||
->docClass($className)
|
||||
->filterMethods(function (ReflectionMethod $r) use ($all, $className) {
|
||||
return $all || $r->isPublic();
|
||||
})
|
||||
->append(
|
||||
'<p> </p><div class="alert alert-warning">Reference is taken from the source code. '
|
||||
. '<a href="' . $source . '">Help us to improve documentation. Edit module reference</a></div>'
|
||||
)
|
||||
->processPropertySignature(function ($r) {
|
||||
return "\n#### $" . $r->name. "\n\n";
|
||||
})
|
||||
->processPropertyDocBlock(function ($r, $text) {
|
||||
$modifiers = implode(' ', \Reflection::getModifierNames($r->getModifiers()));
|
||||
$text = ' *' . $modifiers . '* **$' . $r->name . "**\n" . $text;
|
||||
$text = preg_replace("~@(.*?)\s(.*)~", 'type `$2`', $text);
|
||||
return $text;
|
||||
})
|
||||
->processClassDocBlock(
|
||||
function (ReflectionClass $r, $text) {
|
||||
return $text . "\n";
|
||||
}
|
||||
)
|
||||
->processMethodSignature(function ($r, $text) {
|
||||
return "#### {$r->name}()\n\n" . ltrim($text, '#');
|
||||
})
|
||||
->processMethodDocBlock(
|
||||
function (ReflectionMethod $r, $text) use ($file) {
|
||||
$file = str_replace(__DIR__, '', $r->getFileName());
|
||||
$source = self::REPO_BLOB_URL."/".self::STABLE_BRANCH. $file;
|
||||
|
||||
$line = $r->getStartLine();
|
||||
$text = preg_replace("~^\s?@(.*?)\s~m", ' * `$1` $2', $text);
|
||||
$text .= "\n[See source]($source#L$line)";
|
||||
return "\n" . $text . "\n";
|
||||
}
|
||||
)
|
||||
->reorderMethods('ksort')
|
||||
->run();
|
||||
}
|
||||
}
|
||||
59
vendor/codeception/base/appveyor.yml
vendored
Normal file
59
vendor/codeception/base/appveyor.yml
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
build: false
|
||||
shallow_clone: true
|
||||
platform: 'x86'
|
||||
branches:
|
||||
except:
|
||||
- gh-pages
|
||||
|
||||
cache:
|
||||
- c:\tools\php71 -> appveyor.yml
|
||||
|
||||
services:
|
||||
- mysql
|
||||
- postgresql93
|
||||
- mongodb
|
||||
|
||||
init:
|
||||
- SET PATH=C:\Program Files\OpenSSL;c:\tools\php71;%PATH%
|
||||
- SET COMPOSER_NO_INTERACTION=1
|
||||
- SET PHP=1
|
||||
- SET ANSICON=121x90 (121x90)
|
||||
|
||||
install:
|
||||
# databases setup
|
||||
- SET PATH=C:\Program Files\MySql\MySQL Server 5.7\bin\;%PATH%
|
||||
- SET PGUSER=postgres
|
||||
- SET PGPASSWORD=Password12!
|
||||
- SET PATH=C:\Program Files\PostgreSQL\9.3\bin\;%PATH%
|
||||
# php setup
|
||||
- IF EXIST c:\tools\php71 (SET PHP=0)
|
||||
- IF %PHP%==1 cinst -y OpenSSL.Light
|
||||
- SET PATH=C:\Program Files\OpenSSL;%PATH%
|
||||
- cinst -y curl
|
||||
- SET PATH=C:\Program Files\curl;%PATH%
|
||||
- sc config wuauserv start= auto
|
||||
- net start wuauserv
|
||||
- IF %PHP%==1 cinst -y php --version 7.1.14
|
||||
- IF %PHP%==1 cd c:\tools\php71
|
||||
- IF %PHP%==1 copy php.ini-production php.ini
|
||||
- IF %PHP%==1 echo extension_dir=ext >> php.ini
|
||||
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini
|
||||
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini
|
||||
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini
|
||||
- IF %PHP%==1 echo extension=php_curl.dll >> php.ini
|
||||
- IF %PHP%==1 echo extension=php_pdo_mysql.dll >> php.ini
|
||||
- IF %PHP%==1 echo extension=php_pdo_pgsql.dll >> php.ini
|
||||
- IF %PHP%==1 echo extension=php_pdo_sqlite.dll >> php.ini
|
||||
- IF %PHP%==1 echo extension=php_pgsql.dll >> php.ini
|
||||
- SET PATH=C:\tools\php71;%PATH%
|
||||
- cd %APPVEYOR_BUILD_FOLDER%
|
||||
- appveyor DownloadFile https://getcomposer.org/composer.phar
|
||||
- php composer.phar install --prefer-dist -n --no-ansi
|
||||
|
||||
before_test:
|
||||
- createdb codeception_test
|
||||
- mysql -uroot -pPassword12! -e "CREATE DATABASE codeception_test"
|
||||
|
||||
test_script:
|
||||
- php codecept run cli --no-colors -n --skip-group coverage
|
||||
- php codecept run unit -g core -g appveyor --no-colors -n
|
||||
136
vendor/codeception/base/autoload.php
vendored
Normal file
136
vendor/codeception/base/autoload.php
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
$autoloadFile = './vendor/codeception/codeception/autoload.php';
|
||||
if (file_exists('./vendor/autoload.php') && file_exists($autoloadFile) && __FILE__ != realpath($autoloadFile)) {
|
||||
//for global installation or phar file
|
||||
fwrite(
|
||||
STDERR,
|
||||
"\n==== Redirecting to Composer-installed version in vendor/codeception ====\n"
|
||||
);
|
||||
require $autoloadFile;
|
||||
//require package/bin instead of codecept to avoid printing hashbang line
|
||||
require './vendor/codeception/codeception/package/bin';
|
||||
die;
|
||||
} elseif (file_exists(__DIR__ . '/vendor/autoload.php')) {
|
||||
// for phar
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
} elseif (file_exists(__DIR__ . '/../../autoload.php')) {
|
||||
//for composer
|
||||
require_once __DIR__ . '/../../autoload.php';
|
||||
}
|
||||
unset($autoloadFile);
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
|
||||
include_once __DIR__ . DIRECTORY_SEPARATOR . 'shim.php';
|
||||
// compat
|
||||
if (PHP_MAJOR_VERSION < 7) {
|
||||
if (false === interface_exists('Throwable', false)) {
|
||||
interface Throwable {};
|
||||
}
|
||||
if (false === class_exists('ParseError', false)) {
|
||||
class ParseError extends \Exception {};
|
||||
}
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
if (!function_exists('json_last_error_msg')) {
|
||||
/**
|
||||
* Copied from http://php.net/manual/en/function.json-last-error-msg.php#117393
|
||||
* @return string
|
||||
*/
|
||||
function json_last_error_msg()
|
||||
{
|
||||
static $errors = array(
|
||||
JSON_ERROR_NONE => 'No error',
|
||||
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
|
||||
JSON_ERROR_STATE_MISMATCH => 'State mismatch (invalid or malformed JSON)',
|
||||
JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
|
||||
JSON_ERROR_SYNTAX => 'Syntax error',
|
||||
JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded'
|
||||
);
|
||||
|
||||
$error = json_last_error();
|
||||
return isset($errors[$error]) ? $errors[$error] : 'Unknown error';
|
||||
}
|
||||
}
|
||||
|
||||
// function not autoloaded in PHP, thus its a good place for them
|
||||
if (!function_exists('codecept_debug')) {
|
||||
function codecept_debug($data)
|
||||
{
|
||||
\Codeception\Util\Debug::debug($data);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('codecept_root_dir')) {
|
||||
function codecept_root_dir($appendPath = '')
|
||||
{
|
||||
return \Codeception\Configuration::projectDir() . $appendPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('codecept_output_dir')) {
|
||||
function codecept_output_dir($appendPath = '')
|
||||
{
|
||||
return \Codeception\Configuration::outputDir() . $appendPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('codecept_log_dir')) {
|
||||
function codecept_log_dir($appendPath = '')
|
||||
{
|
||||
return \Codeception\Configuration::outputDir() . $appendPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('codecept_data_dir')) {
|
||||
function codecept_data_dir($appendPath = '')
|
||||
{
|
||||
return \Codeception\Configuration::dataDir() . $appendPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('codecept_relative_path')) {
|
||||
function codecept_relative_path($path)
|
||||
{
|
||||
return \Codeception\Util\PathResolver::getRelativeDir(
|
||||
$path,
|
||||
\Codeception\Configuration::projectDir(),
|
||||
DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('codecept_absolute_path')) {
|
||||
/**
|
||||
* If $path is absolute, it will be returned without changes.
|
||||
* If $path is relative, it will be passed to `codecept_root_dir()` function
|
||||
* to make it absolute.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string the absolute path
|
||||
*/
|
||||
function codecept_absolute_path($path)
|
||||
{
|
||||
return codecept_is_path_absolute($path) ? $path : codecept_root_dir($path);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('codecept_is_path_absolute')) {
|
||||
/**
|
||||
* Check whether the given $path is absolute.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
* @since 2.4.4
|
||||
*/
|
||||
function codecept_is_path_absolute($path)
|
||||
{
|
||||
if (DIRECTORY_SEPARATOR === '/') {
|
||||
return mb_substr($path, 0, 1) === DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
return preg_match('#^[A-Z]:(?![^/\\\])#i', $path) === 1;
|
||||
}
|
||||
}
|
||||
42
vendor/codeception/base/codecept
vendored
Normal file
42
vendor/codeception/base/codecept
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* Codeception CLI
|
||||
*/
|
||||
|
||||
require_once __DIR__.'/autoload.php';
|
||||
|
||||
use Codeception\Application;
|
||||
|
||||
$app = new Application('Codeception', Codeception\Codecept::VERSION);
|
||||
$app->add(new Codeception\Command\Build('build'));
|
||||
$app->add(new Codeception\Command\Run('run'));
|
||||
$app->add(new Codeception\Command\Init('init'));
|
||||
$app->add(new Codeception\Command\Console('console'));
|
||||
$app->add(new Codeception\Command\Bootstrap('bootstrap'));
|
||||
$app->add(new Codeception\Command\GenerateCept('generate:cept'));
|
||||
$app->add(new Codeception\Command\GenerateCest('generate:cest'));
|
||||
$app->add(new Codeception\Command\GenerateTest('generate:test'));
|
||||
$app->add(new Codeception\Command\GenerateSuite('generate:suite'));
|
||||
$app->add(new Codeception\Command\GenerateHelper('generate:helper'));
|
||||
$app->add(new Codeception\Command\GenerateScenarios('generate:scenarios'));
|
||||
$app->add(new Codeception\Command\Clean('clean'));
|
||||
$app->add(new Codeception\Command\GenerateGroup('generate:groupobject'));
|
||||
$app->add(new Codeception\Command\GeneratePageObject('generate:pageobject'));
|
||||
$app->add(new Codeception\Command\GenerateStepObject('generate:stepobject'));
|
||||
$app->add(new Codeception\Command\GenerateEnvironment('generate:environment'));
|
||||
$app->add(new Codeception\Command\GenerateFeature('generate:feature'));
|
||||
$app->add(new Codeception\Command\GherkinSnippets('gherkin:snippets'));
|
||||
$app->add(new Codeception\Command\GherkinSteps('gherkin:steps'));
|
||||
$app->add(new Codeception\Command\DryRun('dry-run'));
|
||||
$app->add(new Codeception\Command\ConfigValidate('config:validate'));
|
||||
|
||||
// Suggests package
|
||||
if (class_exists('Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand')) {
|
||||
$app->add(new Codeception\Command\Completion());
|
||||
} else {
|
||||
$app->add(new Codeception\Command\CompletionFallback());
|
||||
}
|
||||
|
||||
$app->registerCustomCommands();
|
||||
$app->run();
|
||||
11
vendor/codeception/base/codecept.bat
vendored
Normal file
11
vendor/codeception/base/codecept.bat
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
if "%PHPBIN%" == "" set PHPBIN=@php_bin@
|
||||
if exist "codecept" goto INTERNAL
|
||||
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
|
||||
GOTO RUN
|
||||
:USE_PEAR_PATH
|
||||
set PHPBIN=%PHP_PEAR_PHP_BIN%
|
||||
:RUN
|
||||
"%PHPBIN%" "@bin_dir@\codecept" %*
|
||||
:INTERNAL
|
||||
"%PHPBIN%" "codecept" %*
|
||||
46
vendor/codeception/base/codeception.yml
vendored
Normal file
46
vendor/codeception/base/codeception.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
paths:
|
||||
tests: tests
|
||||
log: tests/log
|
||||
data: tests/data
|
||||
support: tests/support
|
||||
envs: tests/envs
|
||||
settings:
|
||||
shuffle: true
|
||||
bootstrap: _bootstrap.php
|
||||
suite_class: \PHPUnit_Framework_TestSuite
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
log: true
|
||||
lint: false
|
||||
report_useless_tests: false
|
||||
disallow_test_output: false
|
||||
be_strict_about_changes_to_global_state: false
|
||||
log_incomplete_skipped: false
|
||||
|
||||
modules:
|
||||
config:
|
||||
AMQP:
|
||||
host: 'localhost'
|
||||
port: '5672'
|
||||
username: 'guest'
|
||||
password: 'guest'
|
||||
vhost: '/'
|
||||
queues: [queue1, queue2]
|
||||
|
||||
extensions:
|
||||
enabled: [Codeception\Extension\RunFailed]
|
||||
config:
|
||||
Codeception\Extension\RunFailed:
|
||||
fail-group: failed
|
||||
|
||||
coverage:
|
||||
enabled: true
|
||||
include:
|
||||
- src/Codeception/Command/*
|
||||
- src/Codeception/Module/Symfony1.php
|
||||
- src/Codeception/Module/Symfony2.php
|
||||
- src/Codeception/Module/Doctrine1.php
|
||||
- src/Codeception/Module/Doctrine2.php
|
||||
- src/Codeception/Module/Kohana.php
|
||||
- src/Codeception/Module/SocialEngine.php
|
||||
- src/Codeception/Module/ZF1.php
|
||||
73
vendor/codeception/base/composer.json
vendored
Normal file
73
vendor/codeception/base/composer.json
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name":"codeception/base",
|
||||
"description":"BDD-style testing framework",
|
||||
"keywords":["BDD", "acceptance testing", "functional testing", "unit testing", "tdd"],
|
||||
"homepage":"http://codeception.com/",
|
||||
"type":"library",
|
||||
"license":"MIT",
|
||||
"authors":[
|
||||
{
|
||||
"name":"Michael Bodnarchuk",
|
||||
"email":"davert@mail.ua",
|
||||
"homepage":"http://codegyre.com"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "RC",
|
||||
|
||||
"require": {
|
||||
"php": ">=5.6.0 <8.0",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
|
||||
"guzzlehttp/psr7": "~1.0",
|
||||
"symfony/finder": ">=2.7 <5.0",
|
||||
"symfony/console": ">=2.7 <5.0",
|
||||
"symfony/event-dispatcher": ">=2.7 <5.0",
|
||||
"symfony/yaml": ">=2.7 <5.0",
|
||||
"symfony/browser-kit": ">=2.7 <5.0",
|
||||
"symfony/css-selector": ">=2.7 <5.0",
|
||||
"symfony/dom-crawler": ">=2.7 <5.0",
|
||||
"behat/gherkin": "^4.4.0",
|
||||
"codeception/phpunit-wrapper": "^6.0.9|^7.0.6",
|
||||
"codeception/stub": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"monolog/monolog": "~1.8",
|
||||
"facebook/graph-sdk": "~5.3",
|
||||
"php-amqplib/php-amqplib": "~2.4",
|
||||
"codeception/specify": "~0.3",
|
||||
"pda/pheanstalk": "~3.0",
|
||||
"flow/jsonpath": "~0.2",
|
||||
"predis/predis": "^1.0",
|
||||
"squizlabs/php_codesniffer": "~2.0",
|
||||
"vlucas/phpdotenv": "^2.4.0",
|
||||
"symfony/process": ">=2.7 <5.0"
|
||||
},
|
||||
"suggest": {
|
||||
"aws/aws-sdk-php": "For using AWS Auth in REST module and Queue module",
|
||||
"codeception/specify": "BDD-style code blocks",
|
||||
"codeception/verify": "BDD-style assertions",
|
||||
"codeception/phpbuiltinserver": "Start and stop PHP built-in web server for your tests",
|
||||
"flow/jsonpath": "For using JSONPath in REST module",
|
||||
"phpseclib/phpseclib": "for SFTP option in FTP Module",
|
||||
"league/factory-muffin": "For DataFactory module",
|
||||
"league/factory-muffin-faker": "For Faker support in DataFactory module",
|
||||
"symfony/phpunit-bridge": "For phpunit-bridge support",
|
||||
"stecman/symfony-console-completion": "For BASH autocompletion"
|
||||
},
|
||||
|
||||
"autoload":{
|
||||
"psr-4":{
|
||||
"Codeception\\": "src\\Codeception",
|
||||
"Codeception\\Extension\\": "ext"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
}
|
||||
},
|
||||
"bin":["codecept"],
|
||||
"config": {
|
||||
"platform": {}
|
||||
}
|
||||
}
|
||||
119
vendor/codeception/base/docs/01-Introduction.md
vendored
Normal file
119
vendor/codeception/base/docs/01-Introduction.md
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
# Introduction
|
||||
|
||||
The idea behind testing is not new. You can't sleep well if you are not confident
|
||||
that your last commit didn't take down the whole application.
|
||||
Having your application covered with tests gives you more trust in the stability of your application. That's all.
|
||||
|
||||
In most cases tests don't guarantee that the application works 100% as it is supposed to.
|
||||
You can't predict all possible scenarios and exceptional situations for complex apps,
|
||||
but with tests you can cover the most important parts of your app and at least be sure they work as predicted.
|
||||
|
||||
There are plenty of ways to test your application.
|
||||
The most popular paradigm is [Unit Testing](http://en.wikipedia.org/wiki/Unit_testing).
|
||||
For web applications, testing just the controller and/or the model doesn't prove that your application is working.
|
||||
To test the behavior of your application as a whole, you should write functional or acceptance tests.
|
||||
|
||||
Codeception supports all three testing types.
|
||||
Out of the box you have tools for writing unit, functional, and acceptance tests in a unified framework.
|
||||
|
||||
| | Codeception Unit Tests | Codeception Functional Tests | Codeception Acceptance Tests
|
||||
| --- | --- | --- | --- |
|
||||
| Scope of the test | Single PHP class | PHP Framework (Routing, Controllers, etc.) | Page in browser (Chrome, Firefox, or PhpBrowser) |
|
||||
| Testing computer needs access to project's PHP files | Yes | Yes | No |
|
||||
| Webserver required | No | No | Yes |
|
||||
| JavaScript | No | No | Yes |
|
||||
| Additional software required | None | None | <ul><li>For WebDriver: Selenium Server or PhantomJS (deprecated)</li><li>For PhpBrowser: None</li></ul> |
|
||||
| Test execution speed | High | High | Low |
|
||||
| Configuration file | `unit.suite.yml` | `functional.suite.yml` | `acceptance.suite.yml` |
|
||||
|
||||
One of the main advantages of Codeception is that you don't have to decide on just *one* type of testing. You can have all three!
|
||||
And chances are, that you will (sooner or later) need all three. That's why Codeception consists of three so-called "suites":
|
||||
A "unit suite" for all unit tests, a "functional suite" for all functional tests, and an "acceptance suite" for all acceptance tests.
|
||||
|
||||
Let's review those three testing types in reverse order.
|
||||
|
||||
### Acceptance Tests
|
||||
|
||||
How does your client, manager, tester, or any other non-technical person know your website is working?
|
||||
By opening the browser, accessing the site, clicking on links, filling in the forms,
|
||||
and actually seeing the content on a web page. They have no idea of the programming language, framework, database, web-server,
|
||||
or why the application did (or did not) behave as expected.
|
||||
|
||||
This is what acceptance tests are doing. They cover scenarios from a user's perspective.
|
||||
With acceptance tests, you can be confident that users, following all the defined scenarios, won't get errors.
|
||||
|
||||
**Any website** can be covered with acceptance tests, even if you use a very exotic CMS or framework.
|
||||
|
||||
#### Sample acceptance test
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->amOnPage('/');
|
||||
$I->click('Sign Up');
|
||||
$I->submitForm('#signup', ['username' => 'MilesDavis', 'email' => 'miles@davis.com']);
|
||||
$I->see('Thank you for Signing Up!');
|
||||
```
|
||||
|
||||
### Functional Tests
|
||||
|
||||
What if we could check our application without running it on a server?
|
||||
That way we could see detailed exceptions on errors, have our tests run faster,
|
||||
and check the database against predictable and expected results. That's what functional tests are for.
|
||||
|
||||
For functional tests, you emulate a web request (`$_GET` and `$_POST` variables)
|
||||
which returns the HTML response. Inside a test, you can make assertions about the response,
|
||||
and you can check if the data was successfully stored in the database.
|
||||
|
||||
For functional tests, your application needs to be structured in order to run in a test environment.
|
||||
Codeception provides connectors to several popular PHP frameworks. You can also write your own.
|
||||
|
||||
#### Sample functional test
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->amOnPage('/');
|
||||
$I->click('Sign Up');
|
||||
$I->submitForm('#signup', ['username' => 'MilesDavis', 'email' => 'miles@davis.com']);
|
||||
$I->see('Thank you for Signing Up!');
|
||||
$I->seeEmailSent('miles@davis.com', 'Thank you for registration');
|
||||
$I->seeInDatabase('users', ['email' => 'miles@davis.com']);
|
||||
```
|
||||
|
||||
### Unit Tests
|
||||
|
||||
Testing pieces of code before coupling them together is highly important as well. This way,
|
||||
you can be sure that some deeply hidden feature still works, even if it was not covered by functional or acceptance tests.
|
||||
This also shows care in producing stable and testable code.
|
||||
|
||||
Codeception is created on top of [PHPUnit](http://www.phpunit.de/). If you have experience writing unit tests with PHPUnit
|
||||
you can continue doing so. Codeception has no problem executing standard PHPUnit tests,
|
||||
but, additionally, Codeception provides some well-built tools to make your unit tests simpler and cleaner.
|
||||
|
||||
Requirements and code can change rapidly,
|
||||
and unit tests should be updated every time to fit the requirements.
|
||||
The better you understand the testing scenario, the faster you can update it for new behavior.
|
||||
|
||||
#### Sample integration test
|
||||
|
||||
```php
|
||||
<?php
|
||||
function testSavingUser()
|
||||
{
|
||||
$user = new User();
|
||||
$user->setName('Miles');
|
||||
$user->setSurname('Davis');
|
||||
$user->save();
|
||||
$this->assertEquals('Miles Davis', $user->getFullName());
|
||||
$this->tester->seeInDatabase('users', ['name' => 'Miles', 'surname' => 'Davis']);
|
||||
}
|
||||
```
|
||||
|
||||
## Conclusion
|
||||
|
||||
Despite the wide popularity of *TDD* (Test Driven Development), some PHP developers never write automated tests for their applications mostly because they think it's hard, slow or boring.
|
||||
The Codeception framework was developed to actually make testing fun.
|
||||
It allows writing unit, functional, integration, and acceptance tests in a single, coherent style.
|
||||
|
||||
It can be called a *BDD* (Behavior Driven Development) framework. All Codeception tests are written in a descriptive manner.
|
||||
Just by looking at the test body, you can clearly understand what is being tested and how it is performed.
|
||||
Even complex tests with many assertions are written in a simple PHP Domain-Specific Language (*DSL*).
|
||||
331
vendor/codeception/base/docs/02-GettingStarted.md
vendored
Normal file
331
vendor/codeception/base/docs/02-GettingStarted.md
vendored
Normal file
@@ -0,0 +1,331 @@
|
||||
# Getting Started
|
||||
|
||||
Let's take a look at Codeception's architecture. We'll assume that you have already [installed](http://codeception.com/install) it
|
||||
and bootstrapped your first test suites. Codeception has generated three of them: unit, functional, and acceptance.
|
||||
They are well described in the [previous chapter](http://codeception.com/docs/01-Introduction). Inside your __/tests__ folder you will have three `.yml` config files and three directories
|
||||
with names corresponding to these suites: `unit`, `functional`, `acceptance`. Suites are independent groups of tests with a common purpose.
|
||||
|
||||
## The Codeception Syntax
|
||||
|
||||
Codeception follows simple naming rules to make it easy to remember (as well as easy to understand) its method names.
|
||||
|
||||
* **Actions** start with a plain english verb, like "click" or "fill". Examples:
|
||||
```php
|
||||
<?php
|
||||
$I->click('Login');
|
||||
$I->fillField('#input-username', 'John Dough');
|
||||
$I->pressKey('#input-remarks', 'foo');
|
||||
```
|
||||
* **Assertions** always start with "see" or "dontSee". Examples:
|
||||
```php
|
||||
<?php
|
||||
$I->see('Welcome');
|
||||
$I->seeInTitle('My Company');
|
||||
$I->seeElement('nav');
|
||||
$I->dontSeeElement('#error-message');
|
||||
$I->dontSeeInPageSource('<section class="foo">');
|
||||
```
|
||||
* **Grabbers** just *read* something from the page, but don't process it. The return value of those are meant to be saved as variables and used later. Example:
|
||||
```php
|
||||
<?php
|
||||
$method = $I->grabAttributeFrom('#login-form', 'method');
|
||||
$I->assertEquals('post', $method);
|
||||
```
|
||||
|
||||
## Actors
|
||||
|
||||
One of the main concepts of Codeception is representation of tests as actions of a person.
|
||||
We have a UnitTester, who executes functions and tests the code. We also have a FunctionalTester, a qualified tester,
|
||||
who tests the application as a whole, with knowledge of its internals. Lastly we have an AcceptanceTester, a user who works with our application
|
||||
through an interface that we provide.
|
||||
|
||||
**Methods of actor classes are generally taken from [Codeception Modules](http://codeception.com/docs/06-ModulesAndHelpers)**.
|
||||
Each module provides predefined actions for different testing purposes, and they can be combined to fit the testing environment.
|
||||
Codeception tries to solve 90% of possible testing issues in its modules, so you don't have to reinvent the wheel.
|
||||
We think that you can spend more time on writing tests and less on writing support code to make those tests run.
|
||||
By default, AcceptanceTester relies on PhpBrowser module, which is set in the `tests/acceptance.suite.yml` configuration file:
|
||||
|
||||
```yaml
|
||||
actor: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- PhpBrowser:
|
||||
url: http://localhost/myapp/
|
||||
- \Helper\Acceptance
|
||||
```
|
||||
|
||||
In this configuration file you can enable/disable and reconfigure modules for your needs.
|
||||
When you change the configuration, the actor classes are rebuilt automatically. If the actor classes are not created or updated as you expect,
|
||||
try to generate them manually with the `build` command:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept build
|
||||
```
|
||||
|
||||
## Writing a Sample Test
|
||||
|
||||
Codeception has its own testing format called Cest (Codecept + Test).
|
||||
To start writing a test we need to create a new Cest file. We can do that by running the following command:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept generate:cest acceptance Signin
|
||||
```
|
||||
|
||||
This will generate `SigninCest.php` file inside `tests/acceptance` directory. Let's open it:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class SigninCest
|
||||
{
|
||||
function _before(AcceptanceTester $I)
|
||||
{
|
||||
}
|
||||
|
||||
public function _after(AcceptanceTester $I)
|
||||
{
|
||||
}
|
||||
|
||||
public function tryToTest(AcceptanceTester $I)
|
||||
{
|
||||
// todo: write test
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We have `_before` and `_after` methods to run some common actions before and after a test. And we have a placeholder action `tryToTest` which we need to implement.
|
||||
If we try to test a signin process it's a good start to test a successful signin. Let's rename this method to `signInSuccessfully`.
|
||||
|
||||
We'll assume that we have a 'login' page where we get authenticated by providing a username and password.
|
||||
Then we are sent to a user page, where we see the text `Hello, %username%`. Let's look at how this scenario is written in Codeception:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class SigninCest
|
||||
{
|
||||
public function loginSuccessfully(AcceptanceTester $I)
|
||||
{
|
||||
$I->amOnPage('/login');
|
||||
$I->fillField('Username','davert');
|
||||
$I->fillField('Password','qwerty');
|
||||
$I->click('Login');
|
||||
$I->see('Hello, davert');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This scenario can probably be read by non-technical people. If you just remove all special chars like braces, arrows and `$`,
|
||||
this test transforms into plain English text:
|
||||
|
||||
```
|
||||
I amOnPage '/login'
|
||||
I fillField 'Username','davert'
|
||||
I fillField 'Password','qwerty'
|
||||
I click 'Login'
|
||||
I see 'Hello, davert'
|
||||
```
|
||||
|
||||
Codeception generates this text representation from PHP code by executing:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept generate:scenarios
|
||||
```
|
||||
|
||||
These generated scenarios will be stored in your `_data` directory in text files.
|
||||
|
||||
Before we execute this test, we should make sure that the website is running on a local web server.
|
||||
Let's open the `tests/acceptance.suite.yml` file and replace the URL with the URL of your web application:
|
||||
|
||||
```yaml
|
||||
actor: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- PhpBrowser:
|
||||
url: 'http://myappurl.local'
|
||||
- \Helper\Acceptance
|
||||
```
|
||||
|
||||
After configuring the URL we can run this test with the `run` command:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run
|
||||
```
|
||||
|
||||
This is the output we should see:
|
||||
|
||||
```bash
|
||||
Acceptance Tests (1) -------------------------------
|
||||
✔ SigninCest: sign in successfully
|
||||
----------------------------------------------------
|
||||
|
||||
Time: 1 second, Memory: 21.00Mb
|
||||
|
||||
OK (1 test, 1 assertions)
|
||||
```
|
||||
|
||||
Let's get some detailed output:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run acceptance --steps
|
||||
```
|
||||
|
||||
We should see a step-by-step report on the performed actions:
|
||||
|
||||
```bash
|
||||
Acceptance Tests (1) -------------------------------
|
||||
SigninCest: Login to website
|
||||
Signature: SigninCest.php:signInSuccessfully
|
||||
Test: tests/acceptance/SigninCest.php:signInSuccessfully
|
||||
Scenario --
|
||||
I am on page "/login"
|
||||
I fill field "Username" "davert"
|
||||
I fill field "Password" "qwerty"
|
||||
I click "Login"
|
||||
I see "Hello, davert"
|
||||
OK
|
||||
----------------------------------------------------
|
||||
|
||||
Time: 0 seconds, Memory: 21.00Mb
|
||||
|
||||
OK (1 test, 1 assertions)
|
||||
```
|
||||
|
||||
This simple test can be extended to a complete scenario of site usage, therefore,
|
||||
by emulating the user's actions, you can test any of your websites.
|
||||
|
||||
To run more tests create a public method for each of them. Include `AcceptanceTester` object as `$I` as a method parameter and use the same `$I->` API you've seen before.
|
||||
If your tests share common setup actions put them into `_before` method.
|
||||
|
||||
For instance, to test CRUD we want 4 methods to be implemented and all next tests should start at `/task` page:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class TaskCrudCest
|
||||
{
|
||||
function _before(AcceptanceTester $I)
|
||||
{
|
||||
// will be executed at the beginning of each test
|
||||
$I->amOnPage('/task');
|
||||
}
|
||||
|
||||
function createTask(AcceptanceTester $I)
|
||||
{
|
||||
// todo: write test
|
||||
}
|
||||
|
||||
function viewTask(AcceptanceTester $I)
|
||||
{
|
||||
// todo: write test
|
||||
}
|
||||
|
||||
function updateTask(AcceptanceTester $I)
|
||||
{
|
||||
// todo: write test
|
||||
}
|
||||
|
||||
function deleteTask(AcceptanceTester $I)
|
||||
{
|
||||
// todo: write test
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Learn more about the [Cest format](http://codeception.com/docs/07-AdvancedUsage#Cest-Classes) in the Advanced Testing section.
|
||||
|
||||
## BDD
|
||||
|
||||
Codeception allows execution of user stories in Gherkin format in a similar manner as is done in Cucumber or Behat.
|
||||
Please refer to [the BDD chapter](http://codeception.com/docs/07-BDD) to learn more.
|
||||
|
||||
## Configuration
|
||||
|
||||
Codeception has a global configuration in `codeception.yml` and a config for each suite. We also support `.dist` configuration files.
|
||||
If you have several developers in a project, put shared settings into `codeception.dist.yml` and personal settings into `codeception.yml`.
|
||||
The same goes for suite configs. For example, the `unit.suite.yml` will be merged with `unit.suite.dist.yml`.
|
||||
|
||||
## Running Tests
|
||||
|
||||
Tests can be started with the `run` command:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run
|
||||
```
|
||||
|
||||
With the first argument you can run all tests from one suite:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run acceptance
|
||||
```
|
||||
|
||||
To limit tests run to a single class, add a second argument. Provide a local path to the test class, from the suite directory:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run acceptance SigninCest.php
|
||||
```
|
||||
|
||||
Alternatively you can provide the full path to test file:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run tests/acceptance/SigninCest.php
|
||||
```
|
||||
|
||||
You can further filter which tests are run by appending a method name to the class, separated by a colon (for Cest or Test formats):
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run tests/acceptance/SigninCest.php:^anonymousLogin$
|
||||
```
|
||||
|
||||
You can provide a directory path as well. This will execute all acceptance tests from the `backend` dir:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run tests/acceptance/backend
|
||||
```
|
||||
|
||||
Using regular expressions, you can even run many different test methods from the same directory or class.
|
||||
For example, this will execute all acceptance tests from the `backend` dir beginning with the word "login":
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run tests/acceptance/backend:^login
|
||||
```
|
||||
|
||||
To execute a group of tests that are not stored in the same directory, you can organize them in [groups](http://codeception.com/docs/07-AdvancedUsage#Groups).
|
||||
|
||||
### Reports
|
||||
|
||||
To generate JUnit XML output, you can provide the `--xml` option, and `--html` for HTML report.
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run --steps --xml --html
|
||||
```
|
||||
|
||||
This command will run all tests for all suites, displaying the steps, and building HTML and XML reports. Reports will be stored in the `tests/_output/` directory.
|
||||
|
||||
To see all the available options, run the following command:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept help run
|
||||
```
|
||||
|
||||
## Debugging
|
||||
|
||||
To receive detailed output, tests can be executed with the `--debug` option.
|
||||
You may print any information inside a test using the `codecept_debug` function.
|
||||
|
||||
### Generators
|
||||
|
||||
There are plenty of useful Codeception commands:
|
||||
|
||||
* `generate:cest` *suite* *filename* - Generates a sample Cest test
|
||||
* `generate:test` *suite* *filename* - Generates a sample PHPUnit Test with Codeception hooks
|
||||
* `generate:feature` *suite* *filename* - Generates Gherkin feature file
|
||||
* `generate:suite` *suite* *actor* - Generates a new suite with the given Actor class name
|
||||
* `generate:scenarios` *suite* - Generates text files containing scenarios from tests
|
||||
* `generate:helper` *filename* - Generates a sample Helper File
|
||||
* `generate:pageobject` *suite* *filename* - Generates a sample Page object
|
||||
* `generate:stepobject` *suite* *filename* - Generates a sample Step object
|
||||
* `generate:environment` *env* - Generates a sample Environment configuration
|
||||
* `generate:groupobject` *group* - Generates a sample Group Extension
|
||||
|
||||
## Conclusion
|
||||
|
||||
We have taken a look into the Codeception structure. Most of the things you need were already generated by the `bootstrap` command.
|
||||
After you have reviewed the basic concepts and configurations, you can start writing your first scenario.
|
||||
637
vendor/codeception/base/docs/03-AcceptanceTests.md
vendored
Normal file
637
vendor/codeception/base/docs/03-AcceptanceTests.md
vendored
Normal file
@@ -0,0 +1,637 @@
|
||||
# Acceptance Testing
|
||||
|
||||
Acceptance testing can be performed by a non-technical person. That person can be your tester, manager or even client.
|
||||
If you are developing a web-application (and you probably are) the tester needs nothing more than a web browser
|
||||
to check that your site works correctly. You can reproduce an acceptance tester's actions in scenarios
|
||||
and run them automatically. Codeception keeps tests clean and simple
|
||||
as if they were recorded from the words of an actual acceptance tester.
|
||||
|
||||
It makes no difference what (if any) CMS or framework is used on the site. You can even test sites created with different
|
||||
languages, like Java, .NET, etc. It's always a good idea to add tests to your website.
|
||||
At least you will be sure that site features work after the latest changes were made.
|
||||
|
||||
## Sample Scenario
|
||||
|
||||
Let's say the first test you would want to run, would be signing in.
|
||||
In order to write such a test, we still require basic knowledge of PHP and HTML:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->amOnPage('/login');
|
||||
$I->fillField('username', 'davert');
|
||||
$I->fillField('password', 'qwerty');
|
||||
$I->click('LOGIN');
|
||||
$I->see('Welcome, Davert!');
|
||||
```
|
||||
|
||||
**This scenario can be performed either by PhpBrowser or by a "real" browser through Selenium WebDriver**.
|
||||
|
||||
| | PhpBrowser | WebDriver |
|
||||
| --- | --- | --- |
|
||||
| Browser Engine | Guzzle + Symfony BrowserKit | Chrome or Firefox |
|
||||
| JavaScript | No | Yes |
|
||||
| `see`/`seeElement` checks if… | …text is present in the HTML source | …text is actually visible to the user |
|
||||
| Read HTTP response headers | Yes | No |
|
||||
| System requirements | PHP with [cURL extension](http://php.net/manual/book.curl.php) | Selenium Standalone Server, Chrome or Firefox |
|
||||
| Speed | Fast | Slow |
|
||||
|
||||
We will start writing our first acceptance tests with PhpBrowser.
|
||||
|
||||
## PhpBrowser
|
||||
|
||||
This is the fastest way to run acceptance tests since it doesn't require running an actual browser.
|
||||
We use a PHP web scraper, which acts like a browser: It sends a request, then receives and parses the response.
|
||||
Codeception uses [Guzzle](http://guzzlephp.org) and [Symfony BrowserKit](http://symfony.com/doc/current/components/browser_kit.html) to interact with HTML web pages.
|
||||
|
||||
Common PhpBrowser drawbacks:
|
||||
|
||||
* You can only click on links with valid URLs or form submit buttons
|
||||
* You can't fill in fields that are not inside a form
|
||||
|
||||
We need to specify the `url` parameter in the acceptance suite config:
|
||||
|
||||
```yaml
|
||||
# acceptance.suite.yml
|
||||
actor: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- PhpBrowser:
|
||||
url: http://www.example.com/
|
||||
- \Helper\Acceptance
|
||||
```
|
||||
|
||||
We should start by creating a test with the next command:
|
||||
|
||||
```
|
||||
php vendor/bin/codecept g:cest acceptance Signin
|
||||
```
|
||||
|
||||
It will be placed into `tests/acceptance` directory.
|
||||
|
||||
```php
|
||||
<?php
|
||||
class SigninCest
|
||||
{
|
||||
public function tryToTest(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantTo('test my page');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `$I` object is used to write all interactions.
|
||||
The methods of the `$I` object are taken from the [PhpBrowser Module](http://codeception.com/docs/modules/PhpBrowser). We will briefly describe them here:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->amOnPage('/login');
|
||||
```
|
||||
|
||||
We will assume that all actions starting with `am` and `have` describe the initial environment.
|
||||
The `amOnPage` action sets the starting point of a test to the `/login` page.
|
||||
|
||||
With the `PhpBrowser` you can click the links and fill in the forms. That will probably be the majority of your actions.
|
||||
|
||||
#### Click
|
||||
|
||||
Emulates a click on valid anchors. The URL referenced in the `href` attribute will be opened.
|
||||
As a parameter, you can specify the link name or a valid CSS or XPath selector.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->click('Log in');
|
||||
// CSS selector applied
|
||||
$I->click('#login a');
|
||||
// XPath
|
||||
$I->click('//a[@id=login]');
|
||||
// Using context as second argument
|
||||
$I->click('Login', '.nav');
|
||||
```
|
||||
|
||||
Codeception tries to locate an element by its text, name, CSS or XPath.
|
||||
You can specify the locator type manually by passing an array as a parameter. We call this a **strict locator**.
|
||||
Available strict locator types are:
|
||||
|
||||
* id
|
||||
* name
|
||||
* css
|
||||
* xpath
|
||||
* link
|
||||
* class
|
||||
|
||||
```php
|
||||
<?php
|
||||
// By specifying locator type
|
||||
$I->click(['link' => 'Login']);
|
||||
$I->click(['class' => 'btn']);
|
||||
```
|
||||
|
||||
There is a special class [`Codeception\Util\Locator`](http://codeception.com/docs/reference/Locator)
|
||||
which may help you to generate complex XPath locators.
|
||||
For instance, it can easily allow you to click an element on the last row of a table:
|
||||
|
||||
```php
|
||||
$I->click('Edit' , \Codeception\Util\Locator::elementAt('//table/tr', -1));
|
||||
```
|
||||
|
||||
#### Forms
|
||||
|
||||
Clicking links is probably not what takes the most time during the testing of a website.
|
||||
The most routine waste of time goes into the testing of forms. Codeception provides several ways of testing forms.
|
||||
|
||||
Let's submit this sample form inside the Codeception test:
|
||||
|
||||
```html
|
||||
<form method="post" action="/update" id="update_form">
|
||||
<label for="user_name">Name</label>
|
||||
<input type="text" name="user[name]" id="user_name" />
|
||||
<label for="user_email">Email</label>
|
||||
<input type="text" name="user[email]" id="user_email" />
|
||||
<label for="user_gender">Gender</label>
|
||||
<select id="user_gender" name="user[gender]">
|
||||
<option value="m">Male</option>
|
||||
<option value="f">Female</option>
|
||||
</select>
|
||||
<input type="submit" name="submitButton" value="Update" />
|
||||
</form>
|
||||
```
|
||||
|
||||
From a user's perspective, a form consists of fields which should be filled in, and then a submit button clicked:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// we are using label to match user_name field
|
||||
$I->fillField('Name', 'Miles');
|
||||
// we can use input name or id
|
||||
$I->fillField('user[email]','miles@davis.com');
|
||||
$I->selectOption('Gender','Male');
|
||||
$I->click('Update');
|
||||
```
|
||||
|
||||
To match fields by their labels, you should write a `for` attribute in the `label` tag.
|
||||
|
||||
From the developer's perspective, submitting a form is just sending a valid POST request to the server.
|
||||
Sometimes it's easier to fill in all of the fields at once and send the form without clicking a 'Submit' button.
|
||||
A similar scenario can be rewritten with only one command:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->submitForm('#update_form', array('user' => array(
|
||||
'name' => 'Miles',
|
||||
'email' => 'Davis',
|
||||
'gender' => 'm'
|
||||
)));
|
||||
```
|
||||
|
||||
The `submitForm` is not emulating a user's actions, but it's quite useful
|
||||
in situations when the form is not formatted properly, for example, to discover that labels aren't set
|
||||
or that fields have unclean names or badly written IDs, or the form is sent by a JavaScript call.
|
||||
|
||||
By default, `submitForm` doesn't send values for buttons. The last parameter allows specifying
|
||||
what button values should be sent, or button values can be explicitly specified in the second parameter:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->submitForm('#update_form', array('user' => array(
|
||||
'name' => 'Miles',
|
||||
'email' => 'Davis',
|
||||
'gender' => 'm'
|
||||
)), 'submitButton');
|
||||
// this would have the same effect, but the value has to be explicitly specified
|
||||
$I->submitForm('#update_form', array('user' => array(
|
||||
'name' => 'Miles',
|
||||
'email' => 'Davis',
|
||||
'gender' => 'm',
|
||||
'submitButton' => 'Update'
|
||||
)));
|
||||
```
|
||||
|
||||
##### Hiding Sensitive Data
|
||||
|
||||
If you need to fill in sensitive data (like passwords) and hide it in logs,
|
||||
you can pass instance `\Codeception\Step\Argument\PasswordArgument` with the data which needs to be hidden.
|
||||
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Step\Argument\PasswordArgument;
|
||||
|
||||
$I->amOnPage('/form/password_argument');
|
||||
$I->fillField('password', new PasswordArgument('thisissecret'));
|
||||
```
|
||||
|
||||
`thisissecret` will be filled into a form but it won't be shown in output and logs.
|
||||
|
||||
#### Assertions
|
||||
|
||||
In the `PhpBrowser` you can test the page contents.
|
||||
In most cases, you just need to check that the required text or element is on the page.
|
||||
|
||||
The most useful method for this is `see()`:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// We check that 'Thank you, Miles' is on the page.
|
||||
$I->see('Thank you, Miles');
|
||||
// We check that 'Thank you, Miles' is inside an element with 'notice' class.
|
||||
$I->see('Thank you, Miles', '.notice');
|
||||
// Or using XPath locators
|
||||
$I->see('Thank you, Miles', "//table/tr[2]");
|
||||
// We check this message is *not* on the page.
|
||||
$I->dontSee('Form is filled incorrectly');
|
||||
```
|
||||
|
||||
You can check that a specific HTML element exists (or doesn't) on a page:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeElement('.notice');
|
||||
$I->dontSeeElement('.error');
|
||||
```
|
||||
|
||||
We also have other useful commands to perform checks. Please note that they all start with the `see` prefix:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeInCurrentUrl('/user/miles');
|
||||
$I->seeCheckboxIsChecked('#agree');
|
||||
$I->seeInField('user[name]', 'Miles');
|
||||
$I->seeLink('Login');
|
||||
```
|
||||
|
||||
#### Conditional Assertions
|
||||
|
||||
Usually, as soon as any assertion fails, further assertions of this test will be skipped.
|
||||
Sometimes you don't want this - maybe you have a long-running test and you want it to run to the end.
|
||||
In this case, you can use conditional assertions.
|
||||
Each `see` method has a corresponding `canSee` method, and `dontSee` has a `cantSee` method:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->canSeeInCurrentUrl('/user/miles');
|
||||
$I->canSeeCheckboxIsChecked('#agree');
|
||||
$I->cantSeeInField('user[name]', 'Miles');
|
||||
```
|
||||
|
||||
Each failed assertion will be shown in the test results, but it won't stop the test.
|
||||
|
||||
#### Comments
|
||||
|
||||
Within a long scenario, you should describe what actions you are going to perform and what results should be achieved.
|
||||
Comment methods like `amGoingTo`, `expect`, `expectTo` help you in making tests more descriptive:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->amGoingTo('submit user form with invalid values');
|
||||
$I->fillField('user[email]', 'miles');
|
||||
$I->click('Update');
|
||||
$I->expect('the form is not submitted');
|
||||
$I->see('Form is filled incorrectly');
|
||||
```
|
||||
|
||||
#### Grabbers
|
||||
|
||||
These commands retrieve data that can be used in the test. Imagine your site generates a password for every user
|
||||
and you want to check that the user can log into the site using this password:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->fillField('email', 'miles@davis.com');
|
||||
$I->click('Generate Password');
|
||||
$password = $I->grabTextFrom('#password');
|
||||
$I->click('Login');
|
||||
$I->fillField('email', 'miles@davis.com');
|
||||
$I->fillField('password', $password);
|
||||
$I->click('Log in!');
|
||||
```
|
||||
|
||||
Grabbers allow you to get a single value from the current page with commands:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$token = $I->grabTextFrom('.token');
|
||||
$password = $I->grabTextFrom("descendant::input/descendant::*[@id = 'password']");
|
||||
$api_key = $I->grabValueFrom('input[name=api]');
|
||||
```
|
||||
|
||||
#### Cookies, URLs, Title, etc
|
||||
|
||||
Actions for cookies:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->setCookie('auth', '123345');
|
||||
$I->grabCookie('auth');
|
||||
$I->seeCookie('auth');
|
||||
```
|
||||
|
||||
Actions for checking the page title:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeInTitle('Login');
|
||||
$I->dontSeeInTitle('Register');
|
||||
```
|
||||
|
||||
Actions for URLs:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeCurrentUrlEquals('/login');
|
||||
$I->seeCurrentUrlMatches('~$/users/(\d+)~');
|
||||
$I->seeInCurrentUrl('user/1');
|
||||
$user_id = $I->grabFromCurrentUrl('~$/user/(\d+)/~');
|
||||
```
|
||||
|
||||
## WebDriver
|
||||
|
||||
A nice feature of Codeception is that most scenarios are similar, no matter of how they are executed.
|
||||
`PhpBrowser` was emulating browser requests but how to execute such test in a real browser like Chrome or Firefox?
|
||||
Selenium WebDriver can drive them so in our acceptance tests we can automate scenarios we used to test manually.
|
||||
In such tests, we should concentrate more on **testing the UI** than on testing functionality.
|
||||
|
||||
"[WebDriver](https://www.w3.org/TR/webdriver/)" is the name of a protocol (specified by W3C)
|
||||
to drive browsers automatically. This specification is implemented for all modern desktop and mobile browsers.
|
||||
Codeception uses [facebook/php-webdriver](https://github.com/facebook/php-webdriver) library from Facebook as PHP implementation of WebDriver protocol.
|
||||
|
||||
To control the browsers you need to use a program or a service to start/stop browser sessions.
|
||||
In the next section, we will overview the most popular solutions.
|
||||
|
||||
### Local Setup
|
||||
|
||||
#### Selenium Server
|
||||
|
||||
[Selenium Server](http://www.seleniumhq.org/) is a de-facto standard for automated web and mobile testing.
|
||||
It is a server that can launch and drive different browsers locally or remotely.
|
||||
WebDriver protocol was initially created by Selenium before becoming a W3C standard.
|
||||
This makes Selenium server the most stable complete implementation of WebDriver for today.
|
||||
Selenium Server is also recommended by Codeception team.
|
||||
|
||||
To control browsers Selenium Server uses official tools maintained by browser vendors, like [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver) for Chrome or [GeckoDriver](https://github.com/mozilla/geckodriver) for Firefox.
|
||||
This makes Selenium quite heavy to install, as it requires Java, browsers, Chrome or GeckoDriver and GUI (display server) to run browsers in.
|
||||
|
||||
* Follow [Installation Instructions](http://codeception.com/docs/modules/WebDriver#Selenium)
|
||||
* Enable [RunProcess](http://codeception.com/extensions#RunProcess) extension to start/stop Selenium automatically *(optional)*.
|
||||
|
||||
#### PhantomJS
|
||||
|
||||
PhantomJS is a customized WebKit-based [headless browser](https://en.wikipedia.org/wiki/Headless_browser)
|
||||
built for programmatic usage only. It doesn't display a browser window and doesn't require GUI (display server) to be installed.
|
||||
This makes PhantomJS highly popular for Continuous Integration systems.
|
||||
PhantomJS needs only one binary with no extra dependencies which make it the simplest WebDriver tool to install.
|
||||
|
||||
However, it should be noted that PhantomJS is not a real browser, so the behavior and output in real browsers may differ from PhantomJS.
|
||||
And the most important: **PhantomJS is not maintained** anymore. So use it at your own risk.
|
||||
|
||||
* Follow [Installation Instructions](http://codeception.com/docs/modules/WebDriver#PhantomJS)
|
||||
* Enable [RunProcess](http://codeception.com/extensions#RunProcess) extension to start/stop PhantomJS automatically *(optional)*.
|
||||
|
||||
#### ChromeDriver
|
||||
|
||||
ChromeDriver was created by Google to control Chrome and Chromium browsers programmatically.
|
||||
It can be paired with [Selenium Server](http://codeception.com/docs/03-AcceptanceTests#Selenium-Server) or used as a standalone tool to drive Chrome browser.
|
||||
It is simpler to set up than Selenium Server, however, it has limited support for WebDriver protocol.
|
||||
|
||||
* Follow [Installation Instructions](http://codeception.com/docs/modules/WebDriver#ChromeDriver)
|
||||
* Enable [RunProcess](http://codeception.com/extensions#RunProcess) extension to start/stop ChromeDriver automatically *(optional)*.
|
||||
|
||||
### Configuration
|
||||
|
||||
To execute a test in a browser we need to change the suite configuration to use **WebDriver** instead of `PhpBrowser`.
|
||||
|
||||
Modify your `acceptance.suite.yml` file:
|
||||
|
||||
```yaml
|
||||
actor: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- WebDriver:
|
||||
url: {{your site URL}}
|
||||
browser: chrome
|
||||
- \Helper\Acceptance
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$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:
|
||||
|
||||
#### Wait
|
||||
|
||||
While testing web application, you may need to wait for JavaScript events to occur. Due to its asynchronous nature,
|
||||
complex JavaScript interactions are hard to test. That's why you may need to use waiters, actions with `wait` prefix.
|
||||
They can be used to specify what event you expect to occur on a page, before continuing the test.
|
||||
|
||||
For example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->waitForElement('#agree_button', 30); // secs
|
||||
$I->click('#agree_button');
|
||||
```
|
||||
|
||||
In this case, we are waiting for the 'agree' button to appear and then click it. If it didn't appear after 30 seconds,
|
||||
the test will fail. There are other `wait` methods you may use, like [waitForText](http://codeception.com/docs/modules/WebDriver#waitForText),
|
||||
[waitForElementVisible](http://codeception.com/docs/modules/WebDriver#waitForElementVisible) and others.
|
||||
|
||||
If you don't know what exact element you need to wait for, you can simply pause execution with using `$I->wait()`
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->wait(3); // wait for 3 secs
|
||||
```
|
||||
|
||||
#### SmartWait
|
||||
|
||||
*since 2.3.4 version*
|
||||
|
||||
It is possible to wait for elements pragmatically.
|
||||
If a test uses element which is not on a page yet, Codeception will wait for few extra seconds before failing.
|
||||
This feature is based on [Implicit Wait](http://www.seleniumhq.org/docs/04_webdriver_advanced.jsp#implicit-waits) of Selenium.
|
||||
Codeception enables implicit wait only when searching for a specific element and disables in all other cases. Thus, the performance of a test is not affected.
|
||||
|
||||
SmartWait can be enabled by setting `wait` option in WebDriver config. It expects the number of seconds to wait. Example:
|
||||
|
||||
```yaml
|
||||
wait: 5
|
||||
```
|
||||
|
||||
With this config we have the following test:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// we use wait: 5 instead of
|
||||
// $I->waitForElement(['css' => '#click-me'], 5);
|
||||
// to wait for element on page
|
||||
$I->click(['css' => '#click-me']);
|
||||
```
|
||||
|
||||
It is important to understand that SmartWait works only with a specific locators:
|
||||
|
||||
* `#locator` - CSS ID locator, works
|
||||
* `//locator` - general XPath locator, works
|
||||
* `['css' => 'button'']` - strict locator, works
|
||||
|
||||
But it won't be executed for all other locator types.
|
||||
See the example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->click('Login'); // DISABLED, not a specific locator
|
||||
$I->fillField('user', 'davert'); // DISABLED, not a specific locator
|
||||
$I->fillField(['name' => 'password'], '123456'); // ENABLED, strict locator
|
||||
$I->click('#login'); // ENABLED, locator is CSS ID
|
||||
$I->see('Hello, Davert'); // DISABLED, Not a locator
|
||||
$I->seeElement('#userbar'); // ENABLED
|
||||
$I->dontSeeElement('#login'); // DISABLED, can't wait for element to hide
|
||||
$I->seeNumberOfElements(['css' => 'button.link'], 5); // DISABLED, can wait only for one element
|
||||
```
|
||||
|
||||
#### Wait and Act
|
||||
|
||||
To combine `waitForElement` with actions inside that element you can use the [performOn](http://codeception.com/docs/modules/WebDriver#performOn) method.
|
||||
Let's see how you can perform some actions inside an HTML popup:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->performOn('.confirm', \Codeception\Util\ActionSequence::build()
|
||||
->see('Warning')
|
||||
->see('Are you sure you want to delete this?')
|
||||
->click('Yes')
|
||||
);
|
||||
```
|
||||
Alternatively, this can be executed using a callback, in this case the `WebDriver` instance is passed as argument
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->performOn('.confirm', function(\Codeception\Module\WebDriver $I) {
|
||||
$I->see('Warning');
|
||||
$I->see('Are you sure you want to delete this?');
|
||||
$I->click('Yes');
|
||||
});
|
||||
```
|
||||
|
||||
For more options see [`performOn()` reference](http://codeception.com/docs/modules/WebDriver#performOn).
|
||||
|
||||
### Multi Session Testing
|
||||
|
||||
Codeception allows you to execute actions in concurrent sessions. The most obvious case for this
|
||||
is testing realtime messaging between users on a site. In order to do it, you will need to launch two browser windows
|
||||
at the same time for the same test. Codeception has a very smart concept for doing this. It is called **Friends**:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->amOnPage('/messages');
|
||||
$nick = $I->haveFriend('nick');
|
||||
$nick->does(function(AcceptanceTester $I) {
|
||||
$I->amOnPage('/messages/new');
|
||||
$I->fillField('body', 'Hello all!');
|
||||
$I->click('Send');
|
||||
$I->see('Hello all!', '.message');
|
||||
});
|
||||
$I->wait(3);
|
||||
$I->see('Hello all!', '.message');
|
||||
```
|
||||
|
||||
In this case, we performed, or 'did', some actions in the second window with the `does` method on a friend object.
|
||||
|
||||
Sometimes you may want to close a webpage before the end of the test. For such cases, you may use `leave()`.
|
||||
You can also specify roles for a friend:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$nickAdmin = $I->haveFriend('nickAdmin', adminStep::class);
|
||||
$nickAdmin->does(function(adminStep $I) {
|
||||
// Admin does ...
|
||||
});
|
||||
$nickAdmin->leave();
|
||||
```
|
||||
|
||||
### Cloud Testing
|
||||
|
||||
Some environments are hard to be reproduced manually, testing Internet Explorer 6-8 on Windows XP may be a hard thing,
|
||||
especially if you don't have Windows XP installed. This is where Cloud Testing services come to help you.
|
||||
Services such as [SauceLabs](https://saucelabs.com), [BrowserStack](https://www.browserstack.com/)
|
||||
and [others](http://codeception.com/docs/modules/WebDriver#Cloud-Testing) can create virtual machines on demand
|
||||
and set up Selenium Server and the desired browser. Tests are executed on a remote machine in a cloud,
|
||||
to access local files cloud testing services provide a special application called **Tunnel**.
|
||||
Tunnel operates on a secured protocol and allows browsers executed in a cloud to connect to a local web server.
|
||||
|
||||
Cloud Testing services work with the standard WebDriver protocol. This makes setting up cloud testing really easy.
|
||||
You just need to set the [WebDriver configuration](http://codeception.com/docs/modules/WebDriver#Cloud-Testing) to:
|
||||
|
||||
* specify the host to connect to (depends on the cloud provider)
|
||||
* authentication details (to use your account)
|
||||
* browser
|
||||
* OS
|
||||
|
||||
We recommend using [params](http://codeception.com/docs/06-ModulesAndHelpers#Dynamic-Configuration-With-Params)
|
||||
to provide authorization credentials.
|
||||
|
||||
It should be mentioned that Cloud Testing services are not free. You should investigate their pricing models
|
||||
and choose one that fits your needs. They also may work painfully slowly if ping times between the local server
|
||||
and the cloud is too high. This may lead to random failures in acceptance tests.
|
||||
|
||||
### AngularJS Testing
|
||||
|
||||
In the modern era of Single Page Applications, the browser replaces the server in creating the user interface.
|
||||
Unlike traditional web applications, web pages are not reloaded on user actions.
|
||||
All interactions with the server are done in JavaScript with XHR requests.
|
||||
However, testing Single Page Applications can be a hard task.
|
||||
There could be no information of the application state: e.g. has it completed rendering or not?
|
||||
What is possible to do in this case is to use more `wait*` methods or execute JavaScript that checks the application state.
|
||||
|
||||
For applications built with the AngularJS v1.x framework,
|
||||
we implemented [AngularJS module](http://codeception.com/docs/modules/AngularJS) which is based on Protractor
|
||||
(an official tool for testing Angular apps). Under the hood, it pauses step execution
|
||||
before the previous actions are completed and use the AngularJS API to check the application state.
|
||||
|
||||
The AngularJS module extends WebDriver so that all the configuration options from it are available.
|
||||
|
||||
### Debugging
|
||||
|
||||
Codeception modules can print valuable information while running.
|
||||
Just execute tests with the `--debug` option to see running details. For any custom output use the `codecept_debug` function:
|
||||
|
||||
```php
|
||||
<?php
|
||||
codecept_debug($I->grabTextFrom('#name'));
|
||||
```
|
||||
|
||||
On each failure, the snapshot of the last shown page will be stored in the `tests/_output` directory.
|
||||
PhpBrowser will store the HTML code and WebDriver will save a screenshot of the page.
|
||||
|
||||
Additional debugging features by Codeception:
|
||||
|
||||
* [pauseExecution](http://codeception.com/docs/modules/WebDriver#pauseExecution) method of WebDriver module allows pausing the test.
|
||||
* [Recorder extension](http://codeception.com/addons#CodeceptionExtensionRecorder) allows to record tests step-by-steps and show them in slideshow
|
||||
* [Interactive Console](http://codeception.com/docs/07-AdvancedUsage#Interactive-Console) is a REPL that allows to type and check commands for instant feedback.
|
||||
|
||||
### Custom Browser Sessions
|
||||
|
||||
By default, WebDriver module is configured to automatically start browser before the test and stop afterward.
|
||||
However, this can be switched off with `start: false` module configuration.
|
||||
To start a browser you will need to write corresponding methods in Acceptance [Helper](http://codeception.com/docs/06-ModulesAndHelpers#Helpers).
|
||||
|
||||
WebDriver module provides advanced methods for the browser session, however, they can only be used from Helpers.
|
||||
|
||||
* [_initializeSession](http://codeception.com/docs/modules/WebDriver#_initializeSession) - starts a new browser session
|
||||
* [_closeSession](http://codeception.com/docs/modules/WebDriver#_closeSession) - stops the browser session
|
||||
* [_restart](http://codeception.com/docs/modules/WebDriver#_restart) - updates configuration and restarts browser
|
||||
* [_capabilities](http://codeception.com/docs/modules/WebDriver#_capabilities) - set [desired capabilities](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities) programmatically.
|
||||
|
||||
Those methods can be used to create custom commands like `$I->startBrowser()` or used in [before/after](http://codeception.com/docs/06-ModulesAndHelpers#Hooks) hooks.
|
||||
|
||||
## Conclusion
|
||||
|
||||
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.
|
||||
If you need to access the database, you can use the [Db Module](http://codeception.com/docs/modules/Db).
|
||||
274
vendor/codeception/base/docs/04-FunctionalTests.md
vendored
Normal file
274
vendor/codeception/base/docs/04-FunctionalTests.md
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
# Functional Tests
|
||||
|
||||
Now that we've written some acceptance tests, functional tests are almost the same, with one major difference:
|
||||
Functional tests don't require a web server.
|
||||
|
||||
In simple terms we set the `$_REQUEST`, `$_GET` and `$_POST` variables and then we execute the application from a test.
|
||||
This may be valuable, as functional tests are faster and provide detailed stack traces on failures.
|
||||
|
||||
Codeception can connect to different PHP frameworks that support functional testing: Symfony2, Laravel5, Yii2,
|
||||
Zend Framework and others. You just need to enable the desired module in your functional suite configuration to start.
|
||||
|
||||
Modules for all of these frameworks share the same interface, and thus your tests are not bound to any one of them.
|
||||
This is a sample functional test:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// LoginCest.php
|
||||
|
||||
class LoginCest
|
||||
{
|
||||
public function tryLogin (FunctionalTester $I)
|
||||
{
|
||||
$I->amOnPage('/');
|
||||
$I->click('Login');
|
||||
$I->fillField('Username', 'Miles');
|
||||
$I->fillField('Password', 'Davis');
|
||||
$I->click('Enter');
|
||||
$I->see('Hello, Miles', 'h1');
|
||||
// $I->seeEmailIsSent(); // only for Symfony2
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
As you see, the syntax is the same for functional and acceptance tests.
|
||||
|
||||
## Limitations
|
||||
|
||||
Functional tests are usually much faster than acceptance tests. But functional tests are less stable as they run Codeception
|
||||
and the application in one environment. If your application was not designed to run in long lived processes (e.g.
|
||||
if you use the `exit` operator or global variables), then functional tests are probably not for you.
|
||||
|
||||
### Headers, Cookies, Sessions
|
||||
|
||||
One of the common issues with functional tests is the use of PHP functions that deal with headers, sessions and cookies.
|
||||
As you may already know, the `header` function triggers an error if it is executed after PHP has already output something.
|
||||
In functional tests we run the application multiple times, thus we will get lots of irrelevant errors in the result.
|
||||
|
||||
### External URL's
|
||||
|
||||
Functional tests cannot access external URL's, just URL's within your project. You can use Guzzle to open external URL's.
|
||||
|
||||
### Shared Memory
|
||||
|
||||
In functional testing, unlike running the application the traditional way, the PHP application does not stop
|
||||
after it has finished processing a request. Since all requests are run in one memory container, they are not isolated.
|
||||
So **if you see that your tests are mysteriously failing when they shouldn't - try to execute a single test.**
|
||||
This will show if the tests were failing because they weren't isolated during the run.
|
||||
Keep your memory clean, avoid memory leaks and clean global and static variables.
|
||||
|
||||
## Enabling Framework Modules
|
||||
|
||||
You have a functional testing suite in the `tests/functional` directory.
|
||||
To start, you need to include one of the framework modules in the suite configuration file: `tests/functional.suite.yml`.
|
||||
|
||||
### Symfony
|
||||
|
||||
To perform Symfony integration you just need to include the Symfony module into your test suite. If you also use Doctrine2,
|
||||
don't forget to include it too. To make the Doctrine2 module connect using the `doctrine` service from Symfony,
|
||||
you should specify the Symfony module as a dependency for Doctrine2:
|
||||
|
||||
```yaml
|
||||
# functional.suite.yml
|
||||
|
||||
actor: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- Symfony
|
||||
- Doctrine2:
|
||||
depends: Symfony # connect to Symfony
|
||||
- \Helper\Functional
|
||||
```
|
||||
|
||||
By default this module will search for AppKernel in the `app` directory.
|
||||
|
||||
The module uses the Symfony Profiler to provide additional information and assertions.
|
||||
|
||||
[See the full reference](http://codeception.com/docs/modules/Symfony)
|
||||
|
||||
### Laravel5
|
||||
|
||||
The [Laravel5](http://codeception.com/docs/modules/Laravel5) module is included and requires no configuration:
|
||||
|
||||
```yaml
|
||||
# functional.suite.yml
|
||||
|
||||
actor: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- Laravel5
|
||||
- \Helper\Functional
|
||||
```
|
||||
|
||||
### Yii2
|
||||
|
||||
Yii2 tests are included in [Basic](https://github.com/yiisoft/yii2-app-basic)
|
||||
and [Advanced](https://github.com/yiisoft/yii2-app-advanced) application templates. Follow the Yii2 guides to start.
|
||||
|
||||
### Yii
|
||||
|
||||
By itself Yii framework does not have an engine for functional testing.
|
||||
So Codeception is the first and the only functional testing framework for Yii.
|
||||
To use it with Yii include `Yii1` module into config:
|
||||
|
||||
```yaml
|
||||
# functional.suite.yml
|
||||
|
||||
actor: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- Yii1
|
||||
- \Helper\Functional
|
||||
```
|
||||
|
||||
To avoid the common pitfalls we discussed earlier, Codeception provides basic hooks over the Yii engine.
|
||||
Please set them up following [the installation steps in the module reference](http://codeception.com/docs/modules/Yii1).
|
||||
|
||||
### Zend Framework 2
|
||||
|
||||
Use [the ZF2 module](http://codeception.com/docs/modules/ZF2) to run functional tests inside Zend Framework 2:
|
||||
|
||||
```yaml
|
||||
# functional.suite.yml
|
||||
|
||||
actor: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- ZF2
|
||||
- \Helper\Functional
|
||||
```
|
||||
|
||||
### Zend Framework 1.x
|
||||
|
||||
The module for Zend Framework is highly inspired by the ControllerTestCase class, used for functional testing with PHPUnit.
|
||||
It follows similar approaches for bootstrapping and cleaning up.
|
||||
To start using Zend Framework in your functional tests, include the `ZF1` module:
|
||||
|
||||
```yaml
|
||||
# functional.suite.yml
|
||||
|
||||
actor: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- ZF1
|
||||
- \Helper\Functional
|
||||
```
|
||||
|
||||
[See the full reference](http://codeception.com/docs/modules/ZF1)
|
||||
|
||||
### Phalcon
|
||||
|
||||
The `Phalcon` module requires creating a bootstrap file which returns an instance of `\Phalcon\Mvc\Application`.
|
||||
To start writing functional tests with Phalcon support you should enable the `Phalcon` module
|
||||
and provide the path to this bootstrap file:
|
||||
|
||||
```yaml
|
||||
# functional.suite.yml
|
||||
|
||||
actor: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- Phalcon:
|
||||
bootstrap: 'app/config/bootstrap.php'
|
||||
cleanup: true
|
||||
savepoints: true
|
||||
- \Helper\Functional
|
||||
```
|
||||
|
||||
[See the full reference](http://codeception.com/docs/modules/Phalcon)
|
||||
|
||||
## Writing Functional Tests
|
||||
|
||||
Functional tests are written in the same manner as [Acceptance Tests](http://codeception.com/docs/03-AcceptanceTests)
|
||||
with the `PhpBrowser` module enabled. All framework modules and the `PhpBrowser` module share the same methods
|
||||
and the same engine.
|
||||
|
||||
Therefore we can open a web page with `amOnPage` method:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I = new FunctionalTester($scenario);
|
||||
$I->amOnPage('/login');
|
||||
```
|
||||
|
||||
We can click links to open web pages:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->click('Logout');
|
||||
// click link inside .nav element
|
||||
$I->click('Logout', '.nav');
|
||||
// click by CSS
|
||||
$I->click('a.logout');
|
||||
// click with strict locator
|
||||
$I->click(['class' => 'logout']);
|
||||
```
|
||||
|
||||
We can submit forms as well:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->submitForm('form#login', ['name' => 'john', 'password' => '123456']);
|
||||
// alternatively
|
||||
$I->fillField('#login input[name=name]', 'john');
|
||||
$I->fillField('#login input[name=password]', '123456');
|
||||
$I->click('Submit', '#login');
|
||||
```
|
||||
|
||||
And do assertions:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->see('Welcome, john');
|
||||
$I->see('Logged in successfully', '.notice');
|
||||
$I->seeCurrentUrlEquals('/profile/john');
|
||||
```
|
||||
|
||||
Framework modules also contain additional methods to access framework internals. For instance, Laravel5, Phalcon,
|
||||
and Yii2 modules have a `seeRecord` method which uses the ActiveRecord layer to check that a record exists in the database.
|
||||
|
||||
Take a look at the complete reference for the module you are using. Most of its methods are common to all modules
|
||||
but some of them are unique.
|
||||
|
||||
You can also access framework globals inside a test or access the dependency injection container
|
||||
inside the `Helper\Functional` class:
|
||||
|
||||
```php
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
class Functional extends \Codeception\Module
|
||||
{
|
||||
function doSomethingWithMyService()
|
||||
{
|
||||
$service = $this->getModule('Symfony')->grabServiceFromContainer('myservice');
|
||||
$service->doSomething();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Also check all available *Public Properties* of the used modules to get full access to their data.
|
||||
|
||||
## Error Reporting
|
||||
|
||||
By default Codeception uses the `E_ALL & ~E_STRICT & ~E_DEPRECATED` error reporting level.
|
||||
In functional tests you might want to change this level depending on your framework's error policy.
|
||||
The error reporting level can be set in the suite configuration file:
|
||||
|
||||
```yaml
|
||||
actor: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- Yii1
|
||||
- \Helper\Functional
|
||||
error_level: "E_ALL & ~E_STRICT & ~E_DEPRECATED"
|
||||
```
|
||||
|
||||
`error_level` can also be set globally in `codeception.yml` file.
|
||||
|
||||
## Conclusion
|
||||
|
||||
Functional tests are great if you are using powerful frameworks. By using functional tests you can access
|
||||
and manipulate their internal state. This makes your tests shorter and faster. In other cases,
|
||||
if you don't use frameworks there is no practical reason to write functional tests.
|
||||
If you are using a framework other than the ones listed here, create a module for it and share it with the community.
|
||||
473
vendor/codeception/base/docs/05-UnitTests.md
vendored
Normal file
473
vendor/codeception/base/docs/05-UnitTests.md
vendored
Normal file
@@ -0,0 +1,473 @@
|
||||
# Unit & Integration Tests
|
||||
|
||||
Codeception uses PHPUnit as a backend for running its tests. Thus, any PHPUnit test can be added to a Codeception test suite
|
||||
and then executed. If you ever wrote a PHPUnit test then do it just as you did before.
|
||||
Codeception adds some nice helpers to simplify common tasks.
|
||||
|
||||
## Creating a Test
|
||||
|
||||
Create a test using `generate:test` command with a suite and test names as parameters:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept generate:test unit Example
|
||||
```
|
||||
|
||||
It creates a new `ExampleTest` file located in the `tests/unit` directory.
|
||||
|
||||
As always, you can run the newly created test with this command:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run unit ExampleTest
|
||||
```
|
||||
|
||||
Or simply run the whole set of unit tests with:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run unit
|
||||
```
|
||||
|
||||
A test created by the `generate:test` command will look like this:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
class ExampleTest extends \Codeception\Test\Unit
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
{
|
||||
}
|
||||
|
||||
// tests
|
||||
public function testMe()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Inside a class:
|
||||
|
||||
* all public methods with `test` prefix are tests
|
||||
* `_before` method is executed before each test (like `setUp` in PHPUnit)
|
||||
* `_after` method is executed after each test (like `tearDown` in PHPUnit)
|
||||
|
||||
## Unit Testing
|
||||
|
||||
Unit tests are focused around a single component of an application.
|
||||
All external dependencies for components should be replaced with test doubles.
|
||||
|
||||
A typical unit test may look like this:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class UserTest extends \Codeception\Test\Unit
|
||||
{
|
||||
public function testValidation()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$user->setName(null);
|
||||
$this->assertFalse($user->validate(['username']));
|
||||
|
||||
$user->setName('toolooooongnaaaaaaameeee');
|
||||
$this->assertFalse($user->validate(['username']));
|
||||
|
||||
$user->setName('davert');
|
||||
$this->assertTrue($user->validate(['username']));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Assertions
|
||||
|
||||
There are pretty many assertions you can use inside tests. The most common are:
|
||||
|
||||
* `$this->assertEquals()`
|
||||
* `$this->assertContains()`
|
||||
* `$this->assertFalse()`
|
||||
* `$this->assertTrue()`
|
||||
* `$this->assertNull()`
|
||||
* `$this->assertEmpty()`
|
||||
|
||||
Assertion methods come from PHPUnit. [See the complete reference at phpunit.de](https://phpunit.de/manual/current/en/appendixes.assertions.html).
|
||||
|
||||
### Test Doubles
|
||||
|
||||
Codeception provides [Codeception\Stub library](https://github.com/Codeception/Stub) for building mocks and stubs for tests.
|
||||
Under the hood it used PHPUnit's mock builder but with much simplified API.
|
||||
|
||||
Alternatively, [Mockery](https://github.com/Codeception/MockeryModule) can be used inside Codeception.
|
||||
|
||||
#### Stubs
|
||||
|
||||
Stubs can be created with a static methods of `Codeception\Stub`.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$user = \Codeception\Stub::make('User', ['getName' => 'john']);
|
||||
$name = $user->getName(); // 'john'
|
||||
```
|
||||
|
||||
[See complete reference](http://codeception.com/docs/reference/Mock)
|
||||
|
||||
Inside unit tests (`Codeception\Test\Unit`) it is recommended to use alternative API:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// create a stub with find method replaced
|
||||
$userRepository = $this->make(UserRepository::class, ['find' => new User]);
|
||||
$userRepository->find(1); // => User
|
||||
|
||||
// create a dummy
|
||||
$userRepository = $this->makeEmpty(UserRepository::class);
|
||||
|
||||
// create a stub with all methods replaced except one
|
||||
$user = $this->makeEmptyExcept(User::class, 'validate');
|
||||
$user->validate($data);
|
||||
|
||||
// create a stub by calling constructor and replacing a method
|
||||
$user = $this->construct(User::class, ['name' => 'davert'], ['save' => false]);
|
||||
|
||||
// create a stub by calling constructor with empty methods
|
||||
$user = $this->constructEmpty(User::class, ['name' => 'davert']);
|
||||
|
||||
// create a stub by calling constructor with empty methods
|
||||
$user = $this->constructEmptyExcept(User::class, 'getName', ['name' => 'davert']);
|
||||
$user->getName(); // => davert
|
||||
$user->setName('jane'); // => this method is empty
|
||||
```
|
||||
|
||||
[See complete reference](http://codeception.com/docs/reference/Mock)
|
||||
|
||||
Stubs can also be created using static methods from `Codeception\Stub` class.
|
||||
In this
|
||||
|
||||
```php
|
||||
<?php
|
||||
\Codeception\Stub::make(UserRepository::class, ['find' => new User]);
|
||||
```
|
||||
|
||||
See a reference for [static Stub API](http://codeception.com/docs/reference/Stub)
|
||||
|
||||
#### Mocks
|
||||
|
||||
To declare expectations for mocks use `Codeception\Stub\Expected` class:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// create a mock where $user->getName() should never be called
|
||||
$user = $this->make('User', [
|
||||
'getName' => Expected::never(),
|
||||
'someMethod' => function() {}
|
||||
]);
|
||||
$user->someMethod();
|
||||
|
||||
// create a mock where $user->getName() should be called at least once
|
||||
$user = $this->make('User', [
|
||||
'getName' => Expected::atLeastOnce('Davert')
|
||||
]
|
||||
);
|
||||
$user->getName();
|
||||
$userName = $user->getName();
|
||||
$this->assertEquals('Davert', $userName);
|
||||
```
|
||||
|
||||
[See complete reference](http://codeception.com/docs/reference/Mock)
|
||||
|
||||
## Integration Tests
|
||||
|
||||
Unlike unit tests integration tests doesn't require the code to be executed in isolation.
|
||||
That allows us to use database and other components inside a tests.
|
||||
To improve the testing experience modules can be used as in functional testing.
|
||||
|
||||
### Using Modules
|
||||
|
||||
As in scenario-driven functional or acceptance tests you can access Actor class methods.
|
||||
If you write integration tests, it may be useful to include the `Db` module for database testing.
|
||||
|
||||
```yaml
|
||||
# Codeception Test Suite Configuration
|
||||
|
||||
# suite for unit (internal) tests.
|
||||
actor: UnitTester
|
||||
modules:
|
||||
enabled:
|
||||
- Asserts
|
||||
- Db
|
||||
- \Helper\Unit
|
||||
```
|
||||
|
||||
To access UnitTester methods you can use the `UnitTester` property in a test.
|
||||
|
||||
### Testing Database
|
||||
|
||||
Let's see how you can do some database testing:
|
||||
|
||||
```php
|
||||
<?php
|
||||
function testSavingUser()
|
||||
{
|
||||
$user = new User();
|
||||
$user->setName('Miles');
|
||||
$user->setSurname('Davis');
|
||||
$user->save();
|
||||
$this->assertEquals('Miles Davis', $user->getFullName());
|
||||
$this->tester->seeInDatabase('users', ['name' => 'Miles', 'surname' => 'Davis']);
|
||||
}
|
||||
```
|
||||
|
||||
To enable the database functionality in unit tests, make sure the `Db` module is included
|
||||
in the `unit.suite.yml` configuration file.
|
||||
The database will be cleaned and populated after each test, the same way it happens for acceptance and functional tests.
|
||||
If that's not your required behavior, change the settings of the `Db` module for the current suite. See [Db Module](http://codeception.com/docs/modules/Db)
|
||||
|
||||
### Interacting with the Framework
|
||||
|
||||
You should probably not access your database directly if your project already uses ORM for database interactions.
|
||||
Why not use ORM directly inside your tests? Let's try to write a test using Laravel's ORM Eloquent.
|
||||
For this we need to configure the Laravel5 module. We won't need its web interaction methods like `amOnPage` or `see`,
|
||||
so let's enable only the ORM part of it:
|
||||
|
||||
```yaml
|
||||
actor: UnitTester
|
||||
modules:
|
||||
enabled:
|
||||
- Asserts
|
||||
- Laravel5:
|
||||
part: ORM
|
||||
- \Helper\Unit
|
||||
```
|
||||
|
||||
We included the Laravel5 module the same way we did for functional testing.
|
||||
Let's see how we can use it for integration tests:
|
||||
|
||||
```php
|
||||
<?php
|
||||
function testUserNameCanBeChanged()
|
||||
{
|
||||
// create a user from framework, user will be deleted after the test
|
||||
$id = $this->tester->haveRecord('users', ['name' => 'miles']);
|
||||
// access model
|
||||
$user = User::find($id);
|
||||
$user->setName('bill');
|
||||
$user->save();
|
||||
$this->assertEquals('bill', $user->getName());
|
||||
// verify data was saved using framework methods
|
||||
$this->tester->seeRecord('users', ['name' => 'bill']);
|
||||
$this->tester->dontSeeRecord('users', ['name' => 'miles']);
|
||||
}
|
||||
```
|
||||
|
||||
A very similar approach can be used for all frameworks that have an ORM implementing the ActiveRecord pattern.
|
||||
In Yii2 and Phalcon, the methods `haveRecord`, `seeRecord`, `dontSeeRecord` work in the same way.
|
||||
They also should be included by specifying `part: ORM` in order to not use the functional testing actions.
|
||||
|
||||
If you are using Symfony with Doctrine, you don't need to enable Symfony itself but just Doctrine2:
|
||||
|
||||
```yaml
|
||||
actor: UnitTester
|
||||
modules:
|
||||
enabled:
|
||||
- Asserts
|
||||
- Doctrine2:
|
||||
depends: Symfony
|
||||
- \Helper\Unit
|
||||
```
|
||||
|
||||
In this case you can use the methods from the Doctrine2 module, while Doctrine itself uses the Symfony module
|
||||
to establish connections to the database. In this case a test might look like:
|
||||
|
||||
```php
|
||||
<?php
|
||||
function testUserNameCanBeChanged()
|
||||
{
|
||||
// create a user from framework, user will be deleted after the test
|
||||
$id = $this->tester->haveInRepository(User::class, ['name' => 'miles']);
|
||||
// get entity manager by accessing module
|
||||
$em = $this->getModule('Doctrine2')->em;
|
||||
// get real user
|
||||
$user = $em->find(User::class, $id);
|
||||
$user->setName('bill');
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
$this->assertEquals('bill', $user->getName());
|
||||
// verify data was saved using framework methods
|
||||
$this->tester->seeInRepository(User::class, ['name' => 'bill']);
|
||||
$this->tester->dontSeeInRepository(User::class, ['name' => 'miles']);
|
||||
}
|
||||
```
|
||||
|
||||
In both examples you should not be worried about the data persistence between tests.
|
||||
The Doctrine2 and Laravel5 modules will clean up the created data at the end of a test.
|
||||
This is done by wrapping each test in a transaction and rolling it back afterwards.
|
||||
|
||||
### Accessing Module
|
||||
|
||||
Codeception allows you to access the properties and methods of all modules defined for this suite.
|
||||
Unlike using the UnitTester class for this purpose, using a module directly grants you access
|
||||
to all public properties of that module.
|
||||
|
||||
We have already demonstrated this in a previous example where we accessed the Entity Manager from a Doctrine2 module:
|
||||
|
||||
```php
|
||||
<?php
|
||||
/** @var Doctrine\ORM\EntityManager */
|
||||
$em = $this->getModule('Doctrine2')->em;
|
||||
```
|
||||
|
||||
If you use the `Symfony` module, here is how you can access the Symfony container:
|
||||
|
||||
```php
|
||||
<?php
|
||||
/** @var Symfony\Component\DependencyInjection\Container */
|
||||
$container = $this->getModule('Symfony')->container;
|
||||
```
|
||||
|
||||
The same can be done for all public properties of an enabled module. Accessible properties are listed in the module reference.
|
||||
|
||||
### Scenario Driven Testing
|
||||
|
||||
[Cest format](http://codeception.com/docs/07-AdvancedUsage#Cest-Classes) can also be used for integration testing.
|
||||
In some cases it makes tests cleaner as it simplifies module access by using common `$I->` syntax:
|
||||
|
||||
```php
|
||||
<?php
|
||||
public function buildShouldHaveSequence(\UnitTester $I)
|
||||
{
|
||||
$build = $I->have(Build::class, ['project_id' => $this->project->id]);
|
||||
$I->assertEquals(1, $build->sequence);
|
||||
$build = $I->have(Build::class, ['project_id' => $this->project->id]);
|
||||
$I->assertEquals(2, $build->sequence);
|
||||
$this->project->refresh();
|
||||
$I->assertEquals(3, $this->project->build_sequence);
|
||||
}
|
||||
```
|
||||
This format can be recommended for testing domain and database interactions.
|
||||
|
||||
In Cest format you don't have native support for test doubles so it's recommended
|
||||
to include a trait `\Codeception\Test\Feature\Stub` to enable mocks inside a test.
|
||||
Alternatively, install and enable [Mockery module](https://github.com/Codeception/MockeryModule).
|
||||
|
||||
## Advanced Tools
|
||||
|
||||
### Specify
|
||||
|
||||
When writing tests you should prepare them for constant changes in your application.
|
||||
Tests should be easy to read and maintain. If a specification of your application is changed,
|
||||
your tests should be updated as well. If you don't have a convention inside your team for documenting tests,
|
||||
you will have issues figuring out what tests will be affected by the introduction of a new feature.
|
||||
|
||||
That's why it's pretty important not just to cover your application with unit tests, but make unit tests self-explanatory.
|
||||
We do this for scenario-driven acceptance and functional tests, and we should do this for unit and integration tests as well.
|
||||
|
||||
For this case we have a stand-alone project [Specify](https://github.com/Codeception/Specify)
|
||||
(which is included in the phar package) for writing specifications inside unit tests:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class UserTest extends \Codeception\Test\Unit
|
||||
{
|
||||
use \Codeception\Specify;
|
||||
|
||||
/** @specify */
|
||||
private $user;
|
||||
|
||||
public function testValidation()
|
||||
{
|
||||
$this->user = User::create();
|
||||
|
||||
$this->specify("username is required", function() {
|
||||
$this->user->username = null;
|
||||
$this->assertFalse($this->user->validate(['username']));
|
||||
});
|
||||
|
||||
$this->specify("username is too long", function() {
|
||||
$this->user->username = 'toolooooongnaaaaaaameeee';
|
||||
$this->assertFalse($this->user->validate(['username']));
|
||||
});
|
||||
|
||||
$this->specify("username is ok", function() {
|
||||
$this->user->username = 'davert';
|
||||
$this->assertTrue($this->user->validate(['username']));
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
By using `specify` codeblocks, you can describe any piece of a test.
|
||||
This makes tests much cleaner and comprehensible for everyone in your team.
|
||||
|
||||
Code inside `specify` blocks is isolated. In the example above, any changes to `$this->user`
|
||||
will not be reflected in other code blocks as it is marked with `@specify` annotation.
|
||||
|
||||
Also, you may add [Codeception\Verify](https://github.com/Codeception/Verify) for BDD-style assertions.
|
||||
This tiny library adds more readable assertions, which is quite nice, if you are always confused
|
||||
about which argument in `assert` calls is expected and which one is actual:
|
||||
|
||||
```php
|
||||
<?php
|
||||
verify($user->getName())->equals('john');
|
||||
```
|
||||
|
||||
### Domain Assertions
|
||||
|
||||
The more complicated your domain is the more explicit your tests should be. With [DomainAssert](https://github.com/Codeception/DomainAssert)
|
||||
library you can easily create custom assertion methods for unit and integration tests.
|
||||
|
||||
It allows to reuse business rules inside assertion methods:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$user = new User;
|
||||
|
||||
// simple custom assertions below:
|
||||
$this->assertUserIsValid($user);
|
||||
$this->assertUserIsAdmin($user);
|
||||
|
||||
// use combined explicit assertion
|
||||
// to tell what you expect to check
|
||||
$this->assertUserCanPostToBlog($user, $blog);
|
||||
// instead of just calling a bunch of assertions
|
||||
$this->assertNotNull($user);
|
||||
$this->assertNotNull($blog);
|
||||
$this->assertContain($user, $blog->getOwners());
|
||||
```
|
||||
|
||||
With custom assertion methods you can improve readability of your tests and keep them focused around the specification.
|
||||
|
||||
### AspectMock
|
||||
|
||||
[AspectMock](https://github.com/Codeception/AspectMock) is an advanced mocking framework which allows you to replace any methods of any class in a test.
|
||||
Static methods, class methods, date and time functions can be easily replaced with AspectMock.
|
||||
For instance, you can test singletons!
|
||||
|
||||
```php
|
||||
<?php
|
||||
public function testSingleton()
|
||||
{
|
||||
$class = MySingleton::getInstance();
|
||||
$this->assertInstanceOf('MySingleton', $class);
|
||||
test::double('MySingleton', ['getInstance' => new DOMDocument]);
|
||||
$this->assertInstanceOf('DOMDocument', $class);
|
||||
}
|
||||
```
|
||||
|
||||
* [AspectMock on GitHub](https://github.com/Codeception/AspectMock)
|
||||
* [AspectMock in Action](http://codeception.com/07-31-2013/nothing-is-untestable-aspect-mock.html)
|
||||
* [How it Works](http://codeception.com/09-13-2013/understanding-aspectmock.html)
|
||||
|
||||
## Conclusion
|
||||
|
||||
PHPUnit tests are first-class citizens in test suites. Whenever you need to write and execute unit tests,
|
||||
you don't need to install PHPUnit separately, but use Codeception directly to execute them.
|
||||
Some nice features can be added to common unit tests by integrating Codeception modules.
|
||||
For most unit and integration testing, PHPUnit tests are enough. They run fast, and are easy to maintain.
|
||||
522
vendor/codeception/base/docs/06-ModulesAndHelpers.md
vendored
Normal file
522
vendor/codeception/base/docs/06-ModulesAndHelpers.md
vendored
Normal file
@@ -0,0 +1,522 @@
|
||||
# Modules and Helpers
|
||||
|
||||
Codeception uses modularity to create a comfortable testing environment for every test suite you write.
|
||||
|
||||
All actions and assertions that can be performed by the Tester object in a class are defined in modules.
|
||||
You can extend the testing suite with your own actions and assertions by writing them into a custom module.
|
||||
|
||||
Let's look at the following test:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I = new FunctionalTester($scenario);
|
||||
$I->amOnPage('/');
|
||||
$I->see('Hello');
|
||||
$I->seeInDatabase('users', array('id' => 1));
|
||||
$I->seeFileFound('running.lock');
|
||||
```
|
||||
|
||||
It can operate with different entities: the web page can be loaded with the PhpBrowser module,
|
||||
the database assertion uses the Db module, and file state can be checked with the Filesystem module.
|
||||
|
||||
Modules are attached to the Actor classes in the suite configuration.
|
||||
For example, in `tests/functional.suite.yml` we should see:
|
||||
|
||||
```yaml
|
||||
actor: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- PhpBrowser:
|
||||
url: http://localhost
|
||||
- Db:
|
||||
dsn: "mysql:host=localhost;dbname=testdb"
|
||||
- Filesystem
|
||||
```
|
||||
|
||||
The FunctionalTester class has its methods defined in modules. Actually, it doesn't contain any of them,
|
||||
but rather acts as a proxy. It knows which module executes this action and passes parameters into it.
|
||||
To make your IDE see all of the FunctionalTester methods, you should run use the `codecept build` command.
|
||||
It generates method signatures from enabled modules and saves them into a trait which is included in an actor.
|
||||
In the current example, the `tests/support/_generated/FunctionalTesterActions.php` file will be generated.
|
||||
By default, Codeception automatically rebuilds the Actions trait on each change of the suite configuration.
|
||||
|
||||
## Standard Modules
|
||||
|
||||
Codeception has many bundled modules which will help you run tests for different purposes and different environments.
|
||||
The idea of modules is to share common actions, so that developers and QA engineers can concentrate on testing
|
||||
and not on reinventing the wheel. Each module provides methods for testing its own part and
|
||||
by combining modules you can get a powerful setup to test an application at all levels.
|
||||
|
||||
There is the `WebDriver` module for acceptance testing, modules for all popular PHP frameworks,
|
||||
`PHPBrowser` to emulate browser execution, `REST` for testing APIs, and more.
|
||||
Modules are considered to be the most valuable part of Codeception.
|
||||
They are constantly improving to provide the best testing experience, and be flexible to satisfy everyone's needs.
|
||||
|
||||
### Module Conflicts
|
||||
|
||||
Modules may conflict with one another. If a module implements `Codeception\Lib\Interfaces\ConflictsWithModule`,
|
||||
it might declare a conflict rule to be used with other modules. For instance, WebDriver conflicts
|
||||
with all modules implementing the `Codeception\Lib\Interfaces\Web` interface.
|
||||
|
||||
```php
|
||||
public function _conflicts()
|
||||
{
|
||||
return 'Codeception\Lib\Interfaces\Web';
|
||||
}
|
||||
```
|
||||
|
||||
This way if you try to use two modules sharing the same conflicted interface you will get an exception.
|
||||
|
||||
To avoid confusion, **Framework modules, PhpBrowser, and WebDriver** can't be used together. For instance,
|
||||
the `amOnPage` method exists in all those modules, and you should not try to guess which module will actually execute it.
|
||||
If you are doing acceptance testing, set up either WebDriver or PHPBrowser but do not set both up at the same time.
|
||||
If you are doing functional testing, enable only one of the framework modules.
|
||||
|
||||
In case you need to use a module which depends on a conflicted one, specify it as a dependent module in the configuration.
|
||||
You may want to use `WebDriver` with the `REST` module which interacts with a server through `PhpBrowser`.
|
||||
In this case your config should look like this:
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- WebDriver:
|
||||
browser: firefox
|
||||
url: http://localhost
|
||||
- REST:
|
||||
url: http://localhost/api/v1
|
||||
depends: PhpBrowser
|
||||
```
|
||||
|
||||
This configuration will allow you to send GET/POST requests to the server's APIs while working with a site through a browser.
|
||||
|
||||
If you only need some parts of a conflicted module to be loaded, refer to the next section.
|
||||
|
||||
### Module Parts
|
||||
|
||||
Modules with *Parts* section in their reference can be partially loaded. This way, the `$I` object will have actions
|
||||
belonging to only a specific part of that module. Partially loaded modules can be also used to avoid module conflicts.
|
||||
|
||||
For instance, the Laravel5 module has an ORM part which contains database actions. You can enable the PhpBrowser module
|
||||
for testing and Laravel + ORM for connecting to the database and checking the data.
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- PhpBrowser:
|
||||
url: http://localhost
|
||||
- Laravel5:
|
||||
part: ORM
|
||||
```
|
||||
|
||||
The modules won't conflict as actions with the same names won't be loaded.
|
||||
|
||||
The REST module has parts for `Xml` and `Json` in the same way. If you are testing a REST service with only JSON responses,
|
||||
you can enable just the JSON part of this module:
|
||||
|
||||
```yaml
|
||||
actor: ApiTester
|
||||
modules:
|
||||
enabled:
|
||||
- REST:
|
||||
url: http://serviceapp/api/v1/
|
||||
depends: PhpBrowser
|
||||
part: Json
|
||||
```
|
||||
|
||||
## Helpers
|
||||
|
||||
Codeception doesn't restrict you to only the modules from the main repository.
|
||||
Your project might need your own actions added to the test suite. By running the `bootstrap` command,
|
||||
Codeception generates three dummy modules for you, one for each of the newly created suites.
|
||||
These custom modules are called 'Helpers', and they can be found in the `tests/_support` directory.
|
||||
|
||||
```php
|
||||
<?php
|
||||
namespace Helper;
|
||||
// here you can define custom functions for FunctionalTester
|
||||
|
||||
class Functional extends \Codeception\Module
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
Actions are also quite simple. Every action you define is a public function. Write a public method,
|
||||
then run the `build` command, and you will see the new function added into the FunctionalTester class.
|
||||
|
||||
<div class="alert alert-info">
|
||||
Public methods prefixed by `_` are treated as hidden and won't be added to your Actor class.
|
||||
</div>
|
||||
|
||||
Assertions can be a bit tricky. First of all, it's recommended to prefix all your assertion actions with `see` or `dontSee`.
|
||||
|
||||
Name your assertions like this:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seePageReloaded();
|
||||
$I->seeClassIsLoaded($classname);
|
||||
$I->dontSeeUserExist($user);
|
||||
```
|
||||
|
||||
And then use them in your tests:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seePageReloaded();
|
||||
$I->seeClassIsLoaded('FunctionalTester');
|
||||
$I->dontSeeUserExist($user);
|
||||
```
|
||||
|
||||
You can define assertions by using assertXXX methods in your modules.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
function seeClassExist($class)
|
||||
{
|
||||
$this->assertTrue(class_exists($class));
|
||||
}
|
||||
```
|
||||
|
||||
In your helpers you can use these assertions:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
function seeCanCheckEverything($thing)
|
||||
{
|
||||
$this->assertTrue(isset($thing), "this thing is set");
|
||||
$this->assertFalse(empty($any), "this thing is not empty");
|
||||
$this->assertNotNull($thing, "this thing is not null");
|
||||
$this->assertContains("world", $thing, "this thing contains 'world'");
|
||||
$this->assertNotContains("bye", $thing, "this thing doesn't contain 'bye'");
|
||||
$this->assertEquals("hello world", $thing, "this thing is 'Hello world'!");
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
### Accessing Other Modules
|
||||
|
||||
It's possible that you will need to access internal data or functions from other modules.
|
||||
For example, for your module you might need to access the responses or internal actions of other modules.
|
||||
|
||||
Modules can interact with each other through the `getModule` method.
|
||||
Please note that this method will throw an exception if the required module was not loaded.
|
||||
|
||||
Let's imagine that we are writing a module that reconnects to a database.
|
||||
It's supposed to use the dbh connection value from the Db module.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
function reconnectToDatabase() {
|
||||
$dbh = $this->getModule('Db')->dbh;
|
||||
$dbh->close();
|
||||
$dbh->open();
|
||||
}
|
||||
```
|
||||
|
||||
By using the `getModule` function, you get access to all of the public methods and properties of the requested module.
|
||||
The `dbh` property was defined as public specifically to be available to other modules.
|
||||
|
||||
Modules may also contain methods that are exposed for use in helper classes. Those methods start with a `_` prefix
|
||||
and are not available in Actor classes, so can be accessed only from modules and extensions.
|
||||
|
||||
You should use them to write your own actions using module internals.
|
||||
|
||||
```php
|
||||
<?php
|
||||
function seeNumResults($num)
|
||||
{
|
||||
// retrieving webdriver session
|
||||
/**@var $table \Facebook\WebDriver\WebDriverElement */
|
||||
$elements = $this->getModule('WebDriver')->_findElements('#result');
|
||||
$this->assertNotEmpty($elements);
|
||||
$table = reset($elements);
|
||||
$this->assertEquals('table', $table->getTagName());
|
||||
$results = $table->findElements('tr');
|
||||
// asserting that table contains exactly $num rows
|
||||
$this->assertEquals($num, count($results));
|
||||
}
|
||||
```
|
||||
|
||||
In this example we use the API of the <a href="https://github.com/facebook/php-webdriver">facebook/php-webdriver</a> library,
|
||||
a Selenium WebDriver client the module is build on.
|
||||
You can also access the `webDriver` property of a module to get access to the `Facebook\WebDriver\RemoteWebDriver` instance
|
||||
for direct Selenium interaction.
|
||||
|
||||
### Extending a Module
|
||||
|
||||
If accessing modules doesn't provide enough flexibility, you can extend a module inside a Helper class:
|
||||
|
||||
```php
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
class MyExtendedSelenium extends \Codeception\Module\WebDriver {
|
||||
}
|
||||
```
|
||||
|
||||
In this helper you can replace the parent's methods with your own implementation.
|
||||
You can also replace the `_before` and `_after` hooks, which might be an option
|
||||
when you need to customize starting and stopping of a testing session.
|
||||
|
||||
### Hooks
|
||||
|
||||
Each module can handle events from the running test. A module can be executed before the test starts,
|
||||
or after the test is finished. This can be useful for bootstrap/cleanup actions.
|
||||
You can also define special behavior for when the test fails. This may help you in debugging the issue.
|
||||
For example, the PhpBrowser module saves the current webpage to the `tests/_output` directory when a test fails.
|
||||
|
||||
All hooks are defined in [Codeception\Module](http://codeception.com/docs/reference/Commands) and are listed here. You are free to redefine them in your module.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
// HOOK: used after configuration is loaded
|
||||
public function _initialize()
|
||||
{
|
||||
}
|
||||
|
||||
// HOOK: before each suite
|
||||
public function _beforeSuite($settings = array())
|
||||
{
|
||||
}
|
||||
|
||||
// HOOK: after suite
|
||||
public function _afterSuite()
|
||||
{
|
||||
}
|
||||
|
||||
// HOOK: before each step
|
||||
public function _beforeStep(\Codeception\Step $step)
|
||||
{
|
||||
}
|
||||
|
||||
// HOOK: after each step
|
||||
public function _afterStep(\Codeception\Step $step)
|
||||
{
|
||||
}
|
||||
|
||||
// HOOK: before test
|
||||
public function _before(\Codeception\TestInterface $test)
|
||||
{
|
||||
}
|
||||
|
||||
// HOOK: after test
|
||||
public function _after(\Codeception\TestInterface $test)
|
||||
{
|
||||
}
|
||||
|
||||
// HOOK: on fail
|
||||
public function _failed(\Codeception\TestInterface $test, $fail)
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
Please note that methods with a `_` prefix are not added to the Actor class.
|
||||
This allows them to be defined as public but used only for internal purposes.
|
||||
|
||||
### Debug
|
||||
|
||||
As we mentioned, the `_failed` hook can help in debugging a failed test.
|
||||
You have the opportunity to save the current test's state and show it to the user, but you are not limited to this.
|
||||
|
||||
Each module can output internal values that may be useful during debug.
|
||||
For example, the PhpBrowser module prints the response code and current URL every time it moves to a new page.
|
||||
Thus, modules are not black boxes. They are trying to show you what is happening during the test.
|
||||
This makes debugging your tests less painful.
|
||||
|
||||
To display additional information, use the `debug` and `debugSection` methods of the module.
|
||||
Here is an example of how it works for PhpBrowser:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$this->debugSection('Request', $params);
|
||||
$this->client->request($method, $uri, $params);
|
||||
$this->debug('Response Code: ' . $this->client->getStatusCode());
|
||||
```
|
||||
|
||||
This test, running with the PhpBrowser module in debug mode, will print something like this:
|
||||
|
||||
```bash
|
||||
I click "All pages"
|
||||
* Request (GET) http://localhost/pages {}
|
||||
* Response code: 200
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Modules and Helpers can be configured from the suite configuration file, or globally from `codeception.yml`.
|
||||
|
||||
Mandatory parameters should be defined in the `$requiredFields` property of the class.
|
||||
Here is how it is done in the Db module:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class Db extends \Codeception\Module
|
||||
{
|
||||
protected $requiredFields = ['dsn', 'user', 'password'];
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
The next time you start the suite without setting one of these values, an exception will be thrown.
|
||||
|
||||
For optional parameters, you should set default values. The `$config` property is used to define optional parameters
|
||||
as well as their values. In the WebDriver module we use the default Selenium Server address and port.
|
||||
|
||||
```php
|
||||
<?php
|
||||
class WebDriver extends \Codeception\Module
|
||||
{
|
||||
protected $requiredFields = ['browser', 'url'];
|
||||
protected $config = ['host' => '127.0.0.1', 'port' => '4444'];
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
The host and port parameter can be redefined in the suite configuration.
|
||||
Values are set in the `modules:config` section of the configuration file.
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- WebDriver:
|
||||
url: 'http://mysite.com/'
|
||||
browser: 'firefox'
|
||||
- Db:
|
||||
cleanup: false
|
||||
repopulate: false
|
||||
```
|
||||
|
||||
Optional and mandatory parameters can be accessed through the `$config` property.
|
||||
Use `$this->config['parameter']` to get its value.
|
||||
|
||||
### Dynamic Configuration With Parameters
|
||||
|
||||
Modules can be dynamically configured from environment variables.
|
||||
Parameter storage should be specified in the global `codeception.yml` configuration inside the `params` section.
|
||||
Parameters can be loaded from environment vars, from yaml (Symfony format), .env (Laravel format), ini, or php files.
|
||||
|
||||
Use the `params` section of the global configuration file `codeception.yml` to specify how to load them.
|
||||
You can specify several sources for parameters to be loaded from.
|
||||
|
||||
Example: load parameters from the environment:
|
||||
|
||||
```yaml
|
||||
params:
|
||||
- env # load params from environment vars
|
||||
```
|
||||
|
||||
Example: load parameters from YAML file (Symfony):
|
||||
|
||||
```yaml
|
||||
params:
|
||||
- app/config/parameters.yml
|
||||
```
|
||||
|
||||
Example: load parameters from php file (Yii)
|
||||
|
||||
```yaml
|
||||
params:
|
||||
- config/params.php
|
||||
```
|
||||
|
||||
Example: load parameters from .env files (Laravel):
|
||||
|
||||
```yaml
|
||||
params:
|
||||
- .env
|
||||
- .env.testing
|
||||
```
|
||||
|
||||
Once loaded, parameter variables can be used as module configuration values.
|
||||
Use a variable name wrapped with `%` as a placeholder and it will be replaced by its value.
|
||||
|
||||
Let's say we want to specify credentials for a cloud testing service. We have loaded `SAUCE_USER`
|
||||
and `SAUCE_KEY` variables from environment, and now we are passing their values into config of `WebDriver`:
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- WebDriver:
|
||||
url: http://mysite.com
|
||||
host: '%SAUCE_USER%:%SAUCE_KEY%@ondemand.saucelabs.com'
|
||||
```
|
||||
|
||||
Parameters are also useful to provide connection credentials for the `Db` module (taken from Laravel's .env files):
|
||||
|
||||
```yaml
|
||||
module:
|
||||
enabled:
|
||||
- Db:
|
||||
dsn: "mysql:host=%DB_HOST%;dbname=%DB_DATABASE%"
|
||||
user: "%DB_USERNAME%"
|
||||
password: "DB_PASSWORD"
|
||||
```
|
||||
|
||||
### Runtime Configuration
|
||||
|
||||
If you want to reconfigure a module at runtime, you can use the `_reconfigure` method of the module.
|
||||
You may call it from a helper class and pass in all the fields you want to change.
|
||||
|
||||
In this case configuration will be changed instantly. In next example we change root URL for PhpBrowser to point to the admin area,
|
||||
so next `amOnPage('/')` will open `/admin/` page.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$this->getModule('PhpBrowser')->_reconfigure(array('url' => 'http://localhost/admin'));
|
||||
```
|
||||
|
||||
However, in WebDriver configuration changes can't be applied that easily. For instance, if you change the browser you need to close the current browser session and start a new one.
|
||||
For that WebDriver module provides `_restart` method which takes an array with config and restarts the browser.
|
||||
|
||||
```php
|
||||
<?php
|
||||
// start chrome
|
||||
$this->getModule('WebDriver')->_restart(['browser' => 'chrome']);
|
||||
// or just restart browser
|
||||
$this->getModule('WebDriver')->_restart();
|
||||
```
|
||||
|
||||
At the end of a test all configuration changes will be rolled back to the original configuration values.
|
||||
|
||||
### Runtime Configuration of a Test
|
||||
|
||||
Sometimes it is needed to set custom configuration for a specific test only.
|
||||
For [Cest](http://codeception.com/docs/07-AdvancedUsage#Cest-Classes) and [Test\Unit](http://codeception.com/docs/05-UnitTests)
|
||||
formats you can use `@prepare` annotation which can execute the code before other hooks are executed. This allows `@prepare`
|
||||
to change the module configuration in runtime. `@prepare` uses [dependency injection](http://codeception.com/docs/07-AdvancedUsage#Dependency-Injection)
|
||||
to automatically inject required modules into a method.
|
||||
|
||||
To run a specific test only in Chrome browser, you can call `_reconfigure` from WebDriver module for a test itself using `@prepare`.
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**
|
||||
* @prepare useChrome
|
||||
*/
|
||||
public function chromeSpecificTest()
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
protected function useChrome(\Codeception\Module\WebDriver $webdriver)
|
||||
{
|
||||
// WebDriver was injected by the class name
|
||||
$webdriver->_reconfigure(['browser' => 'chrome']);
|
||||
}
|
||||
```
|
||||
|
||||
Prepare methods can invoke all methods of a module, as well as hidden API methods (starting with `_`). Use them to customize the module setup for a specific test.
|
||||
|
||||
To change module configuration for a specific group of tests use [GroupObjects](http://codeception.com/docs/08-Customization#Group-Objects).
|
||||
|
||||
## Conclusion
|
||||
|
||||
Modules are the real power of Codeception. They are used to emulate multiple inheritances for Actor classes
|
||||
(UnitTester, FunctionalTester, AcceptanceTester, etc). Codeception provides modules to emulate web requests,
|
||||
access data, interact with popular PHP libraries, etc. If the bundled modules are not enough for you that's OK,
|
||||
you are free to write your own! Use Helpers (custom modules) for everything that Codeception can't do out of the box.
|
||||
Helpers also can be used to extend the functionality of the original modules.
|
||||
370
vendor/codeception/base/docs/06-ReusingTestCode.md
vendored
Normal file
370
vendor/codeception/base/docs/06-ReusingTestCode.md
vendored
Normal file
@@ -0,0 +1,370 @@
|
||||
# Reusing Test Code
|
||||
|
||||
Codeception uses modularity to create a comfortable testing environment for every test suite you write.
|
||||
Modules allow you to choose the actions and assertions that can be performed in tests.
|
||||
|
||||
## What are Actors
|
||||
|
||||
All actions and assertions that can be performed by the Actor object in a class are defined in modules.
|
||||
It might look like Codeception limits you in testing, but that's not true. You can extend the testing suite
|
||||
with your own actions and assertions, by writing them into a custom module, called a Helper.
|
||||
We will get back to this later in this chapter, but for now let's look at the following test:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->amOnPage('/');
|
||||
$I->see('Hello');
|
||||
$I->seeInDatabase('users', ['id' => 1]);
|
||||
$I->seeFileFound('running.lock');
|
||||
```
|
||||
|
||||
It can operate with different entities: the web page can be loaded with the PhpBrowser module,
|
||||
the database assertion uses the Db module, and the file state can be checked with the Filesystem module.
|
||||
|
||||
Modules are attached to Actor classes in the suite config.
|
||||
For example, in `tests/acceptance.suite.yml` we should see:
|
||||
|
||||
```yaml
|
||||
actor: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- PhpBrowser:
|
||||
url: http://localhost
|
||||
- Db
|
||||
- Filesystem
|
||||
```
|
||||
|
||||
The AcceptanceTester class has its methods defined in modules.
|
||||
Let's see what's inside the `AcceptanceTester` class, which is located inside the `tests/_support` directory:
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method void haveFriend($name, $actorClass = null)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class AcceptanceTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\AcceptanceTesterActions;
|
||||
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
||||
```
|
||||
|
||||
The most important part is the `_generated\AcceptanceTesterActions` trait, which is used as a proxy for enabled modules.
|
||||
It knows which module executes which action and passes parameters into it.
|
||||
This trait was created by running `codecept build` and is regenerated each time module or configuration changes.
|
||||
|
||||
### Authorization
|
||||
|
||||
It is recommended to put widely used actions inside an Actor class. A good example is the `login` action
|
||||
which would probably be actively involved in acceptance or functional testing:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
class AcceptanceTester extends \Codeception\Actor
|
||||
{
|
||||
// do not ever remove this line!
|
||||
use _generated\AcceptanceTesterActions;
|
||||
|
||||
public function login($name, $password)
|
||||
{
|
||||
$I = $this;
|
||||
$I->amOnPage('/login');
|
||||
$I->submitForm('#loginForm', [
|
||||
'login' => $name,
|
||||
'password' => $password
|
||||
]);
|
||||
$I->see($name, '.navbar');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Now you can use the `login` method inside your tests:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I = new AcceptanceTester($scenario);
|
||||
$I->login('miles', '123456');
|
||||
```
|
||||
|
||||
However, implementing all actions for reuse in a single actor class may lead to
|
||||
breaking the [Single Responsibility Principle](http://en.wikipedia.org/wiki/Single_responsibility_principle).
|
||||
|
||||
### Session Snapshot
|
||||
|
||||
If you need to authorize a user for each test, you can do so by submitting the login form at the beginning of every test.
|
||||
Running those steps takes time, and in the case of Selenium tests (which are slow by themselves)
|
||||
that time loss can become significant.
|
||||
|
||||
Codeception allows you to share cookies between tests, so a test user can stay logged in for other tests.
|
||||
|
||||
Let's improve the code of our `login` method, executing the form submission only once
|
||||
and restoring the session from cookies for each subsequent login function call:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
public function login($name, $password)
|
||||
{
|
||||
$I = $this;
|
||||
// if snapshot exists - skipping login
|
||||
if ($I->loadSessionSnapshot('login')) {
|
||||
return;
|
||||
}
|
||||
// logging in
|
||||
$I->amOnPage('/login');
|
||||
$I->submitForm('#loginForm', [
|
||||
'login' => $name,
|
||||
'password' => $password
|
||||
]);
|
||||
$I->see($name, '.navbar');
|
||||
// saving snapshot
|
||||
$I->saveSessionSnapshot('login');
|
||||
}
|
||||
```
|
||||
|
||||
Note that session restoration only works for `WebDriver` modules
|
||||
(modules implementing `Codeception\Lib\Interfaces\SessionSnapshot`).
|
||||
|
||||
## StepObjects
|
||||
|
||||
StepObjects are great if you need some common functionality for a group of tests.
|
||||
Let's say you are going to test an admin area of a site. You probably won't need the same actions from the admin area
|
||||
while testing the front end, so it's a good idea to move these admin-specific tests into their own class.
|
||||
We call such a classes StepObjects.
|
||||
|
||||
Lets create an Admin StepObject with the generator:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept generate:stepobject acceptance Admin
|
||||
```
|
||||
|
||||
You can supply optional action names. Enter one at a time, followed by a newline.
|
||||
End with an empty line to continue to StepObject creation.
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept generate:stepobject acceptance Admin
|
||||
Add action to StepObject class (ENTER to exit): loginAsAdmin
|
||||
Add action to StepObject class (ENTER to exit):
|
||||
StepObject was created in /tests/acceptance/_support/Step/Acceptance/Admin.php
|
||||
```
|
||||
|
||||
This will generate a class in `/tests/_support/Step/Acceptance/Admin.php` similar to this:
|
||||
|
||||
```php
|
||||
<?php
|
||||
namespace Step\Acceptance;
|
||||
|
||||
class Admin extends \AcceptanceTester
|
||||
{
|
||||
public function loginAsAdmin()
|
||||
{
|
||||
$I = $this;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
As you see, this class is very simple. It extends the `AcceptanceTester` class,
|
||||
meaning it can access all the methods and properties of `AcceptanceTester`.
|
||||
|
||||
The `loginAsAdmin` method may be implemented like this:
|
||||
|
||||
```php
|
||||
<?php
|
||||
namespace Step\Acceptance;
|
||||
|
||||
class Admin extends \AcceptanceTester
|
||||
{
|
||||
public function loginAsAdmin()
|
||||
{
|
||||
$I = $this;
|
||||
$I->amOnPage('/admin');
|
||||
$I->fillField('username', 'admin');
|
||||
$I->fillField('password', '123456');
|
||||
$I->click('Login');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In tests, you can use a StepObject by instantiating `Step\Acceptance\Admin` instead of `AcceptanceTester`:
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Step\Acceptance\Admin as AdminTester;
|
||||
|
||||
$I = new AdminTester($scenario);
|
||||
$I->loginAsAdmin();
|
||||
```
|
||||
|
||||
The same way as above, a StepObject can be instantiated automatically by the Dependency Injection Container
|
||||
when used inside the Cest format:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class UserCest
|
||||
{
|
||||
function showUserProfile(\Step\Acceptance\Admin $I)
|
||||
{
|
||||
$I->loginAsAdmin();
|
||||
$I->amOnPage('/admin/profile');
|
||||
$I->see('Admin Profile', 'h1');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you have a complex interaction scenario, you may use several step objects in one test.
|
||||
If you feel like adding too many actions into your Actor class
|
||||
(which is AcceptanceTester in this case) consider moving some of them into separate StepObjects.
|
||||
|
||||
## PageObjects
|
||||
|
||||
For acceptance and functional testing, we will not only need to have common actions being reused across different tests,
|
||||
we should have buttons, links and form fields being reused as well. For those cases we need to implement
|
||||
the [PageObject pattern](http://docs.seleniumhq.org/docs/06_test_design_considerations.jsp#page-object-design-pattern),
|
||||
which is widely used by test automation engineers. The PageObject pattern represents a web page as a class
|
||||
and the DOM elements on that page as its properties, and some basic interactions as its methods.
|
||||
PageObjects are very important when you are developing a flexible architecture of your tests.
|
||||
Do not hard-code complex CSS or XPath locators in your tests but rather move them into PageObject classes.
|
||||
|
||||
Codeception can generate a PageObject class for you with command:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept generate:pageobject Login
|
||||
```
|
||||
|
||||
This will create a `Login` class in `tests/_support/Page`.
|
||||
The basic PageObject is nothing more than an empty class with a few stubs.
|
||||
It is expected that you will populate it with the UI locators of a page it represents
|
||||
and then those locators will be used on a page.
|
||||
Locators are represented with public static properties:
|
||||
|
||||
```php
|
||||
<?php
|
||||
namespace Page;
|
||||
|
||||
class Login
|
||||
{
|
||||
public static $URL = '/login';
|
||||
|
||||
public static $usernameField = '#mainForm #username';
|
||||
public static $passwordField = '#mainForm input[name=password]';
|
||||
public static $loginButton = '#mainForm input[type=submit]';
|
||||
}
|
||||
```
|
||||
|
||||
And this is how this page object can be used in a test:
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Page\Login as LoginPage;
|
||||
|
||||
$I = new AcceptanceTester($scenario);
|
||||
$I->wantTo('login to site');
|
||||
$I->amOnPage(LoginPage::$URL);
|
||||
$I->fillField(LoginPage::$usernameField, 'bill evans');
|
||||
$I->fillField(LoginPage::$passwordField, 'debby');
|
||||
$I->click(LoginPage::$loginButton);
|
||||
$I->see('Welcome, bill');
|
||||
```
|
||||
|
||||
As you see, you can freely change markup of your login page, and all the tests interacting with this page
|
||||
will have their locators updated according to properties of LoginPage class.
|
||||
|
||||
But let's move further. The PageObject concept specifies that the methods for the page interaction
|
||||
should also be stored in a PageObject class. It now stores a passed instance of an Actor class.
|
||||
An AcceptanceTester can be accessed via the `AcceptanceTester` property of that class.
|
||||
Let's define a `login` method in this class:
|
||||
|
||||
```php
|
||||
<?php
|
||||
namespace Page;
|
||||
|
||||
class Login
|
||||
{
|
||||
public static $URL = '/login';
|
||||
|
||||
public static $usernameField = '#mainForm #username';
|
||||
public static $passwordField = '#mainForm input[name=password]';
|
||||
public static $loginButton = '#mainForm input[type=submit]';
|
||||
|
||||
/**
|
||||
* @var AcceptanceTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
public function __construct(\AcceptanceTester $I)
|
||||
{
|
||||
$this->tester = $I;
|
||||
}
|
||||
|
||||
public function login($name, $password)
|
||||
{
|
||||
$I = $this->tester;
|
||||
|
||||
$I->amOnPage(self::$URL);
|
||||
$I->fillField(self::$usernameField, $name);
|
||||
$I->fillField(self::$passwordField, $password);
|
||||
$I->click(self::$loginButton);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
And here is an example of how this PageObject can be used in a test:
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Page\Login as LoginPage;
|
||||
|
||||
$I = new AcceptanceTester($scenario);
|
||||
$loginPage = new LoginPage($I);
|
||||
$loginPage->login('bill evans', 'debby');
|
||||
$I->amOnPage('/profile');
|
||||
$I->see('Bill Evans Profile', 'h1');
|
||||
```
|
||||
|
||||
If you write your scenario-driven tests in the Cest format (which is the recommended approach),
|
||||
you can bypass the manual creation of a PageObject and delegate this task to Codeception.
|
||||
If you specify which object you need for a test, Codeception will try to create it using the dependency injection container.
|
||||
In the case of a PageObject you should declare a class as a parameter for a test method:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class UserCest
|
||||
{
|
||||
function showUserProfile(AcceptanceTester $I, \Page\Login $loginPage)
|
||||
{
|
||||
$loginPage->login('bill evans', 'debby');
|
||||
$I->amOnPage('/profile');
|
||||
$I->see('Bill Evans Profile', 'h1');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The dependency injection container can construct any object that requires any known class type.
|
||||
For instance, `Page\Login` required `AcceptanceTester`, and so it was injected into `Page\Login` constructor,
|
||||
and PageObject was created and passed into method arguments. You should explicitly specify
|
||||
the types of required objects for Codeception to know what objects should be created for a test.
|
||||
Dependency Injection will be described in the next chapter.
|
||||
|
||||
## Conclusion
|
||||
|
||||
There are lots of ways to create reusable and readable tests. Group common actions together
|
||||
and move them to an Actor class or StepObjects. Move CSS and XPath locators into PageObjects.
|
||||
Write your custom actions and assertions in Helpers.
|
||||
Scenario-driven tests should not contain anything more complex than `$I->doSomething` commands.
|
||||
Following this approach will allow you to keep your tests clean, readable, stable and make them easy to maintain.
|
||||
739
vendor/codeception/base/docs/07-AdvancedUsage.md
vendored
Normal file
739
vendor/codeception/base/docs/07-AdvancedUsage.md
vendored
Normal file
@@ -0,0 +1,739 @@
|
||||
# Advanced Usage
|
||||
|
||||
In this chapter we will cover some techniques and options that you can use to improve your testing experience
|
||||
and keep your project better organized.
|
||||
|
||||
## Cest Classes
|
||||
|
||||
If you want to get a class-like structure for your Cepts, you can use the Cest format instead of plain PHP.
|
||||
It is very simple and is fully compatible with Cept scenarios. It means that if you feel that your test is long enough
|
||||
and you want to split it, you can easily move it into classes.
|
||||
|
||||
You can create a Cest file by running the command:
|
||||
|
||||
```bash
|
||||
$ php vendor/bin/codecept generate:cest suitename CestName
|
||||
```
|
||||
|
||||
The generated file will look like this:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class BasicCest
|
||||
{
|
||||
public function _before(\AcceptanceTester $I)
|
||||
{
|
||||
}
|
||||
|
||||
public function _after(\AcceptanceTester $I)
|
||||
{
|
||||
}
|
||||
|
||||
// tests
|
||||
public function tryToTest(\AcceptanceTester $I)
|
||||
{
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Each public method of Cest (except those starting with `_`) will be executed as a test**
|
||||
and will receive an instance of the Actor class as the first parameter and the `$scenario` variable as the second one.
|
||||
|
||||
In `_before` and `_after` methods you can use common setups and teardowns for the tests in the class.
|
||||
|
||||
As you see, we are passing the Actor object into `tryToTest` method. This allows us to write scenarios the way we did before:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class BasicCest
|
||||
{
|
||||
// test
|
||||
public function tryToTest(\AcceptanceTester $I)
|
||||
{
|
||||
$I->amOnPage('/');
|
||||
$I->click('Login');
|
||||
$I->fillField('username', 'john');
|
||||
$I->fillField('password', 'coltrane');
|
||||
$I->click('Enter');
|
||||
$I->see('Hello, John');
|
||||
$I->seeInCurrentUrl('/account');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
As you see, Cest classes have no parents.
|
||||
This is done intentionally. It allows you to extend your classes with common behaviors and workarounds
|
||||
that may be used in child classes. But don't forget to make these methods `protected` so they won't be executed as tests.
|
||||
|
||||
Cest format also can contain hooks based on test results:
|
||||
|
||||
* `_failed` will be executed on failed test
|
||||
* `_passed` will be executed on passed test
|
||||
|
||||
```php
|
||||
<?php
|
||||
public function _failed(\AcceptanceTester $I)
|
||||
{
|
||||
// will be executed on test failure
|
||||
}
|
||||
|
||||
public function _passed(\AcceptanceTester $I)
|
||||
{
|
||||
// will be executed when test is successful
|
||||
}
|
||||
```
|
||||
|
||||
## Dependency Injection
|
||||
|
||||
Codeception supports simple dependency injection for Cest and \Codeception\TestCase\Test classes.
|
||||
It means that you can specify which classes you need as parameters of the special `_inject()` method,
|
||||
and Codeception will automatically create the respective objects and invoke this method,
|
||||
passing all dependencies as arguments. This may be useful when working with Helpers. Here's an example for Cest:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class SignUpCest
|
||||
{
|
||||
/**
|
||||
* @var Helper\SignUp
|
||||
*/
|
||||
protected $signUp;
|
||||
|
||||
/**
|
||||
* @var Helper\NavBarHelper
|
||||
*/
|
||||
protected $navBar;
|
||||
|
||||
protected function _inject(\Helper\SignUp $signUp, \Helper\NavBar $navBar)
|
||||
{
|
||||
$this->signUp = $signUp;
|
||||
$this->navBar = $navBar;
|
||||
}
|
||||
|
||||
public function signUp(\AcceptanceTester $I)
|
||||
{
|
||||
$this->navBar->click('Sign up');
|
||||
$this->signUp->register([
|
||||
'first_name' => 'Joe',
|
||||
'last_name' => 'Jones',
|
||||
'email' => 'joe@jones.com',
|
||||
'password' => '1234',
|
||||
'password_confirmation' => '1234'
|
||||
]);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
And for Test classes:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class MathTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
/**
|
||||
* @var Helper\Math
|
||||
*/
|
||||
protected $math;
|
||||
|
||||
protected function _inject(\Helper\Math $math)
|
||||
{
|
||||
$this->math = $math;
|
||||
}
|
||||
|
||||
public function testAll()
|
||||
{
|
||||
$this->assertEquals(3, $this->math->add(1, 2));
|
||||
$this->assertEquals(1, $this->math->subtract(3, 2));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
However, Dependency Injection is not limited to this. It allows you to **inject any class**,
|
||||
which can be constructed with arguments known to Codeception.
|
||||
|
||||
In order to make auto-wiring work, you will need to implement the `_inject()` method with the list of desired arguments.
|
||||
It is important to specify the type of arguments, so Codeception can guess which objects are expected to be received.
|
||||
The `_inject()` will only be invoked once, just after creation of the TestCase object (either Cest or Test).
|
||||
Dependency Injection will also work in a similar manner for Helper and Actor classes.
|
||||
|
||||
Each test of a Cest class can declare its own dependencies and receive them from method arguments:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class UserCest
|
||||
{
|
||||
function updateUser(\Helper\User $u, \AcceptanceTester $I, \Page\User $userPage)
|
||||
{
|
||||
$user = $u->createDummyUser();
|
||||
$userPage->login($user->getName(), $user->getPassword());
|
||||
$userPage->updateProfile(['name' => 'Bill']);
|
||||
$I->see('Profile was saved');
|
||||
$I->see('Profile of Bill','h1');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Moreover, Codeception can resolve dependencies recursively (when `A` depends on `B`, and `B` depends on `C` etc.)
|
||||
and handle parameters of primitive types with default values (like `$param = 'default'`).
|
||||
Of course, you are not allowed to have *cyclic dependencies*.
|
||||
|
||||
## Example Annotation
|
||||
|
||||
What if you want to execute the same test scenario with different data? In this case you can inject examples
|
||||
as `\Codeception\Example` instances.
|
||||
Data is defined via the `@example` annotation, using JSON or Doctrine-style notation (limited to a single line). Doctrine-style:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class EndpointCest
|
||||
{
|
||||
/**
|
||||
* @example ["/api/", 200]
|
||||
* @example ["/api/protected", 401]
|
||||
* @example ["/api/not-found-url", 404]
|
||||
* @example ["/api/faulty", 500]
|
||||
*/
|
||||
public function checkEndpoints(ApiTester $I, \Codeception\Example $example)
|
||||
{
|
||||
$I->sendGET($example[0]);
|
||||
$I->seeResponseCodeIs($example[1]);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
JSON:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class PageCest
|
||||
{
|
||||
/**
|
||||
* @example { "url": "/", "title": "Welcome" }
|
||||
* @example { "url": "/info", "title": "Info" }
|
||||
* @example { "url": "/about", "title": "About Us" }
|
||||
* @example { "url": "/contact", "title": "Contact Us" }
|
||||
*/
|
||||
public function staticPages(AcceptanceTester $I, \Codeception\Example $example)
|
||||
{
|
||||
$I->amOnPage($example['url']);
|
||||
$I->see($example['title'], 'h1');
|
||||
$I->seeInTitle($example['title']);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<div class="alert alert-info">
|
||||
If you use JSON notation please keep in mind that all string keys
|
||||
and values should be enclosed in double quotes (`"`) according to JSON standard.
|
||||
</div>
|
||||
|
||||
Key-value data in Doctrine-style annotation syntax:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class PageCest
|
||||
{
|
||||
/**
|
||||
* @example(url="/", title="Welcome")
|
||||
* @example(url="/info", title="Info")
|
||||
* @example(url="/about", title="About Us")
|
||||
* @example(url="/contact", title="Contact Us")
|
||||
*/
|
||||
public function staticPages(AcceptanceTester $I, \Codeception\Example $example)
|
||||
{
|
||||
$I->amOnPage($example['url']);
|
||||
$I->see($example['title'], 'h1');
|
||||
$I->seeInTitle($example['title']);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## DataProvider Annotations
|
||||
|
||||
You can also use the `@dataProvider` annotation for creating dynamic examples for [Cest classes](#Cest-Classes), using a **protected method** for providing example data:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class PageCest
|
||||
{
|
||||
/**
|
||||
* @dataProvider pageProvider
|
||||
*/
|
||||
public function staticPages(AcceptanceTester $I, \Codeception\Example $example)
|
||||
{
|
||||
$I->amOnPage($example['url']);
|
||||
$I->see($example['title'], 'h1');
|
||||
$I->seeInTitle($example['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function pageProvider() // alternatively, if you want the function to be public, be sure to prefix it with `_`
|
||||
{
|
||||
return [
|
||||
['url'=>"/", 'title'=>"Welcome"],
|
||||
['url'=>"/info", 'title'=>"Info"],
|
||||
['url'=>"/about", 'title'=>"About Us"],
|
||||
['url'=>"/contact", 'title'=>"Contact Us"]
|
||||
];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`@dataprovider` annotation is also available for [unit tests](https://codeception.com/docs/05-UnitTests), in this case the data provider **method must be public**.
|
||||
For more details about how to use data provider for unit tests, please refer to [PHPUnit documentation](https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers).
|
||||
|
||||
## Before/After Annotations
|
||||
|
||||
You can control execution flow with `@before` and `@after` annotations. You may move common actions
|
||||
into protected (non-test) methods and invoke them before or after the test method by putting them into annotations.
|
||||
It is possible to invoke several methods by using more than one `@before` or `@after` annotation.
|
||||
Methods are invoked in order from top to bottom.
|
||||
|
||||
```php
|
||||
<?php
|
||||
class ModeratorCest {
|
||||
|
||||
protected function login(AcceptanceTester $I)
|
||||
{
|
||||
$I->amOnPage('/login');
|
||||
$I->fillField('Username', 'miles');
|
||||
$I->fillField('Password', 'davis');
|
||||
$I->click('Login');
|
||||
}
|
||||
|
||||
/**
|
||||
* @before login
|
||||
*/
|
||||
public function banUser(AcceptanceTester $I)
|
||||
{
|
||||
$I->amOnPage('/users/charlie-parker');
|
||||
$I->see('Ban', '.button');
|
||||
$I->click('Ban');
|
||||
}
|
||||
|
||||
/**
|
||||
* @before login
|
||||
* @before cleanup
|
||||
* @after logout
|
||||
* @after close
|
||||
*/
|
||||
public function addUser(AcceptanceTester $I)
|
||||
{
|
||||
$I->amOnPage('/users/charlie-parker');
|
||||
$I->see('Ban', '.button');
|
||||
$I->click('Ban');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Environments
|
||||
|
||||
For cases where you need to run tests with different configurations you can define different config environments.
|
||||
The most typical use cases are running acceptance tests in different browsers,
|
||||
or running database tests using different database engines.
|
||||
|
||||
Let's demonstrate the usage of environments for the browsers case.
|
||||
|
||||
We need to add some new lines to `acceptance.suite.yml`:
|
||||
|
||||
``` yaml
|
||||
actor: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- WebDriver
|
||||
- \Helper\Acceptance
|
||||
config:
|
||||
WebDriver:
|
||||
url: 'http://127.0.0.1:8000/'
|
||||
browser: 'firefox'
|
||||
|
||||
env:
|
||||
phantom:
|
||||
modules:
|
||||
config:
|
||||
WebDriver:
|
||||
browser: 'phantomjs'
|
||||
|
||||
chrome:
|
||||
modules:
|
||||
config:
|
||||
WebDriver:
|
||||
browser: 'chrome'
|
||||
|
||||
firefox:
|
||||
# nothing changed
|
||||
```
|
||||
|
||||
Basically you can define different environments inside the `env` root, name them (`phantom`, `chrome` etc.),
|
||||
and then redefine any configuration parameters that were set before.
|
||||
|
||||
You can also define environments in separate configuration files placed in the directory specified by the `envs` option in
|
||||
the `paths` configuration:
|
||||
|
||||
```yaml
|
||||
paths:
|
||||
envs: tests/_envs
|
||||
```
|
||||
|
||||
The names of these files are used as environments names
|
||||
(e.g. `chrome.yml` or `chrome.dist.yml` for an environment named `chrome`).
|
||||
You can generate a new file with this environment configuration by using the `generate:environment` command:
|
||||
|
||||
```bash
|
||||
$ php vendor/bin/codecept g:env chrome
|
||||
```
|
||||
|
||||
In that file you can specify just the options you wish to override:
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
config:
|
||||
WebDriver:
|
||||
browser: 'chrome'
|
||||
```
|
||||
|
||||
The environment configuration files are merged into the main configuration before the suite configuration is merged.
|
||||
|
||||
You can easily switch between those configs by running tests with `--env` option.
|
||||
To run the tests only for PhantomJS you just need to pass `--env phantom` as an option:
|
||||
|
||||
```bash
|
||||
$ php vendor/bin/codecept run acceptance --env phantom
|
||||
```
|
||||
|
||||
To run the tests in all 3 browsers, list all the environments:
|
||||
|
||||
```bash
|
||||
$ php vendor/bin/codecept run acceptance --env phantom --env chrome --env firefox
|
||||
```
|
||||
|
||||
The tests will be executed 3 times, each time in a different browser.
|
||||
|
||||
It's also possible to merge multiple environments into a single configuration by separating them with a comma:
|
||||
|
||||
```bash
|
||||
$ php vendor/bin/codecept run acceptance --env dev,phantom --env dev,chrome --env dev,firefox
|
||||
```
|
||||
|
||||
The configuration is merged in the order given.
|
||||
This way you can easily create multiple combinations of your environment configurations.
|
||||
|
||||
Depending on the environment, you may choose which tests are to be executed.
|
||||
For example, you might need some tests to be executed in Firefox only, and some tests in Chrome only.
|
||||
|
||||
The desired environments can be specified with the `@env` annotation for tests in Test and Cest formats:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class UserCest
|
||||
{
|
||||
/**
|
||||
* This test will be executed only in 'firefox' and 'phantom' environments
|
||||
*
|
||||
* @env firefox
|
||||
* @env phantom
|
||||
*/
|
||||
public function webkitOnlyTest(AcceptanceTester $I)
|
||||
{
|
||||
// I do something
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For Cept you should use simple comments:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// @env firefox
|
||||
// @env phantom
|
||||
```
|
||||
|
||||
This way you can easily control which tests will be executed for each environment.
|
||||
|
||||
### Current values
|
||||
|
||||
Sometimes you may need to change the test behavior in real time.
|
||||
For instance, the behavior of the same test may differ in Firefox and in Chrome.
|
||||
In runtime we can retrieve the current environment name, test name,
|
||||
or list of enabled modules by calling the `$scenario->current()` method.
|
||||
|
||||
```php
|
||||
<?php
|
||||
// retrieve current environment
|
||||
$scenario->current('env');
|
||||
|
||||
// list of all enabled modules
|
||||
$scenario->current('modules');
|
||||
|
||||
// test name
|
||||
$scenario->current('name');
|
||||
|
||||
// browser name (if WebDriver module enabled)
|
||||
$scenario->current('browser');
|
||||
|
||||
// capabilities (if WebDriver module enabled)
|
||||
$scenario->current('capabilities');
|
||||
```
|
||||
|
||||
You can access `\Codeception\Scenario` in the Cept and Cest formats.
|
||||
In Cept, the `$scenario` variable is available by default,
|
||||
while in Cest you should retrieve it through dependency injection:
|
||||
|
||||
```php
|
||||
<?php
|
||||
public function myTest(\AcceptanceTester $I, \Codeception\Scenario $scenario)
|
||||
{
|
||||
if ($scenario->current('browser') == 'phantomjs') {
|
||||
// emulate popups for PhantomJS
|
||||
$I->executeScript('window.alert = function(){return true;}');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`Codeception\Scenario` is also available in Actor classes and StepObjects. You can access it with `$this->getScenario()`.
|
||||
|
||||
### Dependencies
|
||||
|
||||
With the `@depends` annotation you can specify a test that should be passed before the current one.
|
||||
If that test fails, the current test will be skipped. You should pass the method name of the test you are relying on.
|
||||
|
||||
```php
|
||||
<?php
|
||||
class ModeratorCest {
|
||||
|
||||
public function login(AcceptanceTester $I)
|
||||
{
|
||||
// logs moderator in
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends login
|
||||
*/
|
||||
public function banUser(AcceptanceTester $I)
|
||||
{
|
||||
// bans user
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`@depends` applies to the `Cest` and `Codeception\Test\Unit` formats. Dependencies can be set across different classes.
|
||||
To specify a dependent test from another file you should provide a *test signature*.
|
||||
Normally, the test signature matches the `className:methodName` format.
|
||||
But to get the exact test signature just run the test with the `--steps` option to see it:
|
||||
|
||||
```
|
||||
Signature: ModeratorCest:login`
|
||||
```
|
||||
|
||||
Codeception reorders tests so dependent tests will always be executed before the tests that rely on them.
|
||||
|
||||
## Interactive Console
|
||||
|
||||
The interactive console was added to try Codeception commands before executing them inside a test.
|
||||
|
||||

|
||||
|
||||
You can run the console with the following command:
|
||||
|
||||
``` bash
|
||||
$ php vendor/bin/codecept console suitename
|
||||
```
|
||||
|
||||
Now you can execute all the commands of an appropriate Actor class and see the results immediately.
|
||||
This is especially useful when used with the `WebDriver` module. It always takes too long to launch Selenium
|
||||
and the browser for tests. But with the console you can try different selectors, and different commands,
|
||||
and then write a test that should pass when executed.
|
||||
|
||||
And a special hint: show your boss how you can easily manipulate web pages with the console and Selenium.
|
||||
It will be easy to convince them to automate this step and introduce acceptance testing to the project.
|
||||
|
||||
## Running from different folders
|
||||
|
||||
If you have several projects with Codeception tests, you can use a single `codecept` file to run all of your tests.
|
||||
You can pass the `-c` option to any Codeception command (except `bootstrap`), to execute Codeception in another directory:
|
||||
|
||||
```bash
|
||||
$ php vendor/bin/codecept run -c ~/projects/ecommerce/
|
||||
$ php vendor/bin/codecept run -c ~/projects/drupal/
|
||||
$ php vendor/bin/codecept generate:cept acceptance CreateArticle -c ~/projects/drupal/
|
||||
```
|
||||
|
||||
To create a project in directory different from the current one, just provide its path as a parameter:
|
||||
|
||||
```bash
|
||||
$ php vendor/bin/codecept bootstrap ~/projects/drupal/
|
||||
```
|
||||
|
||||
Also, the `-c` option allows you to specify another config file to be used.
|
||||
Thus, you can have several `codeception.yml` files for your test suite (e.g. to to specify different environments
|
||||
and settings). Just pass the `.yml` filename as the `-c` parameter to execute tests with specific config settings.
|
||||
|
||||
## Groups
|
||||
|
||||
There are several ways to execute a bunch of tests. You can run tests from a specific directory:
|
||||
|
||||
```bash
|
||||
$ php vendor/bin/codecept run tests/acceptance/admin
|
||||
```
|
||||
|
||||
You can execute one (or several) specific groups of tests:
|
||||
|
||||
```bash
|
||||
$ php vendor/bin/codecept run -g admin -g editor
|
||||
```
|
||||
|
||||
The concept of groups was taken from PHPUnit and behave in the same way.
|
||||
|
||||
For Test and Cest files you can use the `@group` annotation to add a test to a group.
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**
|
||||
* @group admin
|
||||
*/
|
||||
public function testAdminUser()
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
For Cept files, use pseudo-annotations in comments:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// @group admin
|
||||
// @group editor
|
||||
$I = new AcceptanceTester($scenario);
|
||||
$I->wantToTest('admin area');
|
||||
```
|
||||
|
||||
For `.feature`-files (Gherkin) use tags:
|
||||
|
||||
```gherkin
|
||||
@admin @editor
|
||||
Feature: Admin area
|
||||
```
|
||||
|
||||
### Group Files
|
||||
|
||||
Groups can be defined in global or suite configuration files.
|
||||
Tests for groups can be specified as an array of file names or directories containing them:
|
||||
|
||||
```yaml
|
||||
groups:
|
||||
# add 2 tests to db group
|
||||
db: [tests/unit/PersistTest.php, tests/unit/DataTest.php]
|
||||
|
||||
# add all tests from a directory to api group
|
||||
api: [tests/functional/api]
|
||||
```
|
||||
|
||||
A list of tests for the group can be passed from a Group file. It should be defined in plain text with test names on separate lines:
|
||||
|
||||
```bash
|
||||
tests/unit/DbTest.php
|
||||
tests/unit/UserTest.php:create
|
||||
tests/unit/UserTest.php:update
|
||||
```
|
||||
A group file can be included by its relative filename:
|
||||
|
||||
```yaml
|
||||
groups:
|
||||
# requiring a group file
|
||||
slow: tests/_data/slow.txt
|
||||
```
|
||||
|
||||
You can create group files manually or generate them from third party applications.
|
||||
For example, you can write a script that updates the slow group by taking the slowest tests from xml report.
|
||||
|
||||
You can even specify patterns for loading multiple group files with a single definition:
|
||||
|
||||
```yaml
|
||||
groups:
|
||||
p*: tests/_data/p*
|
||||
```
|
||||
|
||||
This will load all found `p*` files in `tests/_data` as groups. Group names will be as follows p1,p2,...,pN.
|
||||
|
||||
## Formats
|
||||
|
||||
In addition to the standard test formats (Cept, Cest, Unit, Gherkin) you can implement your own format classes to customise your test execution.
|
||||
Specify these in your suite configuration:
|
||||
|
||||
```yaml
|
||||
formats:
|
||||
- \My\Namespace\MyFormat
|
||||
```
|
||||
|
||||
Then define a class which implements the LoaderInterface
|
||||
|
||||
```php
|
||||
namespace My\Namespace;
|
||||
|
||||
class MyFormat implements \Codeception\Test\Loader\LoaderInterface
|
||||
{
|
||||
protected $tests;
|
||||
|
||||
protected $settings;
|
||||
|
||||
public function __construct($settings = [])
|
||||
{
|
||||
//These are the suite settings
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
public function loadTests($filename)
|
||||
{
|
||||
//Load file and create tests
|
||||
}
|
||||
|
||||
public function getTests()
|
||||
{
|
||||
return $this->tests;
|
||||
}
|
||||
|
||||
public function getPattern()
|
||||
{
|
||||
return '~Myformat\.php$~';
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Shell auto-completion
|
||||
|
||||
For bash and zsh shells, you can use auto-completion for your Codeception projects by executing the following in your shell (or add it to your .bashrc/.zshrc):
|
||||
```bash
|
||||
# BASH ~4.x, ZSH
|
||||
source <([codecept location] _completion --generate-hook --program codecept --use-vendor-bin)
|
||||
|
||||
# BASH ~3.x, ZSH
|
||||
[codecept location] _completion --generate-hook --program codecept --use-vendor-bin | source /dev/stdin
|
||||
|
||||
# BASH (any version)
|
||||
eval $([codecept location] _completion --generate-hook --program codecept --use-vendor-bin)
|
||||
```
|
||||
|
||||
### Explanation
|
||||
|
||||
By using the above code in your shell, Codeception will try to autocomplete the following:
|
||||
* Commands
|
||||
* Suites
|
||||
* Test paths
|
||||
|
||||
Usage of `-use-vendor-bin` is optional. This option will work for most Codeception projects, where Codeception is located in your `vendor/bin` folder.
|
||||
But in case you are using a global Codeception installation for example, you wouldn't use this option.
|
||||
|
||||
Note that with the `-use-vendor-bin` option, your commands will be completed using the Codeception binary located in your project's root.
|
||||
Without the option, it will use whatever Codeception binary you originally used to generate the completion script ('codecept location' in the above examples)
|
||||
|
||||
## Conclusion
|
||||
|
||||
Codeception is a framework which may look simple at first glance
|
||||
but it allows you to build powerful tests with a single API, refactor them,
|
||||
and write them faster using the interactive console. Codeception tests can be easily organized in groups or Cest classes.
|
||||
557
vendor/codeception/base/docs/07-BDD.md
vendored
Normal file
557
vendor/codeception/base/docs/07-BDD.md
vendored
Normal file
@@ -0,0 +1,557 @@
|
||||
# Behavior Driven Development
|
||||
|
||||
Behavior Driven Development (BDD) is a popular software development methodology. BDD is considered an extension of TDD, and is greatly inspired by [Agile](http://agilemanifesto.org/) practices. The primary reason to choose BDD as your development process is to break down communication barriers between business and technical teams. BDD encourages the use of automated testing to verify all documented features of a project from the very beginning. This is why it is common to talk about BDD in the context of test frameworks (like Codeception). The BDD approach, however, is about much more than testing - it is a common language for all team members to use during the development process.
|
||||
|
||||
## What is Behavior Driven Development
|
||||
|
||||
BDD was introduced by [Dan North](https://dannorth.net/introducing-bdd/). He described it as:
|
||||
|
||||
> outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters.
|
||||
|
||||
BDD has its own evolution from the days it was born, started by replacing "test" to "should" in unit tests, and moving towards powerful tools like Cucumber and Behat, which made user stories (human readable text) to be executed as an acceptance test.
|
||||
|
||||
The idea of story BDD can be narrowed to:
|
||||
|
||||
* describe features in a scenario with a formal text
|
||||
* use examples to make abstract things concrete
|
||||
* implement each step of a scenario for testing
|
||||
* write actual code implementing the feature
|
||||
|
||||
By writing every feature in User Story format that is automatically executable as a test we ensure that: business, developers, QAs and managers are in the same boat.
|
||||
|
||||
BDD encourages exploration and debate in order to formalize the requirements and the features that needs to be implemented by requesting to write the User Stories in a way that everyone can understand.
|
||||
|
||||
By making tests to be a part of User Story, BDD allows non-technical personnel to write (or edit) Acceptance tests.
|
||||
|
||||
With this procedure we also ensure that everyone in a team knows what has been developed, what has not, what has been tested and what has not.
|
||||
|
||||
### Ubiquitous Language
|
||||
|
||||
The ubiquitous language is always referred as *common* language. That is it's main benefit. It is not a couple of our business specification's words, and not a couple of developer's technical terms. It is a common words and terms that can be understood by people for whom we are building the software and should be understood by developers. Establishing correct communication between this two groups people is vital for building successful project that will fit the domain and fulfill all business needs.
|
||||
|
||||
Each feature of a product should be born from a talk between
|
||||
|
||||
* business (analysts, product owner)
|
||||
* developers
|
||||
* QAs
|
||||
|
||||
which are known in BDD as "three amigos".
|
||||
|
||||
Such talks should produce written stories. There should be an actor that doing some things, the feature that should be fulfilled within the story and the result achieved.
|
||||
|
||||
We can try to write such simple story:
|
||||
|
||||
```
|
||||
As a customer I want to buy several products
|
||||
I put first product with $600 price to my cart
|
||||
And then another one with $1000 price
|
||||
When I go to checkout process
|
||||
I should see that total number of products I want to buy is 2
|
||||
And my order amount is $1600
|
||||
```
|
||||
|
||||
As we can see this simple story highlights core concepts that are called *contracts*. We should fulfill those contracts to model software correctly. But how we can verify that those contracts are being satisfied? [Cucumber](http://cucumber.io) introduced a special language for such stories called **Gherkin**. Same story transformed to Gherkin will look like this:
|
||||
|
||||
```gherkin
|
||||
Feature: checkout process
|
||||
In order to buy products
|
||||
As a customer
|
||||
I want to be able to buy several products
|
||||
|
||||
Scenario:
|
||||
Given I have product with $600 price in my cart
|
||||
And I have product with $1000 price
|
||||
When I go to checkout process
|
||||
Then I should see that total number of products is 2
|
||||
And my order amount is $1600
|
||||
```
|
||||
|
||||
Cucumber, Behat, and sure, **Codeception** can execute this scenario step by step as an automated test.
|
||||
Every step in this scenario requires a code which defines it.
|
||||
|
||||
## Gherkin
|
||||
|
||||
Let's learn some more about Gherkin format and then we will see how to execute it with Codeception:
|
||||
|
||||
### Features
|
||||
|
||||
Whenever you start writing a story you are describing a specific feature of an application, with a set of scenarios and examples describing this feature.
|
||||
|
||||
Feature file is written in Gherkin format. Codeception can generate a feature file for you.
|
||||
We will assume that we will use scenarios in feature files for acceptance tests, so feature files to be placed in `acceptance` suite directory:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept g:feature acceptance checkout
|
||||
```
|
||||
|
||||
Generated template will look like this:
|
||||
|
||||
```gherkin
|
||||
Feature: checkout
|
||||
In order to ...
|
||||
As a ...
|
||||
I need to ...
|
||||
|
||||
Scenario: try checkout
|
||||
```
|
||||
|
||||
This template can be fulfilled by setting actor and goals:
|
||||
|
||||
```gherkin
|
||||
Feature: checkout
|
||||
In order to buy product
|
||||
As a customer
|
||||
I need to be able to checkout the selected products
|
||||
```
|
||||
|
||||
Next, we will describe this feature by writing examples for it
|
||||
|
||||
#### Scenarios
|
||||
|
||||
Scenarios are live examples of feature usage. Inside a feature file it should be written inside a *Feature* block. Each scenario should contain its title:
|
||||
|
||||
```gherkin
|
||||
Feature: checkout
|
||||
In order to buy product
|
||||
As a customer
|
||||
I need to be able to checkout the selected products
|
||||
|
||||
Scenario: order several products
|
||||
```
|
||||
|
||||
Scenarios are written in step-by-step manner using Given-When-Then approach. At start, scenario should describe its context with **Given** keyword:
|
||||
|
||||
```gherkin
|
||||
Given I have product with $600 price in my cart
|
||||
And I have product with $1000 price in my cart
|
||||
```
|
||||
|
||||
Here we also use word **And** to extend the Given and not to repeat it in each line.
|
||||
|
||||
This is how we described the initial conditions. Next, we perform some action. We use **When** keyword for it:
|
||||
|
||||
```gherkin
|
||||
When I go to checkout process
|
||||
```
|
||||
|
||||
And in the end we are verifying our expectation using **Then** keyword. The action changed the initial given state, and produced some results. Let's check that those results are what we actually expect.
|
||||
|
||||
```gherkin
|
||||
Then I should see that total number of products is 2
|
||||
And my order amount is $1600
|
||||
```
|
||||
|
||||
We can test this scenario by executing it in dry-run mode. In this mode test won't be executed (actually, we didn't define any step for it, so it won't be executed in any case).
|
||||
|
||||
```bash
|
||||
$ codecept dry-run acceptance checkout.feature
|
||||
```
|
||||
|
||||
```bash
|
||||
checkout: order several products
|
||||
Signature: checkout:order several products
|
||||
Test: tests/acceptance/checkout.feature:order several products
|
||||
Scenario --
|
||||
In order to buy product
|
||||
As a customer
|
||||
I need to be able to checkout the selected products
|
||||
Given i have product with $600 price in my cart
|
||||
And i have product with $1000 price in my cart
|
||||
When i go to checkout process
|
||||
Then i should see that total number of products is 2
|
||||
And my order amount is $1600
|
||||
|
||||
INCOMPLETE
|
||||
Step definition for `I have product with $600 price in my cart` not found in contexts
|
||||
Step definition for `I have product with $1000 price` not found in contexts
|
||||
Step definition for `I go to checkout process` not found in contexts
|
||||
Step definition for `I should see that total number of products is 2` not found in contexts
|
||||
Step definition for `my order amount is $1600` not found in contexts
|
||||
Run gherkin:snippets to define missing steps
|
||||
```
|
||||
|
||||
Besides the scenario steps listed we got the notification that our steps are not defined yet.
|
||||
We can define them easily by executing `gherkin:snippets` command for the given suite:
|
||||
|
||||
```bash
|
||||
codecept gherkin:snippets acceptance
|
||||
```
|
||||
|
||||
This will produce code templates for all undefined steps in all feature files of this suite.
|
||||
Our next step will be to define those steps and transforming feature-file into valid test.
|
||||
|
||||
### Step Definitions
|
||||
|
||||
To match steps from a feature file to PHP code we use annotation which are added to class methods.
|
||||
By default Codeception expects that all methods marked with `@Given`, `@When`, `@Then` annotation.
|
||||
Each annotation should contain a step string.
|
||||
|
||||
```
|
||||
/** @Given I am logged as admin */
|
||||
```
|
||||
|
||||
Steps can also be matched with regex expressions. This way we can make more flexible steps
|
||||
|
||||
```
|
||||
/** @Given /I am (logged|authorized) as admin/ */
|
||||
```
|
||||
|
||||
Please note that regular expressions should start and end with `/` char. Regex is also used to match parameters and pass them as arguments into methods.
|
||||
|
||||
```php
|
||||
<?php
|
||||
/** @Given /I am (?:logged|authorized) as "(\w+)"/ */
|
||||
function amAuthorized($role)
|
||||
{
|
||||
// logged or authorized does not matter to us
|
||||
// so we added ?: for this capture group
|
||||
}
|
||||
```
|
||||
|
||||
Parameters can be also passed in non-regex strings using ":" params placeholder.
|
||||
|
||||
```
|
||||
/** @Given I am logged in as :role */
|
||||
```
|
||||
|
||||
This will match any word (passed in double quotes) or a number passed:
|
||||
|
||||
```
|
||||
Given I am logged in as "admin"
|
||||
Given I am logged in as 1
|
||||
```
|
||||
|
||||
Steps are defined in Context files. Default context is an actor class, i.e. for acceptance testing suite default context is `AcceptanceTester` class. However, you can define steps in any classes and include them as contexts. It is useful to define steps in StepObject and PageObject classes.
|
||||
|
||||
To list all defined steps run `gherkin:steps` command:
|
||||
|
||||
```bash
|
||||
codecept gherkin:steps
|
||||
```
|
||||
|
||||
## Testing Behavior
|
||||
|
||||
As it was mentioned, feature files is not just a user story.
|
||||
By writing features in formal language called Gherkin we can execute those scenarios as automated tests.
|
||||
There is no restrictions in the way how those scenarios are supposed to be tested. Tests can be executed at functional, acceptance, or domain level. However, we will concentrate on acceptance or UI tests in current guide.
|
||||
|
||||
### Acceptance Testing
|
||||
|
||||
As we generated snippets for missing steps with `gherkin:snippets` command, we will define them in `AcceptanceTester` file.
|
||||
|
||||
```php
|
||||
<?php
|
||||
class AcceptanceTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\AcceptanceTesterActions;
|
||||
|
||||
/**
|
||||
* @Given I have product with :num1 price in my cart
|
||||
*/
|
||||
public function iHaveProductWithPriceInMyCart($num1)
|
||||
{
|
||||
throw new \Codeception\Exception\Incomplete("Step `I have product with :num1 price in my cart` is not defined");
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I go to checkout process
|
||||
*/
|
||||
public function iGoToCheckoutProcess()
|
||||
{
|
||||
throw new \Codeception\Exception\Incomplete("Step `I go to checkout process` is not defined");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see that total number of products is :num1
|
||||
*/
|
||||
public function iShouldSeeThatTotalNumberOfProductsIs($num1)
|
||||
{
|
||||
throw new \Codeception\Exception\Incomplete("Step `I should see that total number of products is :num1` is not defined");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then my order amount is :num1
|
||||
*/
|
||||
public function myOrderAmountIs($num1)
|
||||
{
|
||||
throw new \Codeception\Exception\Incomplete("Step `my order amount is :num1` is not defined");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Please note that `:num1` placeholder can be used for strings and numbers (may contain currency sign).
|
||||
In current case `:num1` matches `$600` and `$num1` is assigned to be 600. If you need to receive exact string, wrap the value into quotes: `"600$"`
|
||||
|
||||
By default they throw Incomplete exceptions to ensure test with missing steps won't be accidentally marked as successful. We will need to implement those steps. As we are in acceptance suite we are probably using [PHPBrowser](http://codeception.com/docs/modules/PhpBrowser) or [WebDriver](http://codeception.com/docs/modules/WebDriver) modules. This means that we can use their methods inside Tester file, as we do with writing tests using `$I->`. You can use `amOnPage`, `click`, `see` methods inside a step definitions, so each Gherkin scenario step to be extended with basic Codeception steps. Let's show how it can be implemented in our case:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class AcceptanceTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\AcceptanceTesterActions;
|
||||
|
||||
/**
|
||||
* @Given I have product with :num1 price in my cart
|
||||
*/
|
||||
public function iHaveProductWithPriceInMyCart($num1)
|
||||
{
|
||||
// haveRecord method is available in Laravel, Phalcon, Yii modules
|
||||
$productId = $this->haveRecord('Product', ['name' => 'randomProduct'.uniqid(), 'price' => $num1]);
|
||||
$this->amOnPage("/item/$productId");
|
||||
$this->click('Order');
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I go to checkout process
|
||||
*/
|
||||
public function iGoToCheckoutProcess()
|
||||
{
|
||||
$this->amOnPage('/checkout');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see that total number of products is :num1
|
||||
*/
|
||||
public function iShouldSeeThatTotalNumberOfProductsIs($num1)
|
||||
{
|
||||
$this->see($num1, '.products-count');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then my order amount is :num1
|
||||
*/
|
||||
public function myOrderAmountIs($num1)
|
||||
{
|
||||
$this->see($num1, '.total');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To make testing more effective we assumed that we are using one of the ActiveRecord frameworks like Laravel, Yii, or Phalcon so we are able to dynamically create records in database with `haveRecord` method. After that we are opening browser and testing our web pages to see that after selecting those products we really see the price was calculated correctly.
|
||||
|
||||
We can dry-run (or run) our feature file to see that Given/When/Then are expanded with substeps:
|
||||
|
||||
```bash
|
||||
Given i have product with $600 price in my cart
|
||||
I have record 'Product',{"name":"randomProduct571fad4f88a04","price":"600"}
|
||||
I am on page "/item/1"
|
||||
I click "Order"
|
||||
And i have product with $1000 price in my cart
|
||||
I have record 'Product',{"name":"randomProduct571fad4f88b14","price":"1000"}
|
||||
I am on page "/item/2"
|
||||
I click "Order"
|
||||
When i go to checkout process
|
||||
I am on page "/checkout"
|
||||
Then i should see that total number of products is 2
|
||||
I see "2",".products-count"
|
||||
And my order amount is $1600
|
||||
I see "1600",".total"
|
||||
```
|
||||
|
||||
This way feature file runs just the same as any other Codeception test. Substeps give us detailed information of how the scenario is being executed.
|
||||
|
||||
One of the criticism for testing with Gherkin was that only technical team were aware of how the test scenario is executed. This could have lead to false-positive tests. Developers could have used empty steps for scenarios (or irrelevant ones) and produced invalid tests for valid scenarios. Codeception brings communication to a next level, everyone in a team can understand what happens on a lower (technical) level. Scenario expanding to substeps shows the actual test execution process. Anyone in a team can read the output, and invest their efforts into improving the test suite.
|
||||
|
||||
## Advanced Gherkin
|
||||
|
||||
Let's improve our BDD suite by using the advanced features of Gherkin language.
|
||||
|
||||
### Background
|
||||
|
||||
If a group of scenarios have the same initial steps, let's that for dashboard we need always need to be logged in as administrator. We can use *Background* section to do the required preparations and not to repeat same steps across scenarios.
|
||||
|
||||
```gherkin
|
||||
Feature: Dashboard
|
||||
In order to view current state of business
|
||||
As an owner
|
||||
I need to be able to see reports on dashboard
|
||||
|
||||
Background:
|
||||
Given I am logged in as administrator
|
||||
And I open dashboard page
|
||||
```
|
||||
|
||||
Steps in background are defined the same way as in scenarios.
|
||||
|
||||
### Tables
|
||||
|
||||
Scenarios can become more descriptive when you represent repeating data as tables. Instead of writing several steps "I have product with :num1 $ price in my cart" we can have one step with multiple values in it.
|
||||
|
||||
```gherkin
|
||||
Given i have products in my cart
|
||||
| name | category | price |
|
||||
| Harry Potter | Books | 5 |
|
||||
| iPhone 5 | Smartphones | 1200 |
|
||||
| Nuclear Bomb | Weapons | 100000 |
|
||||
```
|
||||
|
||||
Tables is a recommended ways to pass arrays into test scenarios.
|
||||
Inside a step definition data is stored in argument passed as `\Behat\Gherkin\Node\TableNode` instance.
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**
|
||||
* @Given i have products in my cart
|
||||
*/
|
||||
public function iHaveProductsInCart(\Behat\Gherkin\Node\TableNode $products)
|
||||
{
|
||||
// iterate over all rows
|
||||
foreach ($node->getRows() as $index => $row) {
|
||||
if ($index === 0) { // first row to define fields
|
||||
$keys = $row;
|
||||
continue;
|
||||
}
|
||||
$this->haveRecord('Product', array_combine($keys, $row));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
In case scenarios represent the same logic but differ on data, we can use *Scenario Outline* to provide different examples for the same behavior. Scenario outline is just like a basic scenario with some values replaced with placeholders, which are filled from a table. Each set of values is executed as a different test.
|
||||
|
||||
```gherkin
|
||||
Scenario Outline: order discount
|
||||
Given I have product with price <price>$ in my cart
|
||||
And discount for orders greater than $20 is 10 %
|
||||
When I go to checkout
|
||||
Then I should see overall price is "<total>" $
|
||||
|
||||
Examples:
|
||||
| price | total |
|
||||
| 10 | 10 |
|
||||
| 20 | 20 |
|
||||
| 21 | 18.9 |
|
||||
| 30 | 27 |
|
||||
| 50 | 45 |
|
||||
```
|
||||
|
||||
### Long Strings
|
||||
|
||||
Text values inside a scenarios can be set inside a `"""` block:
|
||||
|
||||
```gherkin
|
||||
Then i see in file "codeception.yml"
|
||||
"""
|
||||
paths:
|
||||
tests: tests
|
||||
log: tests/_output
|
||||
data: tests/_data
|
||||
helpers: tests/_support
|
||||
envs: tests/_envs
|
||||
"""
|
||||
```
|
||||
|
||||
This string is passed as a standard PHP string parameter
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**
|
||||
* @Then i see in file :filename
|
||||
*/
|
||||
public function seeInFile($fileName, $fileContents)
|
||||
{
|
||||
// note: module "Asserts" is enabled in this suite
|
||||
if (!file_exists($fileName)) {
|
||||
$this->fail("File $fileName not found");
|
||||
}
|
||||
$this->assertEquals(file_get_contents($fileName), $fileContents);
|
||||
}
|
||||
```
|
||||
|
||||
### Tags
|
||||
|
||||
Gherkin scenarios and features can contain tags marked with `@`. Tags are equal to groups in Codeception.
|
||||
This way if you define a feature with `@important` tag, you can execute it inside `important` group by running:
|
||||
|
||||
```bash
|
||||
codecept run -g important
|
||||
```
|
||||
|
||||
Tag should be placed before *Scenario:* or before *Feature:* keyword. In the last case all scenarios of that feature will be added to corresponding group.
|
||||
|
||||
## Configuration
|
||||
|
||||
As we mentioned earlier, steps should be defined inside context classes. By default all the steps are defined inside an Actor class, for instance, `AcceptanceTester`. However, you can include more contexts. This can be configured inside global `codeception.yml` or suite configuration file:
|
||||
|
||||
```yaml
|
||||
gherkin:
|
||||
contexts:
|
||||
default:
|
||||
- AcceptanceTester
|
||||
- AdditionalSteps
|
||||
```
|
||||
|
||||
`AdditionalSteps` file should be accessible by autoloader and can be created by `Codeception\Lib\Di`. This means that practically any class can be a context. If a class receives an actor class in constructor or in `_inject` method, DI can inject it into it.
|
||||
|
||||
```php
|
||||
<?php
|
||||
class AdditionalSteps
|
||||
{
|
||||
protected $I;
|
||||
|
||||
function __construct(AcceptanceTester $I)
|
||||
{
|
||||
$this->I = $I;
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I do something
|
||||
*/
|
||||
function additionalActions()
|
||||
{
|
||||
}
|
||||
}
|
||||
```
|
||||
This way PageObjects, Helpers and StepObjects can become contexts as well. But more preferable to include context classes by their tags or roles.
|
||||
|
||||
If you have `Step\Admin` class which defines only admin steps, it is a good idea to use it as context for all features containing with "As an admin". In this case "admin" is a role and we can configure it to use additional context.
|
||||
|
||||
```yaml
|
||||
gherkin:
|
||||
contexts:
|
||||
role:
|
||||
admin:
|
||||
- "Step\Admin"
|
||||
```
|
||||
|
||||
Contexts can be attached to tags as well. This may be useful if you want to redefine steps for some scenarios. Let's say we want to bypass login steps for some scenarios loading already defined session. In this case we can create `Step\FastLogin` class with redefined step "I am logged in as".
|
||||
|
||||
```yaml
|
||||
gherkin:
|
||||
contexts:
|
||||
tag:
|
||||
fastlogin:
|
||||
- "Step\FastLogin"
|
||||
```
|
||||
|
||||
## Migrating From Behat
|
||||
|
||||
While Behat is a great tool for Behavior Driven Development, you still may prefer to use Codeception as your primary testing framework. In case you want to unify all your tests (unit/functional/acceptance), and make them be executed with one runner, Codeception is a good choice. Also Codeception provides rich set of well-maintained modules for various testing backends like Selenium Webdriver, Symfony, Laravel, etc.
|
||||
|
||||
If you decided to run your features with Codeception, we recommend to start with symlinking your `features` directory into one of the test suites:
|
||||
|
||||
```bash
|
||||
ln -s $PWD/features tests/acceptance
|
||||
```
|
||||
|
||||
Then you will need to implement all step definitions. Run `gherkin:snippets` to generate stubs for them.
|
||||
By default it is recommended to place step definitions into actor class (Tester) and use its methods for steps implementation.
|
||||
|
||||
## Tests vs Features
|
||||
|
||||
It is common to think that BDD scenario is equal to test. But it's actually not. Not every test should be described as a feature. Not every test is written to test real business value. For instance, regression tests or negative scenario tests are not bringing any value to business. Business analysts don't care about scenario reproducing bug #13, or what error message is displayed when user tries to enter wrong password on login screen. Writing all the tests inside a feature files creates informational overflow.
|
||||
|
||||
In Codeception you can combine tests written in Gherkin format with tests written in Cept/Cest/Test formats. This way you can keep your feature files compact with minimal set of scenarios, and write regular tests to cover all cases.
|
||||
|
||||
Corresponding features and tests can be attached to the same group. And what is more interesting, you can make tests to depend on feature scenarios. Let's say we have `login.feature` file with "Log regular user" scenario in it. In this case you can specify that every test which requires login to pass to depend on "Log regular user" scenario:
|
||||
|
||||
```
|
||||
@depends login:Log regular user
|
||||
```
|
||||
|
||||
Inside `@depends` block you should use test signature. Execute your feature with `dry-run` to see signatures for all scenarios in it. By marking tests with `@depends` you ensure that this test won't be executed before the test it depends on.
|
||||
|
||||
## Conclusions
|
||||
|
||||
If you like the concept of Behavior Driven Development or prefer to keep test scenarios in human readable format, Codeception allows you to write and execute scenarios in Gherkin. Feature files is just another test format inside Codeception, so it can be combined with Cept and Cest files inside the same suite. Steps definitions of your scenarios can use all the power of Codeception modules, PageObjects, and StepObjects.
|
||||
376
vendor/codeception/base/docs/08-Customization.md
vendored
Normal file
376
vendor/codeception/base/docs/08-Customization.md
vendored
Normal file
@@ -0,0 +1,376 @@
|
||||
# Customization
|
||||
|
||||
In this chapter we will explain how you can extend and customize the file structure and test execution routines.
|
||||
|
||||
## One Runner for Multiple Applications
|
||||
|
||||
If your project consists of several applications (frontend, admin, api) or you are using the Symfony framework
|
||||
with its bundles, you may be interested in having all tests for all applications (bundles) executed in one runner.
|
||||
In this case you will get one report that covers the whole project.
|
||||
|
||||
Place the `codeception.yml` file into the root folder of your project
|
||||
and specify the paths to the other `codeception.yml` configurations that you want to include:
|
||||
|
||||
```yaml
|
||||
include:
|
||||
- frontend/src/*Bundle
|
||||
- admin
|
||||
- api/rest
|
||||
paths:
|
||||
output: _output
|
||||
settings:
|
||||
colors: false
|
||||
```
|
||||
|
||||
You should also specify the path to the `log` directory, where the reports and logs will be saved.
|
||||
|
||||
<div class="alert alert-notice">
|
||||
Wildcards (*) can be used to specify multiple directories at once.
|
||||
</div>
|
||||
|
||||
### Namespaces
|
||||
|
||||
To avoid naming conflicts between Actor classes and Helper classes, they should be separated into namespaces.
|
||||
To create test suites with namespaces you can add `--namespace` option to the bootstrap command:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept bootstrap --namespace frontend
|
||||
```
|
||||
|
||||
This will bootstrap a new project with the `namespace: frontend` parameter in the `codeception.yml` file.
|
||||
Helpers will be in the `frontend\Codeception\Module` namespace and Actor classes will be in the `frontend` namespace.
|
||||
|
||||
Once each of your applications (bundles) has its own namespace and different Helper or Actor classes,
|
||||
you can execute all the tests in a single runner. Run the Codeception tests as usual, using the meta-config we created earlier:
|
||||
|
||||
```bash
|
||||
php vendor/bin/codecept run
|
||||
```
|
||||
|
||||
This will launch the test suites for all three applications and merge the reports from all of them.
|
||||
This is very useful when you run your tests on a Continuous Integration server
|
||||
and you want to get a single report in JUnit and HTML format. The code coverage report will be merged too.
|
||||
|
||||
If you want to run a specific suite from the application you can execute:
|
||||
|
||||
```
|
||||
php vendor/bin/codecept run unit -c frontend
|
||||
```
|
||||
|
||||
Where `unit` is the name of suite and the `-c` option specifies the path to the `codeception.yml` configuration file to use.
|
||||
In this example we will assume that there is `frontend/codeception.yml` configuration file
|
||||
and that we will execute the unit tests for only that app.
|
||||
|
||||
## Extension
|
||||
|
||||
Codeception has limited capabilities to extend its core features.
|
||||
Extensions are not supposed to override current functionality,
|
||||
but can be useful if you are an experienced developer and you want to hook into the testing flow.
|
||||
|
||||
By default, one `RunFailed` Extension is already enabled in your global `codeception.yml`.
|
||||
It allows you to rerun failed tests by using the `-g failed` option:
|
||||
|
||||
```
|
||||
php vendor/bin/codecept run -g failed
|
||||
```
|
||||
|
||||
Codeception comes with bundled extensions located in `ext` directory.
|
||||
For instance, you can enable the Logger extension to log the test execution with Monolog:
|
||||
|
||||
```yaml
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunFailed # default extension
|
||||
- Codeception\Extension\Logger: # enabled extension
|
||||
max_files: 5 # logger configuration
|
||||
```
|
||||
|
||||
But what are extensions, anyway? Basically speaking, extensions are nothing more than event listeners
|
||||
based on the [Symfony Event Dispatcher](http://symfony.com/doc/current/components/event_dispatcher/introduction.html) component.
|
||||
|
||||
### Events
|
||||
|
||||
Here are the events and event classes. The events are listed in the order in which they happen during execution.
|
||||
All listed events are available as constants in `Codeception\Events` class.
|
||||
|
||||
| Event | When? | Triggered by
|
||||
|:--------------------:| --------------------------------------- | --------------------------:
|
||||
| `suite.before` | Before suite is executed | [Suite, Settings](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/SuiteEvent.php)
|
||||
| `test.start` | Before test is executed | [Test](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/TestEvent.php)
|
||||
| `test.before` | At the very beginning of test execution | [Codeception Test](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/TestEvent.php)
|
||||
| `step.before` | Before step | [Step](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/StepEvent.php)
|
||||
| `step.after` | After step | [Step](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/StepEvent.php)
|
||||
| `step.fail` | After failed step | [Step](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/StepEvent.php)
|
||||
| `test.fail` | After failed test | [Test, Fail](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/FailEvent.php)
|
||||
| `test.error` | After test ended with error | [Test, Fail](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/FailEvent.php)
|
||||
| `test.incomplete` | After executing incomplete test | [Test, Fail](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/FailEvent.php)
|
||||
| `test.skipped` | After executing skipped test | [Test, Fail](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/FailEvent.php)
|
||||
| `test.success` | After executing successful test | [Test](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/TestEvent.php)
|
||||
| `test.after` | At the end of test execution | [Codeception Test](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/TestEvent.php)
|
||||
| `test.end` | After test execution | [Test](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/TestEvent.php)
|
||||
| `suite.after` | After suite was executed | [Suite, Result, Settings](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/SuiteEvent.php)
|
||||
| `test.fail.print` | When test fails are printed | [Test, Fail](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/FailEvent.php)
|
||||
| `result.print.after` | After result was printed | [Result, Printer](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Event/PrintResultEvent.php)
|
||||
|
||||
There may be some confusion between `test.start`/`test.before` and `test.after`/`test.end`.
|
||||
The start and end events are triggered by PHPUnit, but the before and after events are triggered by Codeception.
|
||||
Thus, when you are using classical PHPUnit tests (extended from `PHPUnit\Framework\TestCase`),
|
||||
the before/after events won't be triggered for them. During the `test.before` event you can mark a test
|
||||
as skipped or incomplete, which is not possible in `test.start`. You can learn more from
|
||||
[Codeception internal event listeners](https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Subscriber).
|
||||
|
||||
The extension class itself is inherited from `Codeception\Extension`:
|
||||
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Events;
|
||||
|
||||
class MyCustomExtension extends \Codeception\Extension
|
||||
{
|
||||
// list events to listen to
|
||||
// Codeception\Events constants used to set the event
|
||||
|
||||
public static $events = array(
|
||||
Events::SUITE_AFTER => 'afterSuite',
|
||||
Events::SUITE_BEFORE => 'beforeTest',
|
||||
Events::STEP_BEFORE => 'beforeStep',
|
||||
Events::TEST_FAIL => 'testFailed',
|
||||
Events::RESULT_PRINT_AFTER => 'print',
|
||||
);
|
||||
|
||||
// methods that handle events
|
||||
|
||||
public function afterSuite(\Codeception\Event\SuiteEvent $e) {}
|
||||
|
||||
public function beforeTest(\Codeception\Event\TestEvent $e) {}
|
||||
|
||||
public function beforeStep(\Codeception\Event\StepEvent $e) {}
|
||||
|
||||
public function testFailed(\Codeception\Event\FailEvent $e) {}
|
||||
|
||||
public function print(\Codeception\Event\PrintResultEvent $e) {}
|
||||
}
|
||||
```
|
||||
|
||||
By implementing event handling methods you can listen for events and even update passed objects.
|
||||
Extensions have some basic methods you can use:
|
||||
|
||||
* `write` - prints to the screen
|
||||
* `writeln` - prints to the screen with a new-line character at the end
|
||||
* `getModule` - allows you to access a module
|
||||
* `hasModule` - checks if a module is enabled
|
||||
* `getModuleNames` - list all enabled modules
|
||||
* `_reconfigure` - can be implemented instead of overriding the constructor
|
||||
|
||||
### Enabling Extension
|
||||
|
||||
Once you've implemented a simple extension class, you can require it in `tests/_bootstrap.php`,
|
||||
load it with Composer's autoloader defined in `composer.json`, or store the class inside `tests/_support`dir.
|
||||
|
||||
You can then enable it in `codeception.yml`
|
||||
|
||||
```yaml
|
||||
extensions:
|
||||
enabled: [MyCustomExtension]
|
||||
```
|
||||
|
||||
Extensions can also be enabled per suite inside suite configs (like `acceptance.suite.yml`) and for a specific environment.
|
||||
|
||||
To enable extension dynamically, execute the `run` command with `--ext` option.
|
||||
Provide a class name as a parameter:
|
||||
|
||||
```bash
|
||||
codecept run --ext MyCustomExtension
|
||||
codecept run --ext "\My\Extension"
|
||||
```
|
||||
|
||||
If a class is in a `Codeception\Extension` namespace you can skip it and provide only a shortname.
|
||||
So Recorder extension can be started like this:
|
||||
|
||||
```bash
|
||||
codecept run --ext Recorder
|
||||
```
|
||||
|
||||
### Configuring Extension
|
||||
|
||||
In the extension, you can access the currently passed options via the `options` property.
|
||||
You also can access the global configuration via the `\Codeception\Configuration::config()` method.
|
||||
If you want to have custom options for your extension, you can pass them in the `codeception.yml` file:
|
||||
|
||||
```yaml
|
||||
extensions:
|
||||
enabled: [MyCustomExtension]
|
||||
config:
|
||||
MyCustomExtension:
|
||||
param: value
|
||||
```
|
||||
|
||||
The passed in configuration is accessible via the `config` property: `$this->config['param']`.
|
||||
|
||||
Check out a very basic extension [Notifier](https://github.com/Codeception/Notifier).
|
||||
|
||||
### Custom Commands
|
||||
|
||||
You can add your own commands to Codeception.
|
||||
|
||||
Your custom commands have to implement the interface Codeception\CustomCommandInterface,
|
||||
because there has to be a function to get the name of the command.
|
||||
|
||||
You have to register your command in the file `codeception.yml`:
|
||||
|
||||
```yaml
|
||||
extensions:
|
||||
commands: [Project\Command\MyCustomCommand]
|
||||
```
|
||||
|
||||
If you want to activate the Command globally, because you are using more then one `codeception.yml` file,
|
||||
you have to register your command in the `codeception.dist.yml` in the root folder of your project.
|
||||
|
||||
Please see the [complete example](https://github.com/Codeception/Codeception/blob/2.3/tests/data/register_command/examples/MyCustomCommand.php)
|
||||
|
||||
## Group Objects
|
||||
|
||||
Group Objects are extensions listening for the events of tests belonging to a specific group.
|
||||
When a test is added to a group:
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**
|
||||
* @group admin
|
||||
*/
|
||||
public function testAdminCreatingNewBlogPost(\AcceptanceTester $I)
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
This test will trigger the following events:
|
||||
|
||||
* `test.before.admin`
|
||||
* `step.before.admin`
|
||||
* `step.after.admin`
|
||||
* `test.success.admin`
|
||||
* `test.fail.admin`
|
||||
* `test.after.admin`
|
||||
|
||||
A group object is built to listen for these events. It is useful when an additional setup is required
|
||||
for some of your tests. Let's say you want to load fixtures for tests that belong to the `admin` group:
|
||||
```php
|
||||
<?php
|
||||
namespace Group;
|
||||
|
||||
class Admin extends \Codeception\GroupObject
|
||||
{
|
||||
public static $group = 'admin';
|
||||
|
||||
public function _before(\Codeception\Event\TestEvent $e)
|
||||
{
|
||||
$this->writeln('inserting additional admin users...');
|
||||
|
||||
$db = $this->getModule('Db');
|
||||
$db->haveInDatabase('users', array('name' => 'bill', 'role' => 'admin'));
|
||||
$db->haveInDatabase('users', array('name' => 'john', 'role' => 'admin'));
|
||||
$db->haveInDatabase('users', array('name' => 'mark', 'role' => 'banned'));
|
||||
}
|
||||
|
||||
public function _after(\Codeception\Event\TestEvent $e)
|
||||
{
|
||||
$this->writeln('cleaning up admin users...');
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
GroupObjects can also be used to update the module configuration before running a test.
|
||||
For instance, for `nocleanup` group we prevent Doctrine2 module from wrapping test into transaction:
|
||||
|
||||
```php
|
||||
<?php
|
||||
public static $group = 'nocleanup';
|
||||
|
||||
public function _before(\Codeception\Event\TestEvent $e)
|
||||
{
|
||||
$this->getModule('Doctrine2')->_reconfigure(['cleanup' => false]);
|
||||
}
|
||||
```
|
||||
|
||||
A group class can be created with `php vendor/bin/codecept generate:group groupname` command.
|
||||
Group classes will be stored in the `tests/_support/Group` directory.
|
||||
|
||||
A group class can be enabled just like you enable an extension class. In the file `codeception.yml`:
|
||||
|
||||
``` yaml
|
||||
extensions:
|
||||
enabled: [Group\Admin]
|
||||
```
|
||||
|
||||
Now the Admin group class will listen for all events of tests that belong to the `admin` group.
|
||||
|
||||
## Custom Reporters
|
||||
|
||||
Alternative reporters can be implemented as extension.
|
||||
There are [DotReporter](http://codeception.com/extensions#DotReporter) and [SimpleReporter](http://codeception.com/extensions#SimpleReporter) extensions included.
|
||||
Use them to change output or use them as an example to build your own reporter. They can be easily enabled with `--ext` option
|
||||
|
||||
```bash
|
||||
codecept run --ext DotReporter
|
||||
```
|
||||
|
||||

|
||||
|
||||
If you want to use it as default reporter enable it in `codeception.yml`.
|
||||
|
||||
But what if you need to change the output format of the XML or JSON results triggered with the `--xml` or `--json` options?
|
||||
Codeception uses PHPUnit printers and overrides them. If you need to customize one of the standard reporters you can override them too.
|
||||
If you are thinking on implementing your own reporter you should add a `reporters` section to `codeception.yml`
|
||||
and override one of the standard printer classes with one of your own:
|
||||
|
||||
```yaml
|
||||
reporters:
|
||||
xml: Codeception\PHPUnit\Log\JUnit
|
||||
html: Codeception\PHPUnit\ResultPrinter\HTML
|
||||
report: Codeception\PHPUnit\ResultPrinter\Report
|
||||
```
|
||||
|
||||
All PHPUnit printers implement the
|
||||
[PHPUnit_Framework_TestListener](https://phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener)
|
||||
interface. It is recommended to read the code of the original reporter before overriding it.
|
||||
|
||||
## Installation Templates
|
||||
|
||||
Codeception setup can be customized for the needs of your application.
|
||||
If you build a distributable application and you have a personalized configuration you can build an
|
||||
Installation template which will help your users to start testing on their projects.
|
||||
|
||||
Codeception has built-in installation templates for
|
||||
|
||||
* [Acceptance tests](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Template/Acceptance.php)
|
||||
* [Unit tests](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Template/Unit.php)
|
||||
* [REST API tests](https://github.com/Codeception/Codeception/blob/2.3/src/Codeception/Template/Api.php)
|
||||
|
||||
They can be executed with `init` command:
|
||||
|
||||
```bash
|
||||
codecept init Acceptance
|
||||
```
|
||||
To init tests in specific folder use `--path` option:
|
||||
|
||||
```bash
|
||||
codecept init Acceptance --path acceptance_tests
|
||||
```
|
||||
|
||||
You will be asked several questions and then config files will be generated and all necessary directories will be created.
|
||||
Learn from the examples above to build a custom Installation Template. Here are the basic rules you should follow:
|
||||
|
||||
* Templates should be inherited from [`Codeception\InitTemplate`](http://codeception.com/docs/reference/InitTemplate) class and implement `setup` method.
|
||||
* Template class should be placed in `Codeception\Template` namespace so Codeception could locate them by class name
|
||||
* Use methods like `say`, `saySuccess`, `sayWarning`, `sayError`, `ask`, to interact with a user.
|
||||
* Use `createDirectoryFor`, `createEmptyDirectory` methods to create directories
|
||||
* Use `createHelper`, `createActor` methods to create helpers and actors.
|
||||
* Use [Codeception generators](https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Lib/Generator) to create other support classes.
|
||||
|
||||
## Conclusion
|
||||
|
||||
Each feature mentioned above may help dramatically when using Codeception to automate the testing of large projects,
|
||||
although some features may require advanced knowledge of PHP. There is no "best practice" or "use cases"
|
||||
when we talk about groups, extensions, or other powerful features of Codeception.
|
||||
If you see you have a problem that can be solved using these extensions, then give them a try.
|
||||
279
vendor/codeception/base/docs/09-Data.md
vendored
Normal file
279
vendor/codeception/base/docs/09-Data.md
vendored
Normal file
@@ -0,0 +1,279 @@
|
||||
# Working with Data
|
||||
|
||||
Tests should not affect each other. That's a rule of thumb. When tests interact with a database,
|
||||
they may change the data inside it, which would eventually lead to data inconsistency.
|
||||
A test may try to insert a record that has already been inserted, or retrieve a deleted record.
|
||||
To avoid test failures, the database should be brought back to its initial state before each test.
|
||||
Codeception has different methods and approaches to get your data cleaned.
|
||||
|
||||
This chapter summarizes all of the notices on clean-ups from the previous chapters
|
||||
and suggests the best strategies of how to choose data storage backends.
|
||||
|
||||
When we decide to clean up a database, we should make this cleaning as fast as possible. Tests should always run fast.
|
||||
Rebuilding the database from scratch is not the best way, but might be the only one. In any case,
|
||||
you should use a special test database for testing. **Do not ever run tests on development or production databases!**
|
||||
|
||||
## Db
|
||||
|
||||
Codeception has a `Db` module, which takes on most of the tasks of database interaction.
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: 'PDO DSN HERE'
|
||||
user: 'root'
|
||||
password:
|
||||
```
|
||||
|
||||
<div class="alert alert-notice">
|
||||
Use <a href="http://codeception.com/docs/06-ModulesAndHelpers#Dynamic-Configuration-With-Params">module parameters</a>
|
||||
to set the database credentials from environment variables or from application configuration files.
|
||||
</div>
|
||||
|
||||
Db module can cleanup database between tests by loading a database dump. This can be done by parsing SQL file and
|
||||
executing its commands using current connection
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: 'PDO DSN HERE'
|
||||
user: 'root'
|
||||
password:
|
||||
dump: tests/_data/your-dump-name.sql
|
||||
cleanup: true # reload dump between tests
|
||||
populate: true # load dump before all tests
|
||||
|
||||
```
|
||||
|
||||
Alternatively an external tool (like mysql client, or pg_restore) can be used. This approach is faster and won't produce parsing errors while loading a dump.
|
||||
Use `populator` config option to specify the command. For MySQL it can look like this:
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- Db:
|
||||
dsn: 'mysql:host=localhost;dbname=testdb'
|
||||
user: 'root'
|
||||
password: ''
|
||||
cleanup: true # run populator before each test
|
||||
populate: true # run populator before all test
|
||||
populator: 'mysql -u $user $dbname < tests/_data/dump.sql'
|
||||
```
|
||||
|
||||
See the [Db module reference](http://codeception.com/docs/modules/Db#SQL-data-dump) for more examples.
|
||||
|
||||
To ensure database dump is loaded before all tests add `populate: true`. To clean current database and reload dump between tests use `cleanup: true`.
|
||||
|
||||
<div class="alert alert-notice">
|
||||
A full database clean-up can be painfully slow if you use large database dumps. It is recommended to do more data testing
|
||||
on the functional and integration levels, this way you can get performance bonuses from using ORM.
|
||||
</div>
|
||||
|
||||
In acceptance tests, your tests are interacting with the application through a web server. This means that the test
|
||||
and the application work with the same database. You should provide the same credentials in the Db module
|
||||
that your application uses, then you can access the database for assertions (`seeInDatabase` actions)
|
||||
and to perform automatic clean-ups.
|
||||
|
||||
The Db module provides actions to create and verify data inside a database.
|
||||
|
||||
If you want to create a special database record for one test,
|
||||
you can use [`haveInDatabase`](http://codeception.com/docs/modules/Db#haveInDatabase) method of `Db` module:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->haveInDatabase('posts', [
|
||||
'title' => 'Top 10 Testing Frameworks',
|
||||
'body' => '1. Codeception'
|
||||
]);
|
||||
$I->amOnPage('/posts');
|
||||
$I->see('Top 10 Testing Frameworks');
|
||||
|
||||
```
|
||||
|
||||
`haveInDatabase` inserts a row with the provided values into the database.
|
||||
All added records will be deleted at the end of the test.
|
||||
|
||||
If you want to check that a table record was created
|
||||
use [`seeInDatabase`](http://codeception.com/docs/modules/Db#haveInDatabase) method:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->amOnPage('/posts/1');
|
||||
$I->fillField('comment', 'This is nice!');
|
||||
$I->click('Submit');
|
||||
$I->seeInDatabase('comments', ['body' => 'This is nice!']);
|
||||
```
|
||||
|
||||
See the module [reference](http://codeception.com/docs/modules/Db) for other methods you can use for database testing.
|
||||
|
||||
There are also modules for [MongoDb](http://codeception.com/docs/modules/MongoDb),
|
||||
[Redis](http://codeception.com/docs/modules/Redis),
|
||||
and [Memcache](http://codeception.com/docs/modules/Memcache) which behave in a similar manner.
|
||||
|
||||
### Sequence
|
||||
|
||||
If the database clean-up takes too long, you can follow a different strategy: create new data for each test.
|
||||
This way, the only problem you might face is duplication of data records.
|
||||
[Sequence](http://codeception.com/docs/modules/Sequence) was created to solve this.
|
||||
It provides the `sq()` function which generates unique suffixes for creating data in tests.
|
||||
|
||||
## ORM modules
|
||||
|
||||
Your application is most likely using object-relational mapping (ORM) to work with the database. In this case,
|
||||
Codeception allows you to use the ORM methods to work with the database, instead of accessing the database directly.
|
||||
This way you can work with models and entities of a domain, and not on tables and rows.
|
||||
|
||||
By using ORM in functional and integration tests, you can also improve performance of your tests.
|
||||
Instead of cleaning up the database after each test, the ORM module will wrap all the database actions into transactions
|
||||
and roll it back at the end. This way, no actual data will be written to the database.
|
||||
This clean-up strategy is enabled by default,
|
||||
you can disable it by setting `cleanup: false` in the configuration of any ORM module.
|
||||
|
||||
### ActiveRecord
|
||||
|
||||
Popular frameworks like Laravel, Yii, and Phalcon include an ActiveRecord data layer by default.
|
||||
Because of this tight integration, you just need to enable the framework module, and use its configuration for database access.
|
||||
|
||||
Corresponding framework modules provide similar methods for ORM access:
|
||||
|
||||
* `haveRecord`
|
||||
* `seeRecord`
|
||||
* `dontSeeRecord`
|
||||
* `grabRecord`
|
||||
|
||||
They allow you to create and check data by model name and field names in the model. Here is the example in Laravel:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// create record and get its id
|
||||
$id = $I->haveRecord('posts', ['body' => 'My first blogpost', 'user_id' => 1]);
|
||||
$I->amOnPage('/posts/'.$id);
|
||||
$I->see('My first blogpost', 'article');
|
||||
// check record exists
|
||||
$I->seeRecord('posts', ['id' => $id]);
|
||||
$I->click('Delete');
|
||||
// record was deleted
|
||||
$I->dontSeeRecord('posts', ['id' => $id]);
|
||||
```
|
||||
|
||||
<div class="alert alert-notice">
|
||||
Laravel5 module also provides `haveModel`, `makeModel` methods which use factories to generate models with fake data.
|
||||
</div>
|
||||
|
||||
If you want to use ORM for integration testing only, you should enable the framework module with only the `ORM` part enabled:
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- Laravel5:
|
||||
- part: ORM
|
||||
```
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- Yii2:
|
||||
- part: ORM
|
||||
```
|
||||
|
||||
This way no web actions will be added to `$I` object.
|
||||
|
||||
If you want to use ORM to work with data inside acceptance tests, you should also include only the ORM part of a module.
|
||||
Please note that inside acceptance tests, web applications work inside a webserver, so any test data can't be cleaned up
|
||||
by rolling back transactions. You will need to disable cleaning up,
|
||||
and use the `Db` module to clean the database up between tests. Here is a sample config:
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- WebDriver:
|
||||
url: http://localhost
|
||||
browser: firefox
|
||||
- Laravel5:
|
||||
cleanup: false
|
||||
- Db
|
||||
```
|
||||
|
||||
### DataMapper
|
||||
|
||||
Doctrine is also a popular ORM, unlike some others it implements the DataMapper pattern and is not bound to any framework.
|
||||
The [Doctrine2](http://codeception.com/docs/modules/Doctrine2) module requires an `EntityManager` instance to work with.
|
||||
It can be obtained from a Symfony framework or Zend Framework (configured with Doctrine):
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- Symfony
|
||||
- Doctrine2:
|
||||
depends: Symfony
|
||||
```
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- ZF2
|
||||
- Doctrine2:
|
||||
depends: ZF2
|
||||
```
|
||||
|
||||
If no framework is used with Doctrine you should provide the `connection_callback` option
|
||||
with a valid callback to a function which returns an `EntityManager` instance.
|
||||
|
||||
Doctrine2 also provides methods to create and check data:
|
||||
|
||||
* `haveInRepository`
|
||||
* `grabFromRepository`
|
||||
* `grabEntitiesFromRepository`
|
||||
* `seeInRepository`
|
||||
* `dontSeeInRepository`
|
||||
|
||||
### DataFactory
|
||||
|
||||
Preparing data for testing is a very creative, although boring, task. If you create a record,
|
||||
you need to fill in all the fields of the model. It is much easier to use [Faker](https://github.com/fzaninotto/Faker)
|
||||
for this task, which is more effective to set up data generation rules for models.
|
||||
Such a set of rules is called *factories*
|
||||
and are provided by the [DataFactory](http://codeception.com/docs/modules/DataFactory) module.
|
||||
|
||||
Once configured, it can create records with ease:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// creates a new user
|
||||
$user_id = $I->have('App\Model\User');
|
||||
// creates 3 posts
|
||||
$I->haveMultiple('App\Model\Post', 3);
|
||||
```
|
||||
|
||||
Created records will be deleted at the end of a test.
|
||||
The DataFactory module only works with ORM, so it requires one of the ORM modules to be enabled:
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- Yii2:
|
||||
configFile: path/to/config.php
|
||||
- DataFactory:
|
||||
depends: Yii2
|
||||
```
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- Symfony
|
||||
- Doctrine2:
|
||||
depends: Symfony
|
||||
- DataFactory:
|
||||
depends: Doctrine2
|
||||
```
|
||||
|
||||
DataFactory provides a powerful solution for managing data in integration/functional/acceptance tests.
|
||||
Read the [full reference](http://codeception.com/docs/modules/DataFactory) to learn how to set this module up.
|
||||
|
||||
## Conclusion
|
||||
|
||||
Codeception also assists the developer when dealing with data. Tools for database population
|
||||
and cleaning up are bundled within the `Db` module. If you use ORM, you can use one of the provided framework modules
|
||||
to operate with database through a data abstraction layer, and use the DataFactory module to generate new records with ease.
|
||||
287
vendor/codeception/base/docs/10-WebServices.md
vendored
Normal file
287
vendor/codeception/base/docs/10-WebServices.md
vendored
Normal file
@@ -0,0 +1,287 @@
|
||||
# Testing WebServices
|
||||
|
||||
The same way we tested a web site, Codeception allows you to test web services. They are very hard to test manually, so it's a really good idea to automate web service testing. We have SOAP and REST as standards, which are represented in corresponding modules, which we will cover in this chapter.
|
||||
|
||||
You should start by creating a new test suite, (which was not provided by the `bootstrap` command). We recommend calling it **api** and using the `ApiTester` class for it.
|
||||
|
||||
```bash
|
||||
$ php vendor/bin/codecept generate:suite api
|
||||
```
|
||||
|
||||
We will put all the api tests there.
|
||||
|
||||
## REST
|
||||
|
||||
The REST web service is accessed via HTTP with standard methods: `GET`, `POST`, `PUT`, `DELETE`. They allow users to receive and manipulate entities from the service. Accessing a WebService requires an HTTP client, so for using it you need the module `PhpBrowser` or one of framework modules set up. For example, we can use the `Symfony` module for Symfony2 applications in order to ignore web server and test web service internally.
|
||||
|
||||
Configure modules in `api.suite.yml`:
|
||||
|
||||
``` yaml
|
||||
actor: ApiTester
|
||||
modules:
|
||||
enabled:
|
||||
- REST:
|
||||
url: http://serviceapp/api/v1/
|
||||
depends: PhpBrowser
|
||||
```
|
||||
|
||||
The REST module will connect to `PhpBrowser` according to this configuration. Depending on the web service we may deal with XML or JSON responses. Codeception handles both data formats well, however If you don't need one of them, you can explicitly specify that the JSON or XML parts of the module will be used:
|
||||
|
||||
``` yaml
|
||||
actor: ApiTester
|
||||
modules:
|
||||
enabled:
|
||||
- REST:
|
||||
url: http://serviceapp/api/v1/
|
||||
depends: PhpBrowser
|
||||
part: Json
|
||||
```
|
||||
|
||||
API tests can be functional and be executed using Symfony, Laravel5, Zend, or any other framework module. You will need slightly update configuration for it:
|
||||
|
||||
``` yaml
|
||||
actor: ApiTester
|
||||
modules:
|
||||
enabled:
|
||||
- REST:
|
||||
url: /api/v1/
|
||||
depends: Laravel5
|
||||
```
|
||||
|
||||
Once we have configured our new testing suite, we can create the first sample test:
|
||||
|
||||
```bash
|
||||
$ codecept generate:cest api CreateUser
|
||||
```
|
||||
|
||||
It will be called `CreateUserCest.php`.
|
||||
We need to implement a public method for each test. Let's make `createUserViaAPI` to test creation of a user via the REST API.
|
||||
|
||||
```php
|
||||
<?php
|
||||
class CreateUserCest
|
||||
{
|
||||
public function _before(\ApiTester $I)
|
||||
{
|
||||
}
|
||||
|
||||
public function _after(\ApiTester $I)
|
||||
{
|
||||
}
|
||||
|
||||
// tests
|
||||
public function createUserViaAPI(\ApiTester $I)
|
||||
{
|
||||
$I->amHttpAuthenticated('service_user', '123456');
|
||||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
$I->sendPOST('/users', ['name' => 'davert', 'email' => 'davert@codeception.com']);
|
||||
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); // 200
|
||||
$I->seeResponseIsJson();
|
||||
$I->seeResponseContains('{"result":"ok"}');
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We can use HTTP code constants from `Codeception\Util\HttpCode` instead of numeric values to check response code in `seeResponseCodeIs` and `dontSeeResponseCodeIs` methods.
|
||||
|
||||
### Testing JSON Responses
|
||||
|
||||
The last line of the previous example verified that the response contained the provided string. However we shouldn't rely on it, as depending on content formatting we can receive different results with the same data. What we actually need is to check that the response can be parsed and it contains some of the values we expect. In the case of JSON we can use the `seeResponseContainsJson` method
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// matches {"result":"ok"}'
|
||||
$I->seeResponseContainsJson(['result' => 'ok']);
|
||||
// it can match tree-like structures as well
|
||||
$I->seeResponseContainsJson([
|
||||
'user' => [
|
||||
'name' => 'davert',
|
||||
'email' => 'davert@codeception.com',
|
||||
'status' => 'inactive'
|
||||
]
|
||||
]);
|
||||
|
||||
```
|
||||
|
||||
You may want to perform even more complex assertions on a response. This can be done by writing your own methods in the [Helper](http://codeception.com/docs/06-ReusingTestCode#Modules-and-Helpers) classes. To access the latest JSON response you will need to get the `response` property of the `REST` module. Let's demonstrate it with the `seeResponseIsHtml` method:
|
||||
|
||||
```php
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
class Api extends \Codeception\Module
|
||||
{
|
||||
public function seeResponseIsHtml()
|
||||
{
|
||||
$response = $this->getModule('REST')->response;
|
||||
$this->assertRegExp('~^<!DOCTYPE HTML(.*?)<html>.*?<\/html>~m', $response);
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
The same way you can receive request parameters and headers.
|
||||
|
||||
### Validate JSON structures
|
||||
|
||||
It is pretty common for API tests to not only validate the received data but to check the structure of the response. Response data is not usually considered to be consistent, and may change on each request, however the JSON/XML structure should be kept the same for an API version. In order to check response structure the REST module has some useful methods.
|
||||
|
||||
If we expect a JSON response to be received we can check its structure with [JSONPath](http://goessner.net/articles/JsonPath/). It looks and sounds like XPath but is designed to work with JSON data, however we can convert JSON into XML and use XPath to validate the structure. Both approaches are valid and can be used in the REST module:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->sendGET('/users');
|
||||
$I->seeResponseCodeIs(HttpCode::OK); // 200
|
||||
$I->seeResponseIsJson();
|
||||
$I->seeResponseJsonMatchesJsonPath('$[0].user.login');
|
||||
$I->seeResponseJsonMatchesXpath('//user/login');
|
||||
```
|
||||
|
||||
More detailed check can be applied if you need to validate the type of fields in a response.
|
||||
You can do that by using with a [seeResponseMatchesJsonType](http://codeception.com/docs/modules/REST#seeResponseMatchesJsonType) action in which you define the structure of JSON response.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->sendGET('/users/1');
|
||||
$I->seeResponseCodeIs(HttpCode::OK); // 200
|
||||
$I->seeResponseIsJson();
|
||||
$I->seeResponseMatchesJsonType([
|
||||
'id' => 'integer',
|
||||
'name' => 'string',
|
||||
'email' => 'string:email',
|
||||
'homepage' => 'string:url|null',
|
||||
'created_at' => 'string:date',
|
||||
'is_active' => 'boolean'
|
||||
]);
|
||||
|
||||
```
|
||||
|
||||
Codeception uses this simple and lightweight definitions format which can be [easily learned and extended](http://codeception.com/docs/modules/REST#seeResponseMatchesJsonType).
|
||||
|
||||
### Testing XML Responses
|
||||
|
||||
In case your REST API works with XML format you can use similar methods to test its data and structure.
|
||||
There is `seeXmlResponseIncludes` method to match inclusion of XML parts in response, and `seeXmlResponseMatchesXpath` to validate its structure.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->sendGET('/users.xml');
|
||||
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); // 200
|
||||
$I->seeResponseIsXml();
|
||||
$I->seeXmlResponseMatchesXpath('//user/login');
|
||||
$I->seeXmlResponseIncludes(\Codeception\Util\Xml::toXml([
|
||||
'user' => [
|
||||
'name' => 'davert',
|
||||
'email' => 'davert@codeception.com',
|
||||
'status' => 'inactive'
|
||||
]
|
||||
]));
|
||||
|
||||
```
|
||||
|
||||
We are using `Codeception\Util\Xml` class which allows us to build XML structures in a clean manner. The `toXml` method may accept a string or array and returns \DOMDocument instance. If your XML contains attributes and so can't be represented as a PHP array you can create XML using the [XmlBuilder](http://codeception.com/docs/reference/XmlBuilder) class. We will take a look at it a bit more in next section.
|
||||
|
||||
<div class="alert alert-info">
|
||||
Use `\Codeception\Util\Xml::build()` to create XmlBuilder instance.
|
||||
</div>
|
||||
|
||||
## SOAP
|
||||
|
||||
SOAP web services are usually more complex. You will need PHP [configured with SOAP support](http://php.net/manual/en/soap.installation.php). Good knowledge of XML is required too. `SOAP` module uses specially formatted POST request to connect to WSDL web services. Codeception uses `PhpBrowser` or one of framework modules to perform interactions. If you choose using a framework module, SOAP will automatically connect to the underlying framework. That may improve the speed of a test execution and will provide you with more detailed stack traces.
|
||||
|
||||
Let's configure `SOAP` module to be used with `PhpBrowser`:
|
||||
|
||||
``` yaml
|
||||
actor: ApiTester
|
||||
modules:
|
||||
enabled:
|
||||
- SOAP:
|
||||
depends: PhpBrowser
|
||||
endpoint: http://serviceapp/api/v1/
|
||||
```
|
||||
|
||||
SOAP request may contain application specific information, like authentication or payment. This information is provided with SOAP header inside the `<soap:Header>` element of XML request. In case you need to submit such header, you can use `haveSoapHeader` action. For example, next line of code
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->haveSoapHeader('Auth', array('username' => 'Miles', 'password' => '123456'));
|
||||
|
||||
```
|
||||
will produce this XML header
|
||||
|
||||
```xml
|
||||
<soap:Header>
|
||||
<Auth>
|
||||
<username>Miles</username>
|
||||
<password>123456</password>
|
||||
</Auth>
|
||||
</soap:Header>
|
||||
```
|
||||
|
||||
Use `sendSoapRequest` method to define the body of your request.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->sendSoapRequest('CreateUser', '<name>Miles Davis</name><email>miles@davis.com</email>');
|
||||
|
||||
```
|
||||
|
||||
This call will be translated to XML:
|
||||
|
||||
```xml
|
||||
<soap:Body>
|
||||
<ns:CreateUser>
|
||||
<name>Miles Davis</name>
|
||||
<email>miles@davis.com</email>
|
||||
</ns:CreateUser>
|
||||
</soap:Body>
|
||||
```
|
||||
|
||||
And here is the list of sample assertions that can be used with SOAP.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeSoapResponseEquals('<?xml version="1.0"<error>500</error>');
|
||||
$I->seeSoapResponseIncludes('<result>1</result>');
|
||||
$I->seeSoapResponseContainsStructure('<user><name></name><email></email>');
|
||||
$I->seeSoapResponseContainsXPath('//result/user/name[@id=1]');
|
||||
|
||||
```
|
||||
|
||||
In case you don't want to write long XML strings, consider using [XmlBuilder](http://codeception.com/docs/reference/XmlBuilder) class. It will help you to build complex XMLs in jQuery-like style.
|
||||
In the next example we will use `XmlBuilder` instead of regular XML.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->haveSoapHeader('Session', array('token' => '123456'));
|
||||
$I->sendSoapRequest('CreateUser', Xml::build()
|
||||
->user->email->val('miles@davis.com'));
|
||||
$I->seeSoapResponseIncludes(\Codeception\Util\Xml::build()
|
||||
->result->val('Ok')
|
||||
->user->attr('id', 1)
|
||||
);
|
||||
|
||||
```
|
||||
|
||||
It's up to you to decide whether to use `XmlBuilder` or plain XML. `XmlBuilder` will return XML string as well.
|
||||
|
||||
You may extend current functionality by using `SOAP` module in your helper class. To access the SOAP response as `\DOMDocument` you can use `response` property of `SOAP` module.
|
||||
|
||||
```php
|
||||
<?php
|
||||
namespace Helper;
|
||||
class Api extends \Codeception\Module {
|
||||
|
||||
public function seeResponseIsValidOnSchema($schema)
|
||||
{
|
||||
$response = $this->getModule('SOAP')->response;
|
||||
$this->assertTrue($response->schemaValidate($schema));
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Conclusion
|
||||
|
||||
Codeception has two modules that will help you to test various web services. They need a new `api` suite to be created. Remember, you are not limited to test only response body. By including `Db` module you may check if a user has been created after the `CreateUser` call. You can improve testing scenarios by using REST or SOAP responses in your helper methods.
|
||||
133
vendor/codeception/base/docs/11-Codecoverage.md
vendored
Normal file
133
vendor/codeception/base/docs/11-Codecoverage.md
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
# Code Coverage
|
||||
|
||||
At some point you want to review which parts of your application are tested well and which are not.
|
||||
Just for this case the [CodeCoverage](http://en.wikipedia.org/wiki/Code_coverage) is used. When you execute your tests to collect coverage report,
|
||||
you will receive statistics of all classes, methods, and lines triggered by these tests.
|
||||
The ratio between all lines in script and all touched lines is a main coverage criterion. In the ideal world you should get 100% code coverage, but in reality 80% is really enough. Because even 100% code coverage rate doesn't save you from fatal errors and crashes.
|
||||
|
||||
*To collect coverage information `xdebug` is required**.
|
||||
|
||||

|
||||
|
||||
Coverage data can be collected manually for both local and remote tests. Remote tests may be executed on different nodes,
|
||||
or locally but running through web server. It may look hard to collect code coverage for Selenium tests or PhpBrowser tests. But Codeception supports remote codecoverage as well as local.
|
||||
|
||||
### Configuration
|
||||
|
||||
To enable code coverage put these lines in the global configuration file `codeception.yml`:
|
||||
|
||||
``` yaml
|
||||
coverage:
|
||||
enabled: true
|
||||
```
|
||||
|
||||
That's ok for now. But what files should be present in final coverage report?
|
||||
Pass an array of files or directory to include/exclude sections. The path ending with '\*' matches the directory.
|
||||
Also you can use '\*' mask in a file name, i.e. `app/models/*Model.php` to match all models.
|
||||
|
||||
There is a shortcut if you don't need that complex filters:
|
||||
|
||||
``` yaml
|
||||
coverage:
|
||||
enabled: true
|
||||
include:
|
||||
- app/*
|
||||
exclude:
|
||||
- app/cache/*
|
||||
```
|
||||
Include and exclude options can be redefined for each suite in corresponding config files.
|
||||
|
||||
By default, if coverage is reported to be < 35% it is marked as low, and >70% is high coverage.
|
||||
You can also define high and low boundaries with `low_limit` and `high_limit` config options:
|
||||
|
||||
```yaml
|
||||
coverage:
|
||||
enabled: true
|
||||
low_limit: 30
|
||||
high_limit: 60
|
||||
```
|
||||
|
||||
## Local CodeCoverage
|
||||
|
||||
The basic codecoverage can be collected for functional and unit tests.
|
||||
If you performed configuration steps from above, you are ready to go.
|
||||
All you need is to execute codeception with `--coverage` option.
|
||||
|
||||
To generate a clover xml report or a tasty html report append also `--coverage-xml` and `--coverage-html` options.
|
||||
|
||||
``` yaml
|
||||
codecept run --coverage --coverage-xml --coverage-html
|
||||
```
|
||||
|
||||
XML and HTML reports are stored to the `_output` directory. The best way to review report is to open `index.html` from `tests/_output/coverage` in your browser.
|
||||
XML clover reports are used by IDEs (like PHPStorm) or Continuous Integration servers (like Jenkins).
|
||||
|
||||
## Remote CodeCoverage
|
||||
|
||||
### Local Server
|
||||
|
||||
If you run your application via Webserver (Apache, Nginx, PHP WebServer) you don't have a direct access to tested code,
|
||||
so collecting coverage becomes a non-trivial task. The same goes for scripts that are tested on different nodes.
|
||||
To get access to this code you need `xdebug` installed with `remote_enable` option turned on.
|
||||
Codeception also requires a little spy to interact with your application. As your application runs standalone,
|
||||
without even knowing it is being tested, a small file should be included in order to collect coverage info.
|
||||
|
||||
This file is called `c3.php` and is [available on GitHub](https://github.com/Codeception/c3).
|
||||
`c3.php` should be downloaded and included in your application at the very first line from controller.
|
||||
By sending special headers Codeception will command your application when to start codecoverage collection and when to stop it.
|
||||
After the suite is finished, a report will be stored and Codeception will grab it from your application.
|
||||
|
||||
Please, follow installation instructions described in a [readme file](https://github.com/Codeception/c3).
|
||||
|
||||
To connect to `c3` Codeception uses url config from PhpBrowser or WebDriver module.
|
||||
But URL of index with `c3.php` included can be specified explicitly with `c3_url` parameter defined:
|
||||
|
||||
``` yaml
|
||||
coverage:
|
||||
# url of file which includes c3 router.
|
||||
c3_url: 'http://127.0.0.1:8000/index-test.php/'
|
||||
```
|
||||
> note: we can't have multiple `c3_url` on same host difference only by port. Please, use alias of domain
|
||||
(i.e. `frontend.dev:8000`,`backend.dev:8080`) instead.
|
||||
|
||||
After the `c3.php` file is included in application you can start gather coverage.
|
||||
In case you execute your application locally there is nothing to be changed in config.
|
||||
All codecoverage reports will be collected as usual and merged afterwards.
|
||||
Think of it: Codeception runs remote coverage in the same way as local.
|
||||
|
||||
### Remote Server
|
||||
|
||||
But if you run tests on different server (or your webserver doesn't use code from current directory) a single option `remote` should be added to config.
|
||||
For example, let's turn on remote coverage for acceptance suite in `acceptance.suite.yml`:
|
||||
|
||||
``` yaml
|
||||
coverage:
|
||||
remote: true
|
||||
```
|
||||
|
||||
In this case remote Code Coverage results won't be merged with local ones, if this option is enabled.
|
||||
Merging is possible only in case a remote and local files have the same path.
|
||||
But in case of running tests on a remote server we are not sure of it.
|
||||
|
||||
CodeCoverage results from remote server will be saved to `tests/_output` directory. Please note that remote codecoverage results won't be displayed in console by the reason mentioned above: local and remote results can't be merged, and console displays results for local codecoverage.
|
||||
|
||||
### Remote Context Options
|
||||
|
||||
HTML report generation can at times take a little more time than the default 30 second timeout. Or maybe you want to alter SSL settings (verify_peer, for example)
|
||||
To alter the way c3 sends it's service requests to your webserver (be it a local or a remote one), you can use the `remote_context_options` key in `coverage` settings.
|
||||
|
||||
``` yaml
|
||||
coverage:
|
||||
remote_context_options:
|
||||
http:
|
||||
timeout: 60
|
||||
ssl:
|
||||
verify_peer: false
|
||||
```
|
||||
|
||||
Context stream options are [well documented at php.net](http://php.net/manual/en/context.php)
|
||||
|
||||
## Conclusion
|
||||
|
||||
It's never been easier to setup local and remote code coverage. Just one config and one additional file to include!
|
||||
**With Codeception you can easily generate CodeCoverage reports for your Selenium tests** (or other acceptance or api tests). Mixing reports for `acceptance`, `functional`, and `unit` suites provides you with the most complete information on which parts of your applications are tested and which are not.
|
||||
156
vendor/codeception/base/docs/12-ContinuousIntegration.md
vendored
Normal file
156
vendor/codeception/base/docs/12-ContinuousIntegration.md
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
# Continuous Integration
|
||||
|
||||
Once you get testing suite up and running you are interested in running your tests regularly. If you ensure that tests are running on every code change or at least once a day you can be sure that no regression is introduced. This allows to keep you system stable. But developers are not so passionate about running all tests manually, they also can forget to execute tests before pushing code to production... The solution is simple, test execution should be automated. Instead of running them locally it is better to have dedicated server responsible for running tests for a team. This way we can ensure that everyone's tests executed, which commit made a regression in codebase, and that we can deploy only once tests pass.
|
||||
|
||||
There are many Continuous Integration Servers out there. We will try to list basic steps to setup Codeception tests with them. If your CI system is not mentioned, you can get the idea by analogy. Please also help us to extend this guide by adding instructions for different CIs.
|
||||
|
||||
## Jenkins
|
||||
|
||||

|
||||
|
||||
[Jenkins](http://jenkins-ci.org/) is one of the most popular open-source solution on market. It is easy to setup and is easy to customize by applying various plugins.
|
||||
|
||||

|
||||
|
||||
### Preparing Jenkins
|
||||
|
||||
It is recommended to have the next plugins installed:
|
||||
|
||||
* **Git Plugin** - for building tests for Git repo
|
||||
* **Green Balls** - to display success results in green.
|
||||
* **xUnit Plugin**, **jUnit Plugin** - to process and display Codeception XML reports
|
||||
* **HTML Publisher Plugin** - to process Codeception HTML reports
|
||||
* **AnsiColor** - to show colorized console output.
|
||||
|
||||

|
||||
|
||||
### Basic Setup
|
||||
|
||||
At first we need to create build project. Depending on your needs you can set up periodical build or trigger build once the change is pushed to GitHub (you will need GitHub plugin for that).
|
||||
|
||||
We need to define build steps. The most simple setup may look like this:
|
||||
|
||||
```
|
||||
php vendor/bin/codecept run
|
||||
```
|
||||
|
||||

|
||||
|
||||
Then we can start the very first job and check the execution progress. If tests fail we will see that in console:
|
||||
|
||||

|
||||
|
||||
### XML Reports
|
||||
|
||||
But we don't want to analyze console output for each failing build. Especially If Jenkins can collect and display the results inside its web UI. Codeception can export its results using JUnit XML format. To generate XML report on each build we will need to append `--xml` option to Codeception execution command. Codeception will print `result.xml` file containing information about test status with steps and stack traces for failing tests.
|
||||
|
||||
Now let's update our build step to generate xml:
|
||||
|
||||
```
|
||||
php vendor/bin/codecept run --xml
|
||||
```
|
||||
|
||||
and ask Jenkins to collect resulted XML. This can be done as part of Post-build actions. Let's add *Publish xUnit test result report* action and configure it to use with PHPUnit reports.
|
||||
|
||||

|
||||
|
||||
Now we should specify path to PHPUnit style XML reports. In case of standard Codeception setup we should specify `tests/_output/*.xml` as a pattern for matching resulted XMLs. Now we save the project and rebuild it.
|
||||
|
||||

|
||||
|
||||
Now for all builds we will see results trend graph that shows us percentage of passing and failing tests. We also will see a **Latest Test Result** link which will lead to to the page where all executed tests and their stats listed in a table.
|
||||
|
||||
### HTML Reports
|
||||
|
||||
To get more details on steps executed you can generate HTML report and use Jenkins to display them.
|
||||
|
||||
```
|
||||
php vendor/bin/codecept run --html
|
||||
```
|
||||
|
||||
Now we need HTML Publisher plugin configured to display generated HTML files. It should be added as post-build action similar way we did it for XML reports.
|
||||
|
||||

|
||||
|
||||
Jenkins should locate `report.html` at `tests/_output/`. Now Jenkins will display HTML reports for each build.
|
||||
|
||||

|
||||

|
||||
|
||||
## TeamCity
|
||||
|
||||

|
||||
|
||||
TeamCity is a hosted solution from JetBrains. The setup of it can be a bit tricky as TeamCity uses its own reporter format for parsing test results. PHPUnit since version 5.x has integrated support for this format, so does Codeception. What we need to do is to configure Codeception to use custom reporter. By default there is `--report` option which provides an alternative output. You can change the reporter class in `codeception.yml` configuration:
|
||||
|
||||
```yaml
|
||||
reporters:
|
||||
report: PHPUnit_Util_Log_TeamCity
|
||||
```
|
||||
|
||||
As an alternative you can use 3rd-party [TeamCity extension](https://github.com/neronmoon/TeamcityCodeception) for better reporting.
|
||||
|
||||
After you create build project you should define build step with Codeception which is
|
||||
|
||||
```
|
||||
php vendor/bin/codecept run --report
|
||||
```
|
||||
|
||||

|
||||
|
||||
Once you execute your first build you should see detailed report inside TeamCity interface:
|
||||
|
||||

|
||||
|
||||
## TravisCI
|
||||
|
||||

|
||||
|
||||
Travis CI is popular service CI with good GitHub integration. Codeception is self-tested with Travis CI. There nothing special about configuration. Just add to the bottom line of travis configuration:
|
||||
|
||||
```yaml
|
||||
php vendor/bin/codecept run
|
||||
```
|
||||
|
||||
More details on configuration can be learned from Codeception's [`.travis.yml`](https://github.com/Codeception/Codeception/blob/master/.travis.yml).
|
||||
|
||||
Travis doesn't provide visualization for XML or HTML reports so you can't view reports in format any different than console output. However, Codeception produces nice console output with detailed error reports.
|
||||
|
||||
## GitLab
|
||||
|
||||

|
||||
|
||||
If a file `.gitlab-ci.yml` exists in the root of the git repository, GitLab will run a pipeline each time you push to the gitlab server. The file configures the docker image that will be called. Below is a sample which loads a php7 docker image, clones your files, installs composer dependencies, runs the built-in php webserver and finally runs codeception:
|
||||
|
||||
```yaml
|
||||
# Select image from https://hub.docker.com/_/php/
|
||||
image: php:7.0
|
||||
|
||||
# Select what we should cache
|
||||
cache:
|
||||
paths:
|
||||
- vendor/
|
||||
|
||||
before_script:
|
||||
# Install git and unzip (composer will need them)
|
||||
- apt-get update && apt-get install -qqy git unzip
|
||||
# Install composer
|
||||
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
# Install all project dependencies
|
||||
- composer install
|
||||
# Run webserver
|
||||
- php -S localhost:8085 --docroot public &>/dev/null&
|
||||
|
||||
# Test
|
||||
test:
|
||||
script:
|
||||
- vendor/bin/codecept run
|
||||
```
|
||||
|
||||

|
||||
|
||||
For acceptance testing you can use `codeception/codeception` docker image as base.
|
||||
|
||||
## Conclusion
|
||||
|
||||
It is highly recommended to use Continuous Integration system in development. Codeception is easy to install and run in any CI systems. However, each of them has their differences you should take into account. You can use different reporters to provide output in format expected by CI system.
|
||||
420
vendor/codeception/base/docs/12-ParallelExecution.md
vendored
Normal file
420
vendor/codeception/base/docs/12-ParallelExecution.md
vendored
Normal file
@@ -0,0 +1,420 @@
|
||||
# Parallel Execution
|
||||
|
||||
When execution time of your tests is longer than a coffee break, it is a good reason to think about making your tests faster. If you have already tried to run them on SSD drive, or to use PhantomJS instead of Selenium, and the execution time still upsets you, it might be a good idea to run your tests in parallel.
|
||||
|
||||
## Where to start
|
||||
|
||||
Codeception does not provide a command like `run-parallel`. There is no common solution that can play well for everyone. Here are the questions you will need to answer:
|
||||
|
||||
* How parallel processes will be executed?
|
||||
* How parallel processes won't affect each other?
|
||||
* Will they use different databases?
|
||||
* Will they use different hosts?
|
||||
* How should I split my tests across parallel processes?
|
||||
|
||||
There are two approaches to achieve parallelization. We can use [Docker](http://docker.com) and run each process inside isolated containers, and have those containers executed simultaneously.
|
||||
|
||||
Docker works really well for isolating testing environments.
|
||||
By the time of writing this chapter, we didn't have an awesome tool like it. This chapter demonstrates how to manage parallel execution manually. As you will see we spend too much effort trying to isolate tests which Docker does for free. Today we <strong>recommend using Docker</strong> for parallel testing.
|
||||
|
||||
## Docker
|
||||
|
||||
Please make sure you have `docker` or [Docker Toolbox](https://www.docker.com/products/docker-toolbox) installed. Docker experience is required as well.
|
||||
|
||||
### Using Codeception Docker image
|
||||
|
||||
Run official Codeception image from DockerHub:
|
||||
|
||||
docker run codeception/codeception
|
||||
|
||||
Running tests from a project, by mounting the current path as a host-volume into the container.
|
||||
The **default working directory in the container is `/project`**.
|
||||
|
||||
docker run -v ${PWD}:/project codeception/codeception run
|
||||
|
||||
To prepare application and tests to be executed inside containers you will need to use [Docker Compose](https://docs.docker.com/compose/) to run multiple containers and connect them together.
|
||||
|
||||
Define all required services in `docker-compose.yml` file. Make sure to follow Docker philisophy: 1 service = 1 container. So each process should be defined as its own service. Those services can use official Docker images pulled from DockerHub. Directories with code and tests should be mounted using `volume` directive. And exposed ports should be explicitly set using `ports` directive.
|
||||
|
||||
We prepared a sample config with codeception, web server, database, and selenium with firefox to be executed together.
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
services:
|
||||
codecept:
|
||||
image: codeception/codeception
|
||||
depends_on:
|
||||
- chrome
|
||||
- web
|
||||
volumes:
|
||||
- .:/project
|
||||
web:
|
||||
image: php:7-apache
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
- .:/var/www/html
|
||||
db:
|
||||
image: percona:5.6
|
||||
chrome:
|
||||
image: selenium/standalone-chrome
|
||||
```
|
||||
|
||||
Codeception service will execute command `codecept run` but only after all services are started. This is defined using `depends_on` parameter.
|
||||
|
||||
It is easy to add more custom services. For instance to use Redis you just simple add this lines:
|
||||
|
||||
```yaml
|
||||
redis:
|
||||
image: redis:3
|
||||
```
|
||||
|
||||
By default the image has codecept as its entrypoint, to run the tests simply supply the run command
|
||||
|
||||
```
|
||||
docker-compose run --rm codecept help
|
||||
```
|
||||
|
||||
Run suite
|
||||
|
||||
```
|
||||
docker-compose run --rm codecept run acceptance
|
||||
```
|
||||
|
||||
```
|
||||
docker-compose run --rm codecept run acceptance LoginCest
|
||||
```
|
||||
|
||||
Development bash
|
||||
|
||||
```
|
||||
docker-compose run --rm --entrypoint bash codecept
|
||||
```
|
||||
|
||||
And finally to execute testing in parallel you should define how you split your tests and run parallel processes for `docker-compose`. Here we split tests by suites, but you can use different groups to split your tests. In section below you will learn how to do that with Robo.
|
||||
|
||||
```
|
||||
docker-compose --project-name test-web run -d --rm codecept run --html report-web.html web & \
|
||||
docker-compose --project-name test-unit run -d --rm codecept run --html report-unit.html unit & \
|
||||
docker-compose --project-name test-functional run -d --rm codecept run --html report-functional.html functional
|
||||
```
|
||||
|
||||
At the end, it is worth specifying that Docker setup can be complicated and please make sure you understand Docker and Docker Compose before proceed. We prepared some links that might help you:
|
||||
|
||||
* [Acceptance Tests Demo Repository](https://github.com/dmstr/docker-acception)
|
||||
* [Dockerized Codeception Internal Tests](https://github.com/Codeception/Codeception/blob/master/tests/README.md#dockerized-testing)
|
||||
* [Phundament App with Codeception](https://gist.github.com/schmunk42/d6893a64963509ff93daea80f722f694)
|
||||
|
||||
If you want to automate splitting tests by parallel processes, and executing them using PHP script you should use Robo task runner to do that.
|
||||
|
||||
## Robo
|
||||
|
||||
### What to do
|
||||
|
||||
Parallel Test Execution consists of 3 steps:
|
||||
|
||||
* splitting tests
|
||||
* running tests in parallel
|
||||
* merging results
|
||||
|
||||
We propose to perform those steps using a task runner. In this guide we will use [**Robo**](http://robo.li) task runner. It is a modern PHP task runner that is very easy to use. It uses [Symfony Process](http://symfony.com/doc/current/components/process.html) to spawn background and parallel processes. Just what we need for the step 2! What about steps 1 and 3? We have created robo [tasks](https://github.com/Codeception/robo-paracept) for splitting tests into groups and merging resulting JUnit XML reports.
|
||||
|
||||
To conclude, we need:
|
||||
|
||||
* [Robo](http://robo.li), a task runner.
|
||||
* [robo-paracept](https://github.com/Codeception/robo-paracept) - Codeception tasks for parallel execution.
|
||||
|
||||
## Preparing Robo and Robo-paracept
|
||||
|
||||
Execute this command in an empty folder to install Robo and Robo-paracept :
|
||||
```bash
|
||||
$ composer require codeception/robo-paracept:dev-master
|
||||
```
|
||||
|
||||
You need to install Codeception after, if codeception is already installed it will not work.
|
||||
```bash
|
||||
$ composer require codeception/codeception
|
||||
```
|
||||
|
||||
### Preparing Robo
|
||||
|
||||
Initializes basic RoboFile in the root of your project
|
||||
|
||||
```bash
|
||||
$ robo init
|
||||
```
|
||||
|
||||
Open `RoboFile.php` to edit it
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
class RoboFile extends \Robo\Tasks
|
||||
{
|
||||
// define public methods as commands
|
||||
}
|
||||
```
|
||||
|
||||
Each public method in robofile can be executed as a command from console. Let's define commands for 3 steps and include autoload.
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
class Robofile extends \Robo\Tasks
|
||||
{
|
||||
use \Codeception\Task\MergeReports;
|
||||
use \Codeception\Task\SplitTestsByGroups;
|
||||
|
||||
public function parallelSplitTests()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function parallelRun()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function parallelMergeResults()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you run `robo`, you can see the respective commands:
|
||||
|
||||
```bash
|
||||
$ robo
|
||||
Robo version 0.6.0
|
||||
|
||||
Usage:
|
||||
command [options] [arguments]
|
||||
|
||||
Options:
|
||||
-h, --help Display this help message
|
||||
-q, --quiet Do not output any message
|
||||
-V, --version Display this application version
|
||||
--ansi Force ANSI output
|
||||
--no-ansi Disable ANSI output
|
||||
-n, --no-interaction Do not ask any interactive question
|
||||
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||
|
||||
Available commands:
|
||||
help Displays help for a command
|
||||
list Lists commands
|
||||
parallel
|
||||
parallel:merge-results
|
||||
parallel:run
|
||||
parallel:split-tests
|
||||
```
|
||||
|
||||
#### Step 1: Split Tests
|
||||
|
||||
Codeception can organize tests into [groups](http://codeception.com/docs/07-AdvancedUsage#Groups). Starting from 2.0 it can load information about a group from a files. Sample text file with a list of file names can be treated as a dynamically configured group. Take a look into sample group file:
|
||||
|
||||
```bash
|
||||
tests/functional/LoginCept.php
|
||||
tests/functional/AdminCest.php:createUser
|
||||
tests/functional/AdminCest.php:deleteUser
|
||||
```
|
||||
|
||||
Tasks from `\Codeception\Task\SplitTestsByGroups` will generate non-intersecting group files. You can either split your tests by files or by single tests:
|
||||
|
||||
```php
|
||||
<?php
|
||||
function parallelSplitTests()
|
||||
{
|
||||
// Split your tests by files
|
||||
$this->taskSplitTestFilesByGroups(5)
|
||||
->projectRoot('.')
|
||||
->testsFrom('tests/acceptance')
|
||||
->groupsTo('tests/_data/paracept_')
|
||||
->run();
|
||||
|
||||
/*
|
||||
// Split your tests by single tests (alternatively)
|
||||
$this->taskSplitTestsByGroups(5)
|
||||
->projectRoot('.')
|
||||
->testsFrom('tests/acceptance')
|
||||
->groupsTo('tests/_data/paracept_')
|
||||
->run();
|
||||
*/
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Let's prepare group files:
|
||||
|
||||
```bash
|
||||
$ robo parallel:split-tests
|
||||
|
||||
[Codeception\Task\SplitTestFilesByGroupsTask] Processing 33 files
|
||||
[Codeception\Task\SplitTestFilesByGroupsTask] Writing tests/_data/paracept_1
|
||||
[Codeception\Task\SplitTestFilesByGroupsTask] Writing tests/_data/paracept_2
|
||||
[Codeception\Task\SplitTestFilesByGroupsTask] Writing tests/_data/paracept_3
|
||||
[Codeception\Task\SplitTestFilesByGroupsTask] Writing tests/_data/paracept_4
|
||||
[Codeception\Task\SplitTestFilesByGroupsTask] Writing tests/_data/paracept_5
|
||||
```
|
||||
|
||||
Now we have group files. We should update `codeception.yml` to load generated group files. In our case we have groups: *paracept_1*, *paracept_2*, *paracept_3*, *paracept_4*, *paracept_5*.
|
||||
|
||||
```yaml
|
||||
groups:
|
||||
paracept_*: tests/_data/paracept_*
|
||||
```
|
||||
|
||||
Let's try to execute tests from the second group:
|
||||
|
||||
```bash
|
||||
$ codecept run acceptance -g paracept_2
|
||||
```
|
||||
|
||||
#### Step 2: Running Tests
|
||||
|
||||
Robo has `ParallelExec` task to spawn background processes.
|
||||
|
||||
##### Inside Container
|
||||
|
||||
If you are using [Docker](#docker) containers you can launch multiple Codeception containers for different groups:
|
||||
|
||||
```php
|
||||
public function parallelRun()
|
||||
{
|
||||
$parallel = $this->taskParallelExec();
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$parallel->process(
|
||||
$this->taskExec('docker-compose run --rm codecept run')
|
||||
->opt('group', "paracept_$i") // run for groups paracept_*
|
||||
->opt('xml', "tests/_log/result_$i.xml"); // provide xml report
|
||||
);
|
||||
}
|
||||
return $parallel->run();
|
||||
}
|
||||
```
|
||||
|
||||
##### Locally
|
||||
|
||||
If you want to run tests locally just use preinstalled `taskCodecept` task of Robo to define Codeception commands and put them inside `parallelExec`.
|
||||
|
||||
```php
|
||||
<?php
|
||||
public function parallelRun()
|
||||
{
|
||||
$parallel = $this->taskParallelExec();
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$parallel->process(
|
||||
$this->taskCodecept() // use built-in Codecept task
|
||||
->suite('acceptance') // run acceptance tests
|
||||
->group("paracept_$i") // for all paracept_* groups
|
||||
->xml("tests/_log/result_$i.xml") // save XML results
|
||||
);
|
||||
}
|
||||
return $parallel->run();
|
||||
}
|
||||
```
|
||||
|
||||
In case you don't use containers you can isolate processes by starting different web servers and databases per each test process.
|
||||
|
||||
We can define different databases for different processes. This can be done using [Environments](http://codeception.com/docs/07-AdvancedUsage#Environments). Let's define 5 new environments in `acceptance.suite.yml`:
|
||||
|
||||
```yaml
|
||||
actor: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- Db:
|
||||
dsn: 'mysql:dbname=testdb;host=127.0.0.1'
|
||||
user: 'root'
|
||||
dump: 'tests/_data/dump.sql'
|
||||
populate: true
|
||||
cleanup: true
|
||||
- WebDriver:
|
||||
url: 'http://localhost/'
|
||||
env:
|
||||
env1:
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: 'mysql:dbname=testdb_1;host=127.0.0.1'
|
||||
WebDriver:
|
||||
url: 'http://test1.localhost/'
|
||||
env2:
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: 'mysql:dbname=testdb_2;host=127.0.0.1'
|
||||
WebDriver:
|
||||
url: 'http://test2.localhost/'
|
||||
env3:
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: 'mysql:dbname=testdb_3;host=127.0.0.1'
|
||||
WebDriver:
|
||||
url: 'http://test3.localhost/'
|
||||
env4:
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: 'mysql:dbname=testdb_4;host=127.0.0.1'
|
||||
WebDriver:
|
||||
url: 'http://test4.localhost/'
|
||||
env5:
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: 'mysql:dbname=testdb_5;host=127.0.0.1'
|
||||
WebDriver:
|
||||
url: 'http://test5.localhost/'
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
After the `parallelRun` method is defined you can execute tests with
|
||||
|
||||
```bash
|
||||
$ robo parallel:run
|
||||
```
|
||||
|
||||
#### Step 3: Merge Results
|
||||
|
||||
In case of `parallelExec` task we recommend to save results as JUnit XML, which can be merged and plugged into Continuous Integration server.
|
||||
|
||||
```php
|
||||
<?php
|
||||
function parallelMergeResults()
|
||||
{
|
||||
$merge = $this->taskMergeXmlReports();
|
||||
for ($i=1; $i<=5; $i++) {
|
||||
$merge->from("tests/_output/result_paracept_$i.xml");
|
||||
}
|
||||
$merge->into("tests/_output/result_paracept.xml")->run();
|
||||
}
|
||||
|
||||
```
|
||||
Now, we can execute :
|
||||
```bash
|
||||
$ robo parallel:merge-results
|
||||
```
|
||||
`result_paracept.xml` file will be generated. It can be processed and analyzed.
|
||||
|
||||
#### All Together
|
||||
|
||||
To create one command to rule them all we can define new public method `parallelAll` and execute all commands. We will save the result of `parallelRun` and use it for our final exit code:
|
||||
|
||||
```php
|
||||
<?php
|
||||
function parallelAll()
|
||||
{
|
||||
$this->parallelSplitTests();
|
||||
$result = $this->parallelRun();
|
||||
$this->parallelMergeResults();
|
||||
return $result;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Conclusion
|
||||
|
||||
Codeception does not provide tools for parallel test execution. This is a complex task and solutions may vary depending on a project. We use [Robo](http://robo.li) task runner as an external tool to perform all required steps. To prepare our tests to be executed in parallel we use Codeception features of dynamic groups and environments. To do even more we can create Extensions and Group classes to perform dynamic configuration depending on a test process.
|
||||
202
vendor/codeception/base/docs/modules/AMQP.md
vendored
Normal file
202
vendor/codeception/base/docs/modules/AMQP.md
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
# AMQP
|
||||
|
||||
|
||||
This module interacts with message broker software that implements
|
||||
the Advanced Message Queuing Protocol (AMQP) standard. For example, RabbitMQ (tested).
|
||||
|
||||
<div class="alert alert-info">
|
||||
To use this module with Composer you need <em>"php-amqplib/php-amqplib": "~2.4"</em> package.
|
||||
</div>
|
||||
|
||||
## Config
|
||||
|
||||
* host: localhost - host to connect
|
||||
* username: guest - username to connect
|
||||
* password: guest - password to connect
|
||||
* vhost: '/' - vhost to connect
|
||||
* cleanup: true - defined queues will be purged before running every test.
|
||||
* queues: [mail, twitter] - queues to cleanup
|
||||
* single_channel - create and use only one channel during test execution
|
||||
|
||||
### Example
|
||||
|
||||
modules:
|
||||
enabled:
|
||||
- AMQP:
|
||||
host: 'localhost'
|
||||
port: '5672'
|
||||
username: 'guest'
|
||||
password: 'guest'
|
||||
vhost: '/'
|
||||
queues: [queue1, queue2]
|
||||
single_channel: false
|
||||
|
||||
## Public Properties
|
||||
|
||||
* connection - AMQPStreamConnection - current connection
|
||||
|
||||
## Actions
|
||||
|
||||
### bindQueueToExchange
|
||||
|
||||
Binds a queue to an exchange
|
||||
|
||||
This is an alias of method `queue_bind` of `PhpAmqpLib\Channel\AMQPChannel`.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->bindQueueToExchange(
|
||||
'nameOfMyQueueToBind', // name of the queue
|
||||
'transactionTracking.transaction', // exchange name to bind to
|
||||
'your.routing.key' // Optionally, provide a binding key
|
||||
)
|
||||
```
|
||||
|
||||
* `param string` $queue
|
||||
* `param string` $exchange
|
||||
* `param string` $routing_key
|
||||
* `param bool` $nowait
|
||||
* `param array` $arguments
|
||||
* `param int` $ticket
|
||||
* `return` mixed|null
|
||||
|
||||
|
||||
### declareExchange
|
||||
|
||||
Declares an exchange
|
||||
|
||||
This is an alias of method `exchange_declare` of `PhpAmqpLib\Channel\AMQPChannel`.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->declareExchange(
|
||||
'nameOfMyExchange', // exchange name
|
||||
'topic' // exchange type
|
||||
)
|
||||
```
|
||||
|
||||
* `param string` $exchange
|
||||
* `param string` $type
|
||||
* `param bool` $passive
|
||||
* `param bool` $durable
|
||||
* `param bool` $auto_delete
|
||||
* `param bool` $internal
|
||||
* `param bool` $nowait
|
||||
* `param array` $arguments
|
||||
* `param int` $ticket
|
||||
* `return` mixed|null
|
||||
|
||||
|
||||
### declareQueue
|
||||
|
||||
Declares queue, creates if needed
|
||||
|
||||
This is an alias of method `queue_declare` of `PhpAmqpLib\Channel\AMQPChannel`.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->declareQueue(
|
||||
'nameOfMyQueue', // exchange name
|
||||
)
|
||||
```
|
||||
|
||||
* `param string` $queue
|
||||
* `param bool` $passive
|
||||
* `param bool` $durable
|
||||
* `param bool` $exclusive
|
||||
* `param bool` $auto_delete
|
||||
* `param bool` $nowait
|
||||
* `param array` $arguments
|
||||
* `param int` $ticket
|
||||
* `return` mixed|null
|
||||
|
||||
|
||||
### grabMessageFromQueue
|
||||
|
||||
Takes last message from queue.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$message = $I->grabMessageFromQueue('queue.emails');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue
|
||||
* `return` \PhpAmqpLib\Message\AMQPMessage
|
||||
|
||||
|
||||
### purgeAllQueues
|
||||
|
||||
Purge all queues defined in config.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->purgeAllQueues();
|
||||
?>
|
||||
```
|
||||
|
||||
|
||||
### purgeQueue
|
||||
|
||||
Purge a specific queue defined in config.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->purgeQueue('queue.emails');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queueName
|
||||
|
||||
|
||||
### pushToExchange
|
||||
|
||||
Sends message to exchange by sending exchange name, message
|
||||
and (optionally) a routing key
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->pushToExchange('exchange.emails', 'thanks');
|
||||
$I->pushToExchange('exchange.emails', new AMQPMessage('Thanks!'));
|
||||
$I->pushToExchange('exchange.emails', new AMQPMessage('Thanks!'), 'severity');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $exchange
|
||||
* `param string|\PhpAmqpLib\Message\AMQPMessage` $message
|
||||
* `param string` $routing_key
|
||||
|
||||
|
||||
### pushToQueue
|
||||
|
||||
Sends message to queue
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->pushToQueue('queue.jobs', 'create user');
|
||||
$I->pushToQueue('queue.jobs', new AMQPMessage('create'));
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue
|
||||
* `param string|\PhpAmqpLib\Message\AMQPMessage` $message
|
||||
|
||||
|
||||
### seeMessageInQueueContainsText
|
||||
|
||||
Checks if message containing text received.
|
||||
|
||||
**This method drops message from queue**
|
||||
**This method will wait for message. If none is sent the script will stuck**.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->pushToQueue('queue.emails', 'Hello, davert');
|
||||
$I->seeMessageInQueueContainsText('queue.emails','davert');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue
|
||||
* `param string` $text
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/AMQP.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
1952
vendor/codeception/base/docs/modules/AngularJS.md
vendored
Normal file
1952
vendor/codeception/base/docs/modules/AngularJS.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
115
vendor/codeception/base/docs/modules/Apc.md
vendored
Normal file
115
vendor/codeception/base/docs/modules/Apc.md
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
# Apc
|
||||
|
||||
|
||||
This module interacts with the [Alternative PHP Cache (APC)](http://php.net/manual/en/intro.apcu.php)
|
||||
using either _APCu_ or _APC_ extension.
|
||||
|
||||
Performs a cleanup by flushing all values after each test run.
|
||||
|
||||
## Status
|
||||
|
||||
* Maintainer: **Serghei Iakovlev**
|
||||
* Stability: **stable**
|
||||
* Contact: serghei@phalconphp.com
|
||||
|
||||
### Example (`unit.suite.yml`)
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
- Apc
|
||||
```
|
||||
|
||||
Be sure you don't use the production server to connect.
|
||||
|
||||
|
||||
## Actions
|
||||
|
||||
### dontSeeInApc
|
||||
|
||||
Checks item in APC(u) doesn't exist or is the same as expected.
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// With only one argument, only checks the key does not exist
|
||||
$I->dontSeeInApc('users_count');
|
||||
|
||||
// Checks a 'users_count' exists does not exist or its value is not the one provided
|
||||
$I->dontSeeInApc('users_count', 200);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string|string[]` $key
|
||||
* `param mixed` $value
|
||||
|
||||
|
||||
### flushApc
|
||||
|
||||
Clears the APC(u) cache
|
||||
|
||||
|
||||
### grabValueFromApc
|
||||
|
||||
Grabs value from APC(u) by key.
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$users_count = $I->grabValueFromApc('users_count');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string|string[]` $key
|
||||
|
||||
|
||||
### haveInApc
|
||||
|
||||
Stores an item `$value` with `$key` on the APC(u).
|
||||
|
||||
Examples:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// Array
|
||||
$I->haveInApc('users', ['name' => 'miles', 'email' => 'miles@davis.com']);
|
||||
|
||||
// Object
|
||||
$I->haveInApc('user', UserRepository::findFirst());
|
||||
|
||||
// Key as array of 'key => value'
|
||||
$entries = [];
|
||||
$entries['key1'] = 'value1';
|
||||
$entries['key2'] = 'value2';
|
||||
$entries['key3'] = ['value3a','value3b'];
|
||||
$entries['key4'] = 4;
|
||||
$I->haveInApc($entries, null);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string|array` $key
|
||||
* `param mixed` $value
|
||||
* `param int` $expiration
|
||||
|
||||
|
||||
### seeInApc
|
||||
|
||||
Checks item in APC(u) exists and the same as expected.
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// With only one argument, only checks the key exists
|
||||
$I->seeInApc('users_count');
|
||||
|
||||
// Checks a 'users_count' exists and has the value 200
|
||||
$I->seeInApc('users_count', 200);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string|string[]` $key
|
||||
* `param mixed` $value
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/Apc.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
350
vendor/codeception/base/docs/modules/Asserts.md
vendored
Normal file
350
vendor/codeception/base/docs/modules/Asserts.md
vendored
Normal file
@@ -0,0 +1,350 @@
|
||||
# Asserts
|
||||
|
||||
|
||||
Special module for using asserts in your tests.
|
||||
|
||||
## Actions
|
||||
|
||||
### assertArrayHasKey
|
||||
|
||||
* `param` $key
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
|
||||
### assertArrayNotHasKey
|
||||
|
||||
* `param` $key
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
|
||||
### assertArraySubset
|
||||
|
||||
Checks that array contains subset.
|
||||
|
||||
* `param array` $subset
|
||||
* `param array` $array
|
||||
* `param bool` $strict
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertContains
|
||||
|
||||
Checks that haystack contains needle
|
||||
|
||||
* `param` $needle
|
||||
* `param` $haystack
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertCount
|
||||
|
||||
* `param` $expectedCount
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
|
||||
### assertEmpty
|
||||
|
||||
Checks that variable is empty.
|
||||
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertEquals
|
||||
|
||||
Checks that two variables are equal. If you're comparing floating-point values,
|
||||
you can specify the optional "delta" parameter which dictates how great of a precision
|
||||
error are you willing to tolerate in order to consider the two values equal.
|
||||
|
||||
Regular example:
|
||||
```php
|
||||
<?php
|
||||
$I->assertEquals($element->getChildrenCount(), 5);
|
||||
```
|
||||
|
||||
Floating-point example:
|
||||
```php
|
||||
<?php
|
||||
$I->assertEquals($calculator->add(0.1, 0.2), 0.3, 'Calculator should add the two numbers correctly.', 0.01);
|
||||
```
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
* `param float` $delta
|
||||
|
||||
|
||||
### assertFalse
|
||||
|
||||
Checks that condition is negative.
|
||||
|
||||
* `param` $condition
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertFileExists
|
||||
|
||||
Checks if file exists
|
||||
|
||||
* `param string` $filename
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertFileNotExists
|
||||
|
||||
Checks if file doesn't exist
|
||||
|
||||
* `param string` $filename
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertGreaterOrEquals
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
|
||||
### assertGreaterThan
|
||||
|
||||
Checks that actual is greater than expected
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertGreaterThanOrEqual
|
||||
|
||||
Checks that actual is greater or equal than expected
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertInstanceOf
|
||||
|
||||
* `param` $class
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
|
||||
### assertInternalType
|
||||
|
||||
* `param` $type
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
|
||||
### assertIsEmpty
|
||||
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
|
||||
### assertLessOrEquals
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
|
||||
### assertLessThan
|
||||
|
||||
Checks that actual is less than expected
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertLessThanOrEqual
|
||||
|
||||
Checks that actual is less or equal than expected
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertNotContains
|
||||
|
||||
Checks that haystack doesn't contain needle.
|
||||
|
||||
* `param` $needle
|
||||
* `param` $haystack
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertNotEmpty
|
||||
|
||||
Checks that variable is not empty.
|
||||
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertNotEquals
|
||||
|
||||
Checks that two variables are not equal. If you're comparing floating-point values,
|
||||
you can specify the optional "delta" parameter which dictates how great of a precision
|
||||
error are you willing to tolerate in order to consider the two values not equal.
|
||||
|
||||
Regular example:
|
||||
```php
|
||||
<?php
|
||||
$I->assertNotEquals($element->getChildrenCount(), 0);
|
||||
```
|
||||
|
||||
Floating-point example:
|
||||
```php
|
||||
<?php
|
||||
$I->assertNotEquals($calculator->add(0.1, 0.2), 0.4, 'Calculator should add the two numbers correctly.', 0.01);
|
||||
```
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
* `param float` $delta
|
||||
|
||||
|
||||
### assertNotFalse
|
||||
|
||||
Checks that the condition is NOT false (everything but false)
|
||||
|
||||
* `param` $condition
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertNotInstanceOf
|
||||
|
||||
* `param` $class
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
|
||||
### assertNotNull
|
||||
|
||||
Checks that variable is not NULL
|
||||
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertNotRegExp
|
||||
|
||||
Checks that string not match with pattern
|
||||
|
||||
* `param string` $pattern
|
||||
* `param string` $string
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertNotSame
|
||||
|
||||
Checks that two variables are not same
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertNotTrue
|
||||
|
||||
Checks that the condition is NOT true (everything but true)
|
||||
|
||||
* `param` $condition
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertNull
|
||||
|
||||
Checks that variable is NULL
|
||||
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertRegExp
|
||||
|
||||
Checks that string match with pattern
|
||||
|
||||
* `param string` $pattern
|
||||
* `param string` $string
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertSame
|
||||
|
||||
Checks that two variables are same
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertStringStartsNotWith
|
||||
|
||||
Checks that a string doesn't start with the given prefix.
|
||||
|
||||
* `param string` $prefix
|
||||
* `param string` $string
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertStringStartsWith
|
||||
|
||||
Checks that a string starts with the given prefix.
|
||||
|
||||
* `param string` $prefix
|
||||
* `param string` $string
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### assertTrue
|
||||
|
||||
Checks that condition is positive.
|
||||
|
||||
* `param` $condition
|
||||
* `param string` $message
|
||||
|
||||
|
||||
### expectException
|
||||
|
||||
Handles and checks exception called inside callback function.
|
||||
Either exception class name or exception instance should be provided.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->expectException(MyException::class, function() {
|
||||
$this->doSomethingBad();
|
||||
});
|
||||
|
||||
$I->expectException(new MyException(), function() {
|
||||
$this->doSomethingBad();
|
||||
});
|
||||
```
|
||||
If you want to check message or exception code, you can pass them with exception instance:
|
||||
```php
|
||||
<?php
|
||||
// will check that exception MyException is thrown with "Don't do bad things" message
|
||||
$I->expectException(new MyException("Don't do bad things"), function() {
|
||||
$this->doSomethingBad();
|
||||
});
|
||||
```
|
||||
|
||||
* `param` $exception string or \Exception
|
||||
* `param` $callback
|
||||
|
||||
|
||||
### fail
|
||||
|
||||
Fails the test with message.
|
||||
|
||||
* `param` $message
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/Asserts.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
75
vendor/codeception/base/docs/modules/Cli.md
vendored
Normal file
75
vendor/codeception/base/docs/modules/Cli.md
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
# Cli
|
||||
|
||||
|
||||
Wrapper for basic shell commands and shell output
|
||||
|
||||
## Responsibility
|
||||
* Maintainer: **davert**
|
||||
* Status: **stable**
|
||||
* Contact: codecept@davert.mail.ua
|
||||
|
||||
*Please review the code of non-stable modules and provide patches if you have issues.*
|
||||
|
||||
## Actions
|
||||
|
||||
### dontSeeInShellOutput
|
||||
|
||||
Checks that output from latest command doesn't contain text
|
||||
|
||||
* `param` $text
|
||||
|
||||
|
||||
|
||||
### runShellCommand
|
||||
|
||||
Executes a shell command.
|
||||
Fails If exit code is > 0. You can disable this by setting second parameter to false
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->runShellCommand('phpunit');
|
||||
|
||||
// do not fail test when command fails
|
||||
$I->runShellCommand('phpunit', false);
|
||||
```
|
||||
|
||||
* `param` $command
|
||||
* `param bool` $failNonZero
|
||||
|
||||
|
||||
### seeInShellOutput
|
||||
|
||||
Checks that output from last executed command contains text
|
||||
|
||||
* `param` $text
|
||||
|
||||
|
||||
### seeResultCodeIs
|
||||
|
||||
Checks result code
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeResultCodeIs(0);
|
||||
```
|
||||
|
||||
* `param` $code
|
||||
|
||||
|
||||
### seeResultCodeIsNot
|
||||
|
||||
Checks result code
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeResultCodeIsNot(0);
|
||||
```
|
||||
|
||||
* `param` $code
|
||||
|
||||
|
||||
### seeShellOutputMatches
|
||||
|
||||
* `param` $regex
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/Cli.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
166
vendor/codeception/base/docs/modules/DataFactory.md
vendored
Normal file
166
vendor/codeception/base/docs/modules/DataFactory.md
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
# DataFactory
|
||||
|
||||
|
||||
DataFactory allows you to easily generate and create test data using [**FactoryMuffin**](https://github.com/thephpleague/factory-muffin).
|
||||
DataFactory uses an ORM of your application to define, save and cleanup data. Thus, should be used with ORM or Framework modules.
|
||||
|
||||
This module requires packages installed:
|
||||
|
||||
```json
|
||||
{
|
||||
"league/factory-muffin": "^3.0",
|
||||
}
|
||||
```
|
||||
|
||||
Generation rules can be defined in a factories file. You will need to create `factories.php` (it is recommended to store it in `_support` dir)
|
||||
Follow [FactoryMuffin documentation](https://github.com/thephpleague/factory-muffin) to set valid rules.
|
||||
Random data provided by [Faker](https://github.com/fzaninotto/Faker) library.
|
||||
|
||||
```php
|
||||
<?php
|
||||
use League\FactoryMuffin\Faker\Facade as Faker;
|
||||
|
||||
$fm->define(User::class)->setDefinitions([
|
||||
'name' => Faker::name(),
|
||||
|
||||
// generate email
|
||||
'email' => Faker::email(),
|
||||
'body' => Faker::text(),
|
||||
|
||||
// generate a profile and return its Id
|
||||
'profile_id' => 'factory|Profile'
|
||||
]);
|
||||
```
|
||||
|
||||
Configure this module to load factory definitions from a directory.
|
||||
You should also specify a module with an ORM as a dependency.
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- Yii2:
|
||||
configFile: path/to/config.php
|
||||
- DataFactory:
|
||||
factories: tests/_support/factories
|
||||
depends: Yii2
|
||||
```
|
||||
|
||||
(you can also use Laravel5 and Phalcon).
|
||||
|
||||
In this example factories are loaded from `tests/_support/factories` directory. Please note that this directory is relative from the codeception.yml file (so for Yii2 it would be codeception/_support/factories).
|
||||
You should create this directory manually and create PHP files in it with factories definitions following [official documentation](https://github.com/thephpleague/factory-muffin#usage).
|
||||
|
||||
In cases you want to use data from database inside your factory definitions you can define them in Helper.
|
||||
For instance, if you use Doctrine, this allows you to access `EntityManager` inside a definition.
|
||||
|
||||
To proceed you should create Factories helper via `generate:helper` command and enable it:
|
||||
|
||||
```
|
||||
modules:
|
||||
enabled:
|
||||
- DataFactory:
|
||||
depends: Doctrine2
|
||||
- \Helper\Factories
|
||||
|
||||
```
|
||||
|
||||
In this case you can define factories from a Helper class with `_define` method.
|
||||
|
||||
```php
|
||||
<?php
|
||||
public function _beforeSuite()
|
||||
{
|
||||
$factory = $this->getModule('DataFactory');
|
||||
// let us get EntityManager from Doctrine
|
||||
$em = $this->getModule('Doctrine2')->_getEntityManager();
|
||||
|
||||
$factory->_define(User::class, [
|
||||
|
||||
// generate random user name
|
||||
// use League\FactoryMuffin\Faker\Facade as Faker;
|
||||
'name' => Faker::name(),
|
||||
|
||||
// get real company from database
|
||||
'company' => $em->getRepository(Company::class)->find(),
|
||||
|
||||
// let's generate a profile for each created user
|
||||
// receive an entity and set it via `setProfile` method
|
||||
// UserProfile factory should be defined as well
|
||||
'profile' => 'entity|'.UserProfile::class
|
||||
]);
|
||||
}
|
||||
```
|
||||
|
||||
Factory Definitions are described in official [Factory Muffin Documentation](https://github.com/thephpleague/factory-muffin)
|
||||
|
||||
### Related Models Generators
|
||||
|
||||
If your module relies on other model you can generate them both.
|
||||
To create a related module you can use either `factory` or `entity` prefix, depending on ORM you use.
|
||||
|
||||
In case your ORM expects an Id of a related record (Eloquent) to be set use `factory` prefix:
|
||||
|
||||
```php
|
||||
'user_id' => 'factory|User'
|
||||
```
|
||||
|
||||
In case your ORM expects a related record itself (Doctrine) then you should use `entity` prefix:
|
||||
|
||||
```php
|
||||
'user' => 'entity|User'
|
||||
```
|
||||
|
||||
## Actions
|
||||
|
||||
### have
|
||||
|
||||
Generates and saves a record,.
|
||||
|
||||
```php
|
||||
$I->have('User'); // creates user
|
||||
$I->have('User', ['is_active' => true]); // creates active user
|
||||
```
|
||||
|
||||
Returns an instance of created user.
|
||||
|
||||
* `param string` $name
|
||||
* `param array` $extraAttrs
|
||||
|
||||
* `return` object
|
||||
|
||||
|
||||
### haveMultiple
|
||||
|
||||
Generates and saves a record multiple times.
|
||||
|
||||
```php
|
||||
$I->haveMultiple('User', 10); // create 10 users
|
||||
$I->haveMultiple('User', 10, ['is_active' => true]); // create 10 active users
|
||||
```
|
||||
|
||||
* `param string` $name
|
||||
* `param int` $times
|
||||
* `param array` $extraAttrs
|
||||
|
||||
* `return` \object[]
|
||||
|
||||
|
||||
### make
|
||||
|
||||
Generates a record instance.
|
||||
|
||||
This does not save it in the database. Use `have` for that.
|
||||
|
||||
```php
|
||||
$user = $I->make('User'); // return User instance
|
||||
$activeUser = $I->make('User', ['is_active' => true]); // return active user instance
|
||||
```
|
||||
|
||||
Returns an instance of created user without creating a record in database.
|
||||
|
||||
* `param string` $name
|
||||
* `param array` $extraAttrs
|
||||
|
||||
* `return` object
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/DataFactory.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
327
vendor/codeception/base/docs/modules/Db.md
vendored
Normal file
327
vendor/codeception/base/docs/modules/Db.md
vendored
Normal file
@@ -0,0 +1,327 @@
|
||||
# Db
|
||||
|
||||
|
||||
Access a database.
|
||||
|
||||
The most important function of this module is to clean a database before each test.
|
||||
This module also provides actions to perform checks in a database, e.g. [seeInDatabase()](http://codeception.com/docs/modules/Db#seeInDatabase)
|
||||
|
||||
In order to have your database populated with data you need a raw SQL dump.
|
||||
Simply put the dump in the `tests/_data` directory (by default) and specify the path in the config.
|
||||
The next time after the database is cleared, all your data will be restored from the dump.
|
||||
Don't forget to include `CREATE TABLE` statements in the dump.
|
||||
|
||||
Supported and tested databases are:
|
||||
|
||||
* MySQL
|
||||
* SQLite (i.e. just one file)
|
||||
* PostgreSQL
|
||||
|
||||
Also available:
|
||||
|
||||
* MS SQL
|
||||
* Oracle
|
||||
|
||||
Connection is done by database Drivers, which are stored in the `Codeception\Lib\Driver` namespace.
|
||||
[Check out the drivers](https://github.com/Codeception/Codeception/tree/2.3/src/Codeception/Lib/Driver)
|
||||
if you run into problems loading dumps and cleaning databases.
|
||||
|
||||
## Config
|
||||
|
||||
* dsn *required* - PDO DSN
|
||||
* 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
|
||||
* cleanup: false - whether the dump should be reloaded before each test
|
||||
* reconnect: false - whether the module should reconnect to the database before each test
|
||||
* waitlock: 0 - wait lock (in seconds) that the database session should use for DDL statements
|
||||
* ssl_key - path to the SSL key (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-key)
|
||||
* ssl_cert - path to the SSL certificate (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-cert)
|
||||
* ssl_ca - path to the SSL certificate authority (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-ca)
|
||||
* ssl_verify_server_cert - disables certificate CN verification (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php)
|
||||
* ssl_cipher - list of one or more permissible ciphers to use for SSL encryption (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-cipher)
|
||||
|
||||
## Example
|
||||
|
||||
modules:
|
||||
enabled:
|
||||
- Db:
|
||||
dsn: 'mysql:host=localhost;dbname=testdb'
|
||||
user: 'root'
|
||||
password: ''
|
||||
dump: 'tests/_data/dump.sql'
|
||||
populate: true
|
||||
cleanup: true
|
||||
reconnect: true
|
||||
waitlock: 10
|
||||
ssl_key: '/path/to/client-key.pem'
|
||||
ssl_cert: '/path/to/client-cert.pem'
|
||||
ssl_ca: '/path/to/ca-cert.pem'
|
||||
ssl_verify_server_cert: false
|
||||
ssl_cipher: 'AES256-SHA'
|
||||
|
||||
## SQL data dump
|
||||
|
||||
There are two ways of loading the dump into your database:
|
||||
|
||||
### Populator
|
||||
|
||||
The recommended approach is to configure a `populator`, an external command to load a dump. Command parameters like host, username, password, database
|
||||
can be obtained from the config and inserted into placeholders:
|
||||
|
||||
For MySQL:
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- Db:
|
||||
dsn: 'mysql:host=localhost;dbname=testdb'
|
||||
user: 'root'
|
||||
password: ''
|
||||
dump: 'tests/_data/dump.sql'
|
||||
populate: true # run populator before all tests
|
||||
cleanup: true # run populator before each test
|
||||
populator: 'mysql -u $user -h $host $dbname < $dump'
|
||||
```
|
||||
|
||||
For PostgreSQL (using pg_restore)
|
||||
|
||||
```
|
||||
modules:
|
||||
enabled:
|
||||
- Db:
|
||||
dsn: 'pgsql:host=localhost;dbname=testdb'
|
||||
user: 'root'
|
||||
password: ''
|
||||
dump: 'tests/_data/db_backup.dump'
|
||||
populate: true # run populator before all tests
|
||||
cleanup: true # run populator before each test
|
||||
populator: 'pg_restore -u $user -h $host -D $dbname < $dump'
|
||||
```
|
||||
|
||||
Variable names are being taken from config and DSN which has a `keyword=value` format, so you should expect to have a variable named as the
|
||||
keyword with the full value inside it.
|
||||
|
||||
PDO dsn elements for the supported drivers:
|
||||
* MySQL: [PDO_MYSQL DSN](https://secure.php.net/manual/en/ref.pdo-mysql.connection.php)
|
||||
* SQLite: [PDO_SQLITE DSN](https://secure.php.net/manual/en/ref.pdo-sqlite.connection.php)
|
||||
* PostgreSQL: [PDO_PGSQL DSN](https://secure.php.net/manual/en/ref.pdo-pgsql.connection.php)
|
||||
* MSSQL: [PDO_SQLSRV DSN](https://secure.php.net/manual/en/ref.pdo-sqlsrv.connection.php)
|
||||
* Oracle: [PDO_OCI DSN](https://secure.php.net/manual/en/ref.pdo-oci.connection.php)
|
||||
|
||||
### Dump
|
||||
|
||||
Db module by itself can load SQL dump without external tools by using current database connection.
|
||||
This approach is system-independent, however, it is slower than using a populator and may have parsing issues (see below).
|
||||
|
||||
Provide a path to SQL file in `dump` config option:
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
enabled:
|
||||
- Db:
|
||||
dsn: 'mysql:host=localhost;dbname=testdb'
|
||||
user: 'root'
|
||||
password: ''
|
||||
populate: true # load dump before all tests
|
||||
cleanup: true # load dump for each test
|
||||
dump: 'tests/_data/dump.sql'
|
||||
```
|
||||
|
||||
To parse SQL Db file, it should follow this specification:
|
||||
* Comments are permitted.
|
||||
* The `dump.sql` may contain multiline statements.
|
||||
* The delimiter, a semi-colon in this case, must be on the same line as the last statement:
|
||||
|
||||
```sql
|
||||
-- Add a few contacts to the table.
|
||||
REPLACE INTO `Contacts` (`created`, `modified`, `status`, `contact`, `first`, `last`) VALUES
|
||||
(NOW(), NOW(), 1, 'Bob Ross', 'Bob', 'Ross'),
|
||||
(NOW(), NOW(), 1, 'Fred Flintstone', 'Fred', 'Flintstone');
|
||||
|
||||
-- Remove existing orders for testing.
|
||||
DELETE FROM `Order`;
|
||||
```
|
||||
## Query generation
|
||||
|
||||
`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.
|
||||
|
||||
Example:
|
||||
```php
|
||||
<?php
|
||||
$I->seeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com'));
|
||||
|
||||
```
|
||||
Will generate:
|
||||
|
||||
```sql
|
||||
SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com'
|
||||
```
|
||||
Since version 2.1.9 it's possible to use LIKE in a condition, as shown here:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeInDatabase('users', array('name' => 'Davert', 'email like' => 'davert%'));
|
||||
|
||||
```
|
||||
Will generate:
|
||||
|
||||
```sql
|
||||
SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` LIKE 'davert%'
|
||||
```
|
||||
## Public Properties
|
||||
* dbh - contains the PDO connection
|
||||
* driver - contains the Connection Driver
|
||||
|
||||
|
||||
## Actions
|
||||
|
||||
### dontSeeInDatabase
|
||||
|
||||
Effect is opposite to ->seeInDatabase
|
||||
|
||||
Asserts that there is no record with the given column values in a database.
|
||||
Provide table name and column values.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->dontSeeInDatabase('users', ['name' => 'Davert', 'email' => 'davert@mail.com']);
|
||||
```
|
||||
Fails if such user was found.
|
||||
|
||||
Comparison expressions can be used as well:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->dontSeeInDatabase('posts', ['num_comments >=' => '0']);
|
||||
$I->dontSeeInDatabase('users', ['email like' => 'miles%']);
|
||||
```
|
||||
|
||||
Supported operators: `<`, `>`, `>=`, `<=`, `!=`, `like`.
|
||||
|
||||
* `param string` $table
|
||||
* `param array` $criteria
|
||||
|
||||
|
||||
### grabColumnFromDatabase
|
||||
|
||||
Fetches all values from the column in database.
|
||||
Provide table name, desired column and criteria.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$mails = $I->grabColumnFromDatabase('users', 'email', array('name' => 'RebOOter'));
|
||||
```
|
||||
|
||||
* `param string` $table
|
||||
* `param string` $column
|
||||
* `param array` $criteria
|
||||
|
||||
* `return` array
|
||||
|
||||
|
||||
### grabFromDatabase
|
||||
|
||||
Fetches all values from the column in database.
|
||||
Provide table name, desired column and criteria.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$mails = $I->grabFromDatabase('users', 'email', array('name' => 'RebOOter'));
|
||||
```
|
||||
|
||||
* `param string` $table
|
||||
* `param string` $column
|
||||
* `param array` $criteria
|
||||
|
||||
* `return` array
|
||||
|
||||
|
||||
### grabNumRecords
|
||||
|
||||
Returns the number of rows in a database
|
||||
|
||||
* `param string` $table Table name
|
||||
* `param array` $criteria Search criteria [Optional]
|
||||
|
||||
* `return` int
|
||||
|
||||
|
||||
### haveInDatabase
|
||||
|
||||
Inserts an SQL record into a database. This record will be erased after the test.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->haveInDatabase('users', array('name' => 'miles', 'email' => 'miles@davis.com'));
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $table
|
||||
* `param array` $data
|
||||
|
||||
* `return integer` $id
|
||||
|
||||
|
||||
### isPopulated
|
||||
__not documented__
|
||||
|
||||
|
||||
### seeInDatabase
|
||||
|
||||
Asserts that a row with the given column values exists.
|
||||
Provide table name and column values.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeInDatabase('users', ['name' => 'Davert', 'email' => 'davert@mail.com']);
|
||||
```
|
||||
Fails if no such user found.
|
||||
|
||||
Comparison expressions can be used as well:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeInDatabase('posts', ['num_comments >=' => '0']);
|
||||
$I->seeInDatabase('users', ['email like' => 'miles@davis.com']);
|
||||
```
|
||||
|
||||
Supported operators: `<`, `>`, `>=`, `<=`, `!=`, `like`.
|
||||
|
||||
* `param string` $table
|
||||
* `param array` $criteria
|
||||
|
||||
|
||||
### seeNumRecords
|
||||
|
||||
Asserts that the given number of records were found in the database.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeNumRecords(1, 'users', ['name' => 'davert'])
|
||||
?>
|
||||
```
|
||||
|
||||
* `param int` $expectedNumber Expected number
|
||||
* `param string` $table Table name
|
||||
* `param array` $criteria Search criteria [Optional]
|
||||
|
||||
|
||||
### updateInDatabase
|
||||
|
||||
Update an SQL record into a database.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->updateInDatabase('users', array('isAdmin' => true), array('email' => 'miles@davis.com'));
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $table
|
||||
* `param array` $data
|
||||
* `param array` $criteria
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/Db.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
193
vendor/codeception/base/docs/modules/Doctrine2.md
vendored
Normal file
193
vendor/codeception/base/docs/modules/Doctrine2.md
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
# Doctrine2
|
||||
|
||||
|
||||
Access the database using [Doctrine2 ORM](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/).
|
||||
|
||||
When used with Zend Framework 2 or Symfony2, Doctrine's Entity Manager is automatically retrieved from Service Locator.
|
||||
Set up your `functional.suite.yml` like this:
|
||||
|
||||
```
|
||||
modules:
|
||||
enabled:
|
||||
- Symfony # 'ZF2' or 'Symfony'
|
||||
- Doctrine2:
|
||||
depends: Symfony
|
||||
cleanup: true # All doctrine queries will be wrapped in a transaction, which will be rolled back at the end of each test
|
||||
```
|
||||
|
||||
If you don't use Symfony or Zend Framework, you need to specify a callback function to retrieve the Entity Manager:
|
||||
|
||||
```
|
||||
modules:
|
||||
enabled:
|
||||
- Doctrine2:
|
||||
connection_callback: ['MyDb', 'createEntityManager']
|
||||
cleanup: true # All doctrine queries will be wrapped in a transaction, which will be rolled back at the end of each test
|
||||
|
||||
```
|
||||
|
||||
This will use static method of `MyDb::createEntityManager()` to establish the Entity Manager.
|
||||
|
||||
By default, the module will wrap everything into a transaction for each test and roll it back afterwards. By doing this
|
||||
tests will run much faster and will be isolated from each other.
|
||||
|
||||
## Status
|
||||
|
||||
* Maintainer: **davert**
|
||||
* Stability: **stable**
|
||||
* Contact: codecept@davert.mail.ua
|
||||
|
||||
## Config
|
||||
|
||||
## Public Properties
|
||||
|
||||
* `em` - Entity Manager
|
||||
|
||||
## Actions
|
||||
|
||||
### dontSeeInRepository
|
||||
|
||||
Flushes changes to database and performs `findOneBy()` call for current repository.
|
||||
|
||||
* `param` $entity
|
||||
* `param array` $params
|
||||
|
||||
|
||||
### flushToDatabase
|
||||
|
||||
Performs $em->flush();
|
||||
|
||||
|
||||
### grabEntitiesFromRepository
|
||||
|
||||
Selects entities 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('AppBundle:User', array('name' => 'davert'));
|
||||
?>
|
||||
```
|
||||
|
||||
* `Available since` 1.1
|
||||
* `param` $entity
|
||||
* `param array` $params
|
||||
* `return` array
|
||||
|
||||
|
||||
### grabEntityFromRepository
|
||||
|
||||
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
|
||||
$user = $I->grabEntityFromRepository('User', array('id' => '1234'));
|
||||
?>
|
||||
```
|
||||
|
||||
* `Available since` 1.1
|
||||
* `param` $entity
|
||||
* `param array` $params
|
||||
* `return` object
|
||||
|
||||
|
||||
### 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
|
||||
|
||||
|
||||
### haveFakeRepository
|
||||
|
||||
Mocks the repository.
|
||||
|
||||
With this action you can redefine any method of any repository.
|
||||
Please, note: this fake repositories will be accessible through entity manager till the end of test.
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
$I->haveFakeRepository('Entity\User', array('findByUsername' => function($username) { return null; }));
|
||||
|
||||
```
|
||||
|
||||
This creates a stub class for Entity\User repository with redefined method findByUsername,
|
||||
which will always return the NULL value.
|
||||
|
||||
* `param` $classname
|
||||
* `param array` $methods
|
||||
|
||||
|
||||
### haveInRepository
|
||||
|
||||
Persists record into repository.
|
||||
This method creates an entity, and sets its properties directly (via reflection).
|
||||
Setters of entity won't be executed, but you can create almost any entity and save it to database.
|
||||
Returns id using `getId` of newly created entity.
|
||||
|
||||
```php
|
||||
$I->haveInRepository('Entity\User', array('name' => 'davert'));
|
||||
```
|
||||
|
||||
|
||||
### persistEntity
|
||||
|
||||
Adds entity to repository and flushes. You can redefine it's properties with the second parameter.
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->persistEntity(new \Entity\User, array('name' => 'Miles'));
|
||||
$I->persistEntity($user, array('name' => 'Miles'));
|
||||
```
|
||||
|
||||
* `param` $obj
|
||||
* `param array` $values
|
||||
|
||||
|
||||
### seeInRepository
|
||||
|
||||
Flushes changes to database, and executes a query with parameters defined in an array.
|
||||
You can use entity associations to build complex queries.
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeInRepository('AppBundle:User', array('name' => 'davert'));
|
||||
$I->seeInRepository('User', array('name' => 'davert', 'Company' => array('name' => 'Codegyre')));
|
||||
$I->seeInRepository('Client', array('User' => array('Company' => array('name' => 'Codegyre')));
|
||||
?>
|
||||
```
|
||||
|
||||
Fails if record for given criteria can\'t be found,
|
||||
|
||||
* `param` $entity
|
||||
* `param array` $params
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/Doctrine2.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
429
vendor/codeception/base/docs/modules/FTP.md
vendored
Normal file
429
vendor/codeception/base/docs/modules/FTP.md
vendored
Normal file
@@ -0,0 +1,429 @@
|
||||
# FTP
|
||||
|
||||
|
||||
|
||||
Works with SFTP/FTP servers.
|
||||
|
||||
In order to test the contents of a specific file stored on any remote FTP/SFTP system
|
||||
this module downloads a temporary file to the local system. The temporary directory is
|
||||
defined by default as ```tests/_data``` to specify a different directory set the tmp config
|
||||
option to your chosen path.
|
||||
|
||||
Don't forget to create the folder and ensure its writable.
|
||||
|
||||
Supported and tested FTP types are:
|
||||
|
||||
* FTP
|
||||
* SFTP
|
||||
|
||||
Connection uses php build in FTP client for FTP,
|
||||
connection to SFTP uses [phpseclib](http://phpseclib.sourceforge.net/) pulled in using composer.
|
||||
|
||||
For SFTP, add [phpseclib](http://phpseclib.sourceforge.net/) to require list.
|
||||
```
|
||||
"require": {
|
||||
"phpseclib/phpseclib": "0.3.6"
|
||||
}
|
||||
```
|
||||
|
||||
## Status
|
||||
|
||||
* Maintainer: **nathanmac**
|
||||
* Stability:
|
||||
- FTP: **stable**
|
||||
- SFTP: **stable**
|
||||
* Contact: nathan.macnamara@outlook.com
|
||||
|
||||
## Config
|
||||
|
||||
* type: ftp - type of connection ftp/sftp (defaults to ftp).
|
||||
* host *required* - hostname/ip address of the ftp server.
|
||||
* port: 21 - port number for the ftp server
|
||||
* timeout: 90 - timeout settings for connecting the ftp server.
|
||||
* user: anonymous - user to access ftp server, defaults to anonymous authentication.
|
||||
* password - password, defaults to empty for anonymous.
|
||||
* key - path to RSA key for sftp.
|
||||
* tmp - path to local directory for storing tmp files.
|
||||
* passive: true - Turns on or off passive mode (FTP only)
|
||||
* cleanup: true - remove tmp files from local directory on completion.
|
||||
|
||||
### Example
|
||||
#### Example (FTP)
|
||||
|
||||
modules:
|
||||
enabled: [FTP]
|
||||
config:
|
||||
FTP:
|
||||
type: ftp
|
||||
host: '127.0.0.1'
|
||||
port: 21
|
||||
timeout: 120
|
||||
user: 'root'
|
||||
password: 'root'
|
||||
key: ~/.ssh/id_rsa
|
||||
tmp: 'tests/_data/ftp'
|
||||
passive: true
|
||||
cleanup: false
|
||||
|
||||
#### Example (SFTP)
|
||||
|
||||
modules:
|
||||
enabled: [FTP]
|
||||
config:
|
||||
FTP:
|
||||
type: sftp
|
||||
host: '127.0.0.1'
|
||||
port: 22
|
||||
timeout: 120
|
||||
user: 'root'
|
||||
password: 'root'
|
||||
key: ''
|
||||
tmp: 'tests/_data/ftp'
|
||||
cleanup: false
|
||||
|
||||
|
||||
This module extends the Filesystem module, file contents methods are inherited from this module.
|
||||
|
||||
## Actions
|
||||
|
||||
### amInPath
|
||||
|
||||
Enters a directory on the ftp system - FTP root directory is used by default
|
||||
|
||||
* `param` $path
|
||||
|
||||
|
||||
### cleanDir
|
||||
|
||||
Erases directory contents on the FTP/SFTP server
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->cleanDir('logs');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $dirname
|
||||
|
||||
|
||||
### copyDir
|
||||
|
||||
Currently not supported in this module, overwrite inherited method
|
||||
|
||||
* `param` $src
|
||||
* `param` $dst
|
||||
|
||||
|
||||
### deleteDir
|
||||
|
||||
Deletes directory with all subdirectories on the remote FTP/SFTP server
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->deleteDir('vendor');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $dirname
|
||||
|
||||
|
||||
### deleteFile
|
||||
|
||||
Deletes a file on the remote FTP/SFTP system
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->deleteFile('composer.lock');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $filename
|
||||
|
||||
|
||||
### deleteThisFile
|
||||
|
||||
Deletes a file
|
||||
|
||||
|
||||
### dontSeeFileFound
|
||||
|
||||
Checks if file does not exist in path on the remote FTP/SFTP system
|
||||
|
||||
* `param` $filename
|
||||
* `param string` $path
|
||||
|
||||
|
||||
### dontSeeFileFoundMatches
|
||||
|
||||
Checks if file does not exist in path on the remote FTP/SFTP system, using regular expression as filename.
|
||||
DOES NOT OPEN the file when it's exists
|
||||
|
||||
* `param` $regex
|
||||
* `param string` $path
|
||||
|
||||
|
||||
### dontSeeInThisFile
|
||||
|
||||
Checks If opened file doesn't contain `text` in it
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->openFile('composer.json');
|
||||
$I->dontSeeInThisFile('codeception/codeception');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $text
|
||||
|
||||
|
||||
### grabDirectory
|
||||
|
||||
Grabber method to return current working directory
|
||||
|
||||
```php
|
||||
<?php
|
||||
$pwd = $I->grabDirectory();
|
||||
?>
|
||||
```
|
||||
|
||||
* `return` string
|
||||
|
||||
|
||||
### grabFileCount
|
||||
|
||||
Grabber method for returning file/folders count in directory
|
||||
|
||||
```php
|
||||
<?php
|
||||
$count = $I->grabFileCount();
|
||||
$count = $I->grabFileCount('TEST', false); // Include . .. .thumbs.db
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $path
|
||||
* `param bool` $ignore - suppress '.', '..' and '.thumbs.db'
|
||||
* `return` int
|
||||
|
||||
|
||||
### grabFileList
|
||||
|
||||
Grabber method for returning file/folders listing in an array
|
||||
|
||||
```php
|
||||
<?php
|
||||
$files = $I->grabFileList();
|
||||
$count = $I->grabFileList('TEST', false); // Include . .. .thumbs.db
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $path
|
||||
* `param bool` $ignore - suppress '.', '..' and '.thumbs.db'
|
||||
* `return` array
|
||||
|
||||
|
||||
### grabFileModified
|
||||
|
||||
Grabber method to return last modified timestamp
|
||||
|
||||
```php
|
||||
<?php
|
||||
$time = $I->grabFileModified('test.txt');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $filename
|
||||
* `return` bool
|
||||
|
||||
|
||||
### grabFileSize
|
||||
|
||||
Grabber method to return file size
|
||||
|
||||
```php
|
||||
<?php
|
||||
$size = $I->grabFileSize('test.txt');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $filename
|
||||
* `return` bool
|
||||
|
||||
|
||||
### loginAs
|
||||
|
||||
Change the logged in user mid-way through your test, this closes the
|
||||
current connection to the server and initialises and new connection.
|
||||
|
||||
On initiation of this modules you are automatically logged into
|
||||
the server using the specified config options or defaulted
|
||||
to anonymous user if not provided.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->loginAs('user','password');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param String` $user
|
||||
* `param String` $password
|
||||
|
||||
|
||||
### makeDir
|
||||
|
||||
Create a directory on the server
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->makeDir('vendor');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $dirname
|
||||
|
||||
|
||||
### openFile
|
||||
|
||||
Opens a file (downloads from the remote FTP/SFTP system to a tmp directory for processing)
|
||||
and stores it's content.
|
||||
|
||||
Usage:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->openFile('composer.json');
|
||||
$I->seeInThisFile('codeception/codeception');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $filename
|
||||
|
||||
|
||||
### renameDir
|
||||
|
||||
Rename/Move directory on the FTP/SFTP server
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->renameDir('vendor', 'vendor_old');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $dirname
|
||||
* `param` $rename
|
||||
|
||||
|
||||
### renameFile
|
||||
|
||||
Rename/Move file on the FTP/SFTP server
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->renameFile('composer.lock', 'composer_old.lock');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $filename
|
||||
* `param` $rename
|
||||
|
||||
|
||||
### seeFileContentsEqual
|
||||
|
||||
Checks the strict matching of file contents.
|
||||
Unlike `seeInThisFile` will fail if file has something more than expected lines.
|
||||
Better to use with HEREDOC strings.
|
||||
Matching is done after removing "\r" chars from file content.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->openFile('process.pid');
|
||||
$I->seeFileContentsEqual('3192');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $text
|
||||
|
||||
|
||||
### seeFileFound
|
||||
|
||||
Checks if file exists in path on the remote FTP/SFTP system.
|
||||
DOES NOT OPEN the file when it's exists
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeFileFound('UserModel.php','app/models');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $filename
|
||||
* `param string` $path
|
||||
|
||||
|
||||
### seeFileFoundMatches
|
||||
|
||||
Checks if file exists in path on the remote FTP/SFTP system, using regular expression as filename.
|
||||
DOES NOT OPEN the file when it's exists
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeFileFoundMatches('/^UserModel_([0-9]{6}).php$/','app/models');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $regex
|
||||
* `param string` $path
|
||||
|
||||
|
||||
### seeInThisFile
|
||||
|
||||
Checks If opened file has `text` in it.
|
||||
|
||||
Usage:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->openFile('composer.json');
|
||||
$I->seeInThisFile('codeception/codeception');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $text
|
||||
|
||||
|
||||
### seeNumberNewLines
|
||||
|
||||
Checks If opened file has the `number` of new lines.
|
||||
|
||||
Usage:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->openFile('composer.json');
|
||||
$I->seeNumberNewLines(5);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param int` $number New lines
|
||||
|
||||
|
||||
### seeThisFileMatches
|
||||
|
||||
Checks that contents of currently opened file matches $regex
|
||||
|
||||
* `param string` $regex
|
||||
|
||||
|
||||
### writeToFile
|
||||
|
||||
Saves contents to tmp file and uploads the FTP/SFTP system.
|
||||
Overwrites current file on server if exists.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->writeToFile('composer.json', 'some data here');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $filename
|
||||
* `param` $contents
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/FTP.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
153
vendor/codeception/base/docs/modules/Facebook.md
vendored
Normal file
153
vendor/codeception/base/docs/modules/Facebook.md
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
# Facebook
|
||||
|
||||
|
||||
Provides testing for projects integrated with Facebook API.
|
||||
Relies on Facebook's tool Test User API.
|
||||
|
||||
<div class="alert alert-info">
|
||||
To use this module with Composer you need <em>"facebook/php-sdk4": "5.*"</em> package.
|
||||
</div>
|
||||
|
||||
## Status
|
||||
|
||||
[ ](https://codeship.com/projects/160201)
|
||||
|
||||
* Stability: **beta**
|
||||
* Maintainer: **tiger-seo**
|
||||
* Contact: tiger.seo@codeception.com
|
||||
|
||||
## Config
|
||||
|
||||
* app_id *required* - Facebook application ID
|
||||
* secret *required* - Facebook application secret
|
||||
* test_user - Facebook test user parameters:
|
||||
* name - You can specify a name for the test user you create. The specified name will also be used in the email address assigned to the test user.
|
||||
* locale - You can specify a locale for the test user you create, the default is en_US. The list of supported locales is available at https://www.facebook.com/translations/FacebookLocales.xml
|
||||
* permissions - An array of permissions. Your app is granted these permissions for the new test user. The full list of permissions is available at https://developers.facebook.com/docs/authentication/permissions
|
||||
|
||||
### Config example
|
||||
|
||||
modules:
|
||||
enabled:
|
||||
- Facebook:
|
||||
depends: PhpBrowser
|
||||
app_id: 412345678901234
|
||||
secret: ccb79c1b0fdff54e4f7c928bf233aea5
|
||||
test_user:
|
||||
name: FacebookGuy
|
||||
locale: uk_UA
|
||||
permissions: [email, publish_stream]
|
||||
|
||||
### Test example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I = new ApiGuy($scenario);
|
||||
$I->am('Guest');
|
||||
$I->wantToTest('check-in to a place be published on the Facebook using API');
|
||||
$I->haveFacebookTestUserAccount();
|
||||
$accessToken = $I->grabFacebookTestUserAccessToken();
|
||||
$I->haveHttpHeader('Auth', 'FacebookToken ' . $accessToken);
|
||||
$I->amGoingTo('send request to the backend, so that it will publish on user\'s wall on Facebook');
|
||||
$I->sendPOST('/api/v1/some-api-endpoint');
|
||||
$I->seePostOnFacebookWithAttachedPlace('167724369950862');
|
||||
|
||||
```
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I = new WebGuy($scenario);
|
||||
$I->am('Guest');
|
||||
$I->wantToTest('log in to site using Facebook');
|
||||
$I->haveFacebookTestUserAccount(); // create facebook test user
|
||||
$I->haveTestUserLoggedInOnFacebook(); // so that facebook will not ask us for login and password
|
||||
$fbUserFirstName = $I->grabFacebookTestUserFirstName();
|
||||
$I->amOnPage('/welcome');
|
||||
$I->see('Welcome, Guest');
|
||||
$I->click('Login with Facebook');
|
||||
$I->see('Welcome, ' . $fbUserFirstName);
|
||||
|
||||
```
|
||||
|
||||
@since 1.6.3
|
||||
@author tiger.seo@gmail.com
|
||||
|
||||
## Actions
|
||||
|
||||
### grabFacebookTestUserAccessToken
|
||||
|
||||
Returns the test user access token.
|
||||
|
||||
* `return` string
|
||||
|
||||
|
||||
### grabFacebookTestUserEmail
|
||||
|
||||
Returns the test user email.
|
||||
|
||||
* `return` string
|
||||
|
||||
|
||||
### grabFacebookTestUserId
|
||||
|
||||
Returns the test user id.
|
||||
|
||||
* `return` string
|
||||
|
||||
|
||||
### grabFacebookTestUserLoginUrl
|
||||
|
||||
Returns URL for test user auto-login.
|
||||
|
||||
* `return` string
|
||||
|
||||
|
||||
### grabFacebookTestUserName
|
||||
|
||||
Returns the test user name.
|
||||
|
||||
* `return` string
|
||||
|
||||
|
||||
### grabFacebookTestUserPassword
|
||||
__not documented__
|
||||
|
||||
|
||||
### haveFacebookTestUserAccount
|
||||
|
||||
Get facebook test user be created.
|
||||
|
||||
*Please, note that the test user is created only at first invoke, unless $renew arguments is true.*
|
||||
|
||||
* `param bool` $renew true if the test user should be recreated
|
||||
|
||||
|
||||
### haveTestUserLoggedInOnFacebook
|
||||
|
||||
Get facebook test user be logged in on facebook.
|
||||
This is done by going to facebook.com
|
||||
|
||||
@throws ModuleConfigException
|
||||
|
||||
|
||||
### postToFacebookAsTestUser
|
||||
|
||||
Please, note that you must have publish_actions permission to be able to publish to user's feed.
|
||||
|
||||
* `param array` $params
|
||||
|
||||
|
||||
### seePostOnFacebookWithAttachedPlace
|
||||
|
||||
Please, note that you must have publish_actions permission to be able to publish to user's feed.
|
||||
|
||||
* `param string` $placeId Place identifier to be verified against user published posts
|
||||
|
||||
|
||||
### seePostOnFacebookWithMessage
|
||||
|
||||
Please, note that you must have publish_actions permission to be able to publish to user's feed.
|
||||
|
||||
* `param string` $message published post to be verified against the actual post on facebook
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/Facebook.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
199
vendor/codeception/base/docs/modules/Filesystem.md
vendored
Normal file
199
vendor/codeception/base/docs/modules/Filesystem.md
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
# Filesystem
|
||||
|
||||
|
||||
Module for testing local filesystem.
|
||||
Fork it to extend the module for FTP, Amazon S3, others.
|
||||
|
||||
## Status
|
||||
|
||||
* Maintainer: **davert**
|
||||
* Stability: **stable**
|
||||
* Contact: codecept@davert.mail.ua
|
||||
|
||||
Module was developed to test Codeception itself.
|
||||
|
||||
## Actions
|
||||
|
||||
### amInPath
|
||||
|
||||
Enters a directory In local filesystem.
|
||||
Project root directory is used by default
|
||||
|
||||
* `param string` $path
|
||||
|
||||
|
||||
### cleanDir
|
||||
|
||||
Erases directory contents
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->cleanDir('logs');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $dirname
|
||||
|
||||
|
||||
### copyDir
|
||||
|
||||
Copies directory with all contents
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->copyDir('vendor','old_vendor');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $src
|
||||
* `param string` $dst
|
||||
|
||||
|
||||
### deleteDir
|
||||
|
||||
Deletes directory with all subdirectories
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->deleteDir('vendor');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $dirname
|
||||
|
||||
|
||||
### deleteFile
|
||||
|
||||
Deletes a file
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->deleteFile('composer.lock');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $filename
|
||||
|
||||
|
||||
### deleteThisFile
|
||||
|
||||
Deletes a file
|
||||
|
||||
|
||||
### dontSeeFileFound
|
||||
|
||||
Checks if file does not exist in path
|
||||
|
||||
* `param string` $filename
|
||||
* `param string` $path
|
||||
|
||||
|
||||
### dontSeeInThisFile
|
||||
|
||||
Checks If opened file doesn't contain `text` in it
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->openFile('composer.json');
|
||||
$I->dontSeeInThisFile('codeception/codeception');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $text
|
||||
|
||||
|
||||
### openFile
|
||||
|
||||
Opens a file and stores it's content.
|
||||
|
||||
Usage:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->openFile('composer.json');
|
||||
$I->seeInThisFile('codeception/codeception');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $filename
|
||||
|
||||
|
||||
### seeFileContentsEqual
|
||||
|
||||
Checks the strict matching of file contents.
|
||||
Unlike `seeInThisFile` will fail if file has something more than expected lines.
|
||||
Better to use with HEREDOC strings.
|
||||
Matching is done after removing "\r" chars from file content.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->openFile('process.pid');
|
||||
$I->seeFileContentsEqual('3192');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $text
|
||||
|
||||
|
||||
### seeFileFound
|
||||
|
||||
Checks if file exists in path.
|
||||
Opens a file when it's exists
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeFileFound('UserModel.php','app/models');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $filename
|
||||
* `param string` $path
|
||||
|
||||
|
||||
### seeInThisFile
|
||||
|
||||
Checks If opened file has `text` in it.
|
||||
|
||||
Usage:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->openFile('composer.json');
|
||||
$I->seeInThisFile('codeception/codeception');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $text
|
||||
|
||||
|
||||
### seeNumberNewLines
|
||||
|
||||
Checks If opened file has the `number` of new lines.
|
||||
|
||||
Usage:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->openFile('composer.json');
|
||||
$I->seeNumberNewLines(5);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param int` $number New lines
|
||||
|
||||
|
||||
### seeThisFileMatches
|
||||
|
||||
Checks that contents of currently opened file matches $regex
|
||||
|
||||
* `param string` $regex
|
||||
|
||||
|
||||
### writeToFile
|
||||
|
||||
Saves contents to file
|
||||
|
||||
* `param string` $filename
|
||||
* `param string` $contents
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/Filesystem.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
1925
vendor/codeception/base/docs/modules/Laravel5.md
vendored
Normal file
1925
vendor/codeception/base/docs/modules/Laravel5.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1585
vendor/codeception/base/docs/modules/Lumen.md
vendored
Normal file
1585
vendor/codeception/base/docs/modules/Lumen.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
106
vendor/codeception/base/docs/modules/Memcache.md
vendored
Normal file
106
vendor/codeception/base/docs/modules/Memcache.md
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
# Memcache
|
||||
|
||||
|
||||
Connects to [memcached](http://www.memcached.org/) using either _Memcache_ or _Memcached_ extension.
|
||||
|
||||
Performs a cleanup by flushing all values after each test run.
|
||||
|
||||
## Status
|
||||
|
||||
* Maintainer: **davert**
|
||||
* Stability: **beta**
|
||||
* Contact: davert@codeception.com
|
||||
|
||||
## Configuration
|
||||
|
||||
* **`host`** (`string`, default `'localhost'`) - The memcached host
|
||||
* **`port`** (`int`, default `11211`) - The memcached port
|
||||
|
||||
### Example (`unit.suite.yml`)
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
- Memcache:
|
||||
host: 'localhost'
|
||||
port: 11211
|
||||
```
|
||||
|
||||
Be sure you don't use the production server to connect.
|
||||
|
||||
## Public Properties
|
||||
|
||||
* **memcache** - instance of _Memcache_ or _Memcached_ object
|
||||
|
||||
|
||||
## Actions
|
||||
|
||||
### clearMemcache
|
||||
|
||||
Flushes all Memcached data.
|
||||
|
||||
|
||||
### dontSeeInMemcached
|
||||
|
||||
Checks item in Memcached doesn't exist or is the same as expected.
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// With only one argument, only checks the key does not exist
|
||||
$I->dontSeeInMemcached('users_count');
|
||||
|
||||
// Checks a 'users_count' exists does not exist or its value is not the one provided
|
||||
$I->dontSeeInMemcached('users_count', 200);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $key
|
||||
* `param` $value
|
||||
|
||||
|
||||
### grabValueFromMemcached
|
||||
|
||||
Grabs value from memcached by key.
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$users_count = $I->grabValueFromMemcached('users_count');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $key
|
||||
* `return` array|string
|
||||
|
||||
|
||||
### haveInMemcached
|
||||
|
||||
Stores an item `$value` with `$key` on the Memcached server.
|
||||
|
||||
* `param string` $key
|
||||
* `param mixed` $value
|
||||
* `param int` $expiration
|
||||
|
||||
|
||||
### seeInMemcached
|
||||
|
||||
Checks item in Memcached exists and the same as expected.
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// With only one argument, only checks the key exists
|
||||
$I->seeInMemcached('users_count');
|
||||
|
||||
// Checks a 'users_count' exists and has the value 200
|
||||
$I->seeInMemcached('users_count', 200);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $key
|
||||
* `param` $value
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/Memcache.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
170
vendor/codeception/base/docs/modules/MongoDb.md
vendored
Normal file
170
vendor/codeception/base/docs/modules/MongoDb.md
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
# MongoDb
|
||||
|
||||
|
||||
Works with MongoDb database.
|
||||
|
||||
The most important function of this module is cleaning database before each test.
|
||||
To have your database properly cleaned you should configure it to access the database.
|
||||
|
||||
In order to have your database populated with data you need a valid js file with data (of the same style which can be fed up to mongo binary)
|
||||
File can be generated by RockMongo export command
|
||||
You can also use directory, generated by ```mongodump``` tool or it's ```.tar.gz``` archive (not available for Windows systems), generated by ```tar -czf <archive_file_name>.tar.gz <path_to dump directory>```.
|
||||
Just put it in ``` tests/_data ``` dir (by default) and specify path to it in config.
|
||||
Next time after database is cleared all your data will be restored from dump.
|
||||
The DB preparation should as following:
|
||||
- clean database
|
||||
- system collection system.users should contain the user which will be authenticated while script performs DB operations
|
||||
|
||||
Connection is done by MongoDb driver, which is stored in Codeception\Lib\Driver namespace.
|
||||
Check out the driver if you get problems loading dumps and cleaning databases.
|
||||
|
||||
HINT: This module can be used with [Mongofill](https://github.com/mongofill/mongofill) library which is Mongo client written in PHP without extension.
|
||||
|
||||
## Status
|
||||
|
||||
* Maintainer: **judgedim**, **davert**
|
||||
* Stability: **beta**
|
||||
* Contact: davert@codeception.com
|
||||
|
||||
*Please review the code of non-stable modules and provide patches if you have issues.*
|
||||
|
||||
## Config
|
||||
|
||||
* dsn *required* - MongoDb DSN with the db name specified at the end of the host after slash
|
||||
* user *required* - user to access database
|
||||
* password *required* - password
|
||||
* dump_type *required* - type of dump.
|
||||
One of 'js' (MongoDb::DUMP_TYPE_JS), 'mongodump' (MongoDb::DUMP_TYPE_MONGODUMP) or 'mongodump-tar-gz' (MongoDb::DUMP_TYPE_MONGODUMP_TAR_GZ).
|
||||
default: MongoDb::DUMP_TYPE_JS).
|
||||
* dump - path to database dump
|
||||
* populate: true - should the dump be loaded before test suite is started.
|
||||
* cleanup: true - should the dump be reloaded after each test
|
||||
|
||||
|
||||
## Actions
|
||||
|
||||
### dontSeeInCollection
|
||||
|
||||
Checks if collection doesn't contain an item.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->dontSeeInCollection('users', array('name' => 'miles'));
|
||||
```
|
||||
|
||||
* `param` $collection
|
||||
* `param array` $criteria
|
||||
|
||||
|
||||
### grabCollectionCount
|
||||
|
||||
Grabs the documents count from a collection
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$count = $I->grabCollectionCount('users');
|
||||
// or
|
||||
$count = $I->grabCollectionCount('users', array('isAdmin' => true));
|
||||
```
|
||||
|
||||
* `param` $collection
|
||||
* `param array` $criteria
|
||||
* `return` integer
|
||||
|
||||
|
||||
### grabFromCollection
|
||||
|
||||
Grabs a data from collection
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$user = $I->grabFromCollection('users', array('name' => 'miles'));
|
||||
```
|
||||
|
||||
* `param` $collection
|
||||
* `param array` $criteria
|
||||
* `return` array
|
||||
|
||||
|
||||
### haveInCollection
|
||||
|
||||
Inserts data into collection
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->haveInCollection('users', array('name' => 'John', 'email' => 'john@coltrane.com'));
|
||||
$user_id = $I->haveInCollection('users', array('email' => 'john@coltrane.com'));
|
||||
```
|
||||
|
||||
* `param` $collection
|
||||
* `param array` $data
|
||||
|
||||
|
||||
### seeElementIsArray
|
||||
|
||||
Asserts that an element in a collection exists and is an Array
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeElementIsArray('users', array('name' => 'John Doe') , 'data.skills');
|
||||
```
|
||||
|
||||
* `param String` $collection
|
||||
* `param Array` $criteria
|
||||
* `param String` $elementToCheck
|
||||
|
||||
|
||||
### seeElementIsObject
|
||||
|
||||
Asserts that an element in a collection exists and is an Object
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeElementIsObject('users', array('name' => 'John Doe') , 'data');
|
||||
```
|
||||
|
||||
* `param String` $collection
|
||||
* `param Array` $criteria
|
||||
* `param String` $elementToCheck
|
||||
|
||||
|
||||
### seeInCollection
|
||||
|
||||
Checks if collection contains an item.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeInCollection('users', array('name' => 'miles'));
|
||||
```
|
||||
|
||||
* `param` $collection
|
||||
* `param array` $criteria
|
||||
|
||||
|
||||
### seeNumElementsInCollection
|
||||
|
||||
Count number of records in a collection
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeNumElementsInCollection('users', 2);
|
||||
$I->seeNumElementsInCollection('users', 1, array('name' => 'miles'));
|
||||
```
|
||||
|
||||
* `param` $collection
|
||||
* `param integer` $expected
|
||||
* `param array` $criteria
|
||||
|
||||
|
||||
### useDatabase
|
||||
|
||||
Specify the database to use
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->useDatabase('db_1');
|
||||
```
|
||||
|
||||
* `param` $dbName
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/MongoDb.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
1526
vendor/codeception/base/docs/modules/Phalcon.md
vendored
Normal file
1526
vendor/codeception/base/docs/modules/Phalcon.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1397
vendor/codeception/base/docs/modules/PhpBrowser.md
vendored
Normal file
1397
vendor/codeception/base/docs/modules/PhpBrowser.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
297
vendor/codeception/base/docs/modules/Queue.md
vendored
Normal file
297
vendor/codeception/base/docs/modules/Queue.md
vendored
Normal file
@@ -0,0 +1,297 @@
|
||||
# Queue
|
||||
|
||||
|
||||
|
||||
Works with Queue servers.
|
||||
|
||||
Testing with a selection of remote/local queueing services, including Amazon's SQS service
|
||||
Iron.io service and beanstalkd service.
|
||||
|
||||
Supported and tested queue types are:
|
||||
|
||||
* [Iron.io](http://iron.io/)
|
||||
* [Beanstalkd](http://kr.github.io/beanstalkd/)
|
||||
* [Amazon SQS](http://aws.amazon.com/sqs/)
|
||||
|
||||
The following dependencies are needed for the listed queue servers:
|
||||
|
||||
* Beanstalkd: pda/pheanstalk ~3.0
|
||||
* Amazon SQS: aws/aws-sdk-php
|
||||
* IronMQ: iron-io/iron_mq
|
||||
|
||||
## Status
|
||||
|
||||
* Maintainer: **nathanmac**
|
||||
* Stability:
|
||||
- Iron.io: **stable**
|
||||
- Beanstalkd: **stable**
|
||||
- Amazon SQS: **stable**
|
||||
* Contact: nathan.macnamara@outlook.com
|
||||
|
||||
## Config
|
||||
|
||||
The configuration settings depending on which queueing service is being used, all the options are listed
|
||||
here. Refer to the configuration examples below to identify the configuration options required for your chosen
|
||||
service.
|
||||
|
||||
* type - type of queueing server (defaults to beanstalkd).
|
||||
* host - hostname/ip address of the queue server or the host for the iron.io when using iron.io service.
|
||||
* port: 11300 - port number for the queue server.
|
||||
* timeout: 90 - timeout settings for connecting the queue server.
|
||||
* token - Iron.io access token.
|
||||
* project - Iron.io project ID.
|
||||
* key - AWS access key ID.
|
||||
* version - AWS version (e.g. latest)
|
||||
* endpoint - The full URI of the webservice. This is only required when connecting to a custom endpoint (e.g., a local version of SQS).
|
||||
* secret - AWS secret access key.
|
||||
Warning:
|
||||
Hard-coding your credentials can be dangerous, because it is easy to accidentally commit your credentials
|
||||
into an SCM repository, potentially exposing your credentials to more people than intended.
|
||||
It can also make it difficult to rotate credentials in the future.
|
||||
* profile - AWS credential profile
|
||||
- it should be located in ~/.aws/credentials file
|
||||
- eg: [default]
|
||||
aws_access_key_id = YOUR_AWS_ACCESS_KEY_ID
|
||||
aws_secret_access_key = YOUR_AWS_SECRET_ACCESS_KEY
|
||||
[project1]
|
||||
aws_access_key_id = YOUR_AWS_ACCESS_KEY_ID
|
||||
aws_secret_access_key = YOUR_AWS_SECRET_ACCESS_KEY
|
||||
- Note: Using IAM roles is the preferred technique for providing credentials
|
||||
to applications running on Amazon EC2
|
||||
http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html?highlight=credentials
|
||||
|
||||
* region - A region parameter is also required for AWS, refer to the AWS documentation for possible values list.
|
||||
|
||||
### Example
|
||||
#### Example (beanstalkd)
|
||||
|
||||
modules:
|
||||
enabled: [Queue]
|
||||
config:
|
||||
Queue:
|
||||
type: 'beanstalkd'
|
||||
host: '127.0.0.1'
|
||||
port: 11300
|
||||
timeout: 120
|
||||
|
||||
#### Example (Iron.io)
|
||||
|
||||
modules:
|
||||
enabled: [Queue]
|
||||
config:
|
||||
Queue:
|
||||
'type': 'iron',
|
||||
'host': 'mq-aws-us-east-1.iron.io',
|
||||
'token': 'your-token',
|
||||
'project': 'your-project-id'
|
||||
|
||||
#### Example (AWS SQS)
|
||||
|
||||
modules:
|
||||
enabled: [Queue]
|
||||
config:
|
||||
Queue:
|
||||
'type': 'aws',
|
||||
'key': 'your-public-key',
|
||||
'secret': 'your-secret-key',
|
||||
'region': 'us-west-2'
|
||||
|
||||
#### Example AWS SQS using profile credentials
|
||||
|
||||
modules:
|
||||
enabled: [Queue]
|
||||
config:
|
||||
Queue:
|
||||
'type': 'aws',
|
||||
'profile': 'project1', //see documentation
|
||||
'region': 'us-west-2'
|
||||
|
||||
#### Example AWS SQS running on Amazon EC2 instance
|
||||
|
||||
modules:
|
||||
enabled: [Queue]
|
||||
config:
|
||||
Queue:
|
||||
'type': 'aws',
|
||||
'region': 'us-west-2'
|
||||
|
||||
|
||||
## Actions
|
||||
|
||||
### addMessageToQueue
|
||||
|
||||
Add a message to a queue/tube
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->addMessageToQueue('this is a messages', 'default');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $message Message Body
|
||||
* `param string` $queue Queue Name
|
||||
|
||||
|
||||
### clearQueue
|
||||
|
||||
Clear all messages of the queue/tube
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->clearQueue('default');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue Queue Name
|
||||
|
||||
|
||||
### dontSeeEmptyQueue
|
||||
|
||||
Check if a queue/tube is NOT empty of all messages
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->dontSeeEmptyQueue('default');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue Queue Name
|
||||
|
||||
|
||||
### dontSeeQueueExists
|
||||
|
||||
Check if a queue/tube does NOT exist on the queueing server.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->dontSeeQueueExists('default');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue Queue Name
|
||||
|
||||
|
||||
### dontSeeQueueHasCurrentCount
|
||||
|
||||
Check if a queue/tube does NOT have a given current number of messages
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->dontSeeQueueHasCurrentCount('default', 10);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue Queue Name
|
||||
* `param int` $expected Number of messages expected
|
||||
|
||||
|
||||
### dontSeeQueueHasTotalCount
|
||||
|
||||
Check if a queue/tube does NOT have a given total number of messages
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->dontSeeQueueHasTotalCount('default', 10);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue Queue Name
|
||||
* `param int` $expected Number of messages expected
|
||||
|
||||
|
||||
### grabQueueCurrentCount
|
||||
|
||||
Grabber method to get the current number of messages on the queue/tube (pending/ready)
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->grabQueueCurrentCount('default');
|
||||
?>
|
||||
```
|
||||
* `param string` $queue Queue Name
|
||||
|
||||
* `return` int Count
|
||||
|
||||
|
||||
### grabQueueTotalCount
|
||||
|
||||
Grabber method to get the total number of messages on the queue/tube
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->grabQueueTotalCount('default');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $queue Queue Name
|
||||
|
||||
* `return` int Count
|
||||
|
||||
|
||||
### grabQueues
|
||||
|
||||
Grabber method to get the list of queues/tubes on the server
|
||||
|
||||
```php
|
||||
<?php
|
||||
$queues = $I->grabQueues();
|
||||
?>
|
||||
```
|
||||
|
||||
* `return` array List of Queues/Tubes
|
||||
|
||||
|
||||
### seeEmptyQueue
|
||||
|
||||
Check if a queue/tube is empty of all messages
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeEmptyQueue('default');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue Queue Name
|
||||
|
||||
|
||||
### seeQueueExists
|
||||
|
||||
Check if a queue/tube exists on the queueing server.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeQueueExists('default');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue Queue Name
|
||||
|
||||
|
||||
### seeQueueHasCurrentCount
|
||||
|
||||
Check if a queue/tube has a given current number of messages
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeQueueHasCurrentCount('default', 10);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue Queue Name
|
||||
* `param int` $expected Number of messages expected
|
||||
|
||||
|
||||
### seeQueueHasTotalCount
|
||||
|
||||
Check if a queue/tube has a given total number of messages
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeQueueHasTotalCount('default', 10);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $queue Queue Name
|
||||
* `param int` $expected Number of messages expected
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/Queue.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
887
vendor/codeception/base/docs/modules/REST.md
vendored
Normal file
887
vendor/codeception/base/docs/modules/REST.md
vendored
Normal file
@@ -0,0 +1,887 @@
|
||||
# REST
|
||||
|
||||
|
||||
Module for testing REST WebService.
|
||||
|
||||
This module can be used either with frameworks or PHPBrowser.
|
||||
If a framework module is connected, the testing will occur in the application directly.
|
||||
Otherwise, a PHPBrowser should be specified as a dependency to send requests and receive responses from a server.
|
||||
|
||||
## Configuration
|
||||
|
||||
* url *optional* - the url of api
|
||||
|
||||
This module requires PHPBrowser or any of Framework modules enabled.
|
||||
|
||||
### Example
|
||||
|
||||
modules:
|
||||
enabled:
|
||||
- REST:
|
||||
depends: PhpBrowser
|
||||
url: 'http://serviceapp/api/v1/'
|
||||
|
||||
## Public Properties
|
||||
|
||||
* headers - array of headers going to be sent.
|
||||
* params - array of sent data
|
||||
* response - last response (string)
|
||||
|
||||
## Parts
|
||||
|
||||
* Json - actions for validating Json responses (no Xml responses)
|
||||
* Xml - actions for validating XML responses (no Json responses)
|
||||
|
||||
## Conflicts
|
||||
|
||||
Conflicts with SOAP module
|
||||
|
||||
|
||||
## Actions
|
||||
|
||||
### amAWSAuthenticated
|
||||
|
||||
Allows to send REST request using AWS Authorization
|
||||
Only works with PhpBrowser
|
||||
Example
|
||||
Config -
|
||||
|
||||
modules:
|
||||
enabled:
|
||||
- REST:
|
||||
aws:
|
||||
key: accessKey
|
||||
secret: accessSecret
|
||||
service: awsService
|
||||
region: awsRegion
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->amAWSAuthenticated();
|
||||
?>
|
||||
```
|
||||
* `param array` $additionalAWSConfig
|
||||
@throws ModuleException
|
||||
|
||||
|
||||
### amBearerAuthenticated
|
||||
|
||||
Adds Bearer authentication via access token.
|
||||
|
||||
* `param` $accessToken
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### amDigestAuthenticated
|
||||
|
||||
Adds Digest authentication via username/password.
|
||||
|
||||
* `param` $username
|
||||
* `param` $password
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### amHttpAuthenticated
|
||||
|
||||
Adds HTTP authentication via username/password.
|
||||
|
||||
* `param` $username
|
||||
* `param` $password
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### amNTLMAuthenticated
|
||||
|
||||
Adds NTLM authentication via username/password.
|
||||
Requires client to be Guzzle >=6.3.0
|
||||
Out of scope for functional modules.
|
||||
|
||||
Example:
|
||||
```php
|
||||
<?php
|
||||
$I->amNTLMAuthenticated('jon_snow', 'targaryen');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $username
|
||||
* `param` $password
|
||||
@throws ModuleException
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### deleteHeader
|
||||
|
||||
Deletes the header with the passed name. Subsequent requests
|
||||
will not have the deleted header in its request.
|
||||
|
||||
Example:
|
||||
```php
|
||||
<?php
|
||||
$I->haveHttpHeader('X-Requested-With', 'Codeception');
|
||||
$I->sendGET('test-headers.php');
|
||||
// ...
|
||||
$I->deleteHeader('X-Requested-With');
|
||||
$I->sendPOST('some-other-page.php');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $name the name of the header to delete.
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### dontSeeBinaryResponseEquals
|
||||
|
||||
Checks if the hash of a binary response is not the same as provided.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->dontSeeBinaryResponseEquals("8c90748342f19b195b9c6b4eff742ded");
|
||||
?>
|
||||
```
|
||||
Opposite to `seeBinaryResponseEquals`
|
||||
|
||||
* `param` $hash the hashed data response expected
|
||||
* `param` $algo the hash algorithm to use. Default md5.
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### dontSeeHttpHeader
|
||||
|
||||
Checks over the given HTTP header and (optionally)
|
||||
its value, asserting that are not there
|
||||
|
||||
* `param` $name
|
||||
* `param` $value
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### dontSeeResponseCodeIs
|
||||
|
||||
Checks that response code is not equal to provided value.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->dontSeeResponseCodeIs(200);
|
||||
|
||||
// preferred to use \Codeception\Util\HttpCode
|
||||
$I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK);
|
||||
```
|
||||
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
* `param` $code
|
||||
|
||||
|
||||
### dontSeeResponseContains
|
||||
|
||||
Checks whether last response do not contain text.
|
||||
|
||||
* `param` $text
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### dontSeeResponseContainsJson
|
||||
|
||||
Opposite to seeResponseContainsJson
|
||||
|
||||
* `[Part]` json
|
||||
* `param array` $json
|
||||
|
||||
|
||||
### dontSeeResponseJsonMatchesJsonPath
|
||||
|
||||
Opposite to seeResponseJsonMatchesJsonPath
|
||||
|
||||
* `param string` $jsonPath
|
||||
* `[Part]` json
|
||||
|
||||
|
||||
### dontSeeResponseJsonMatchesXpath
|
||||
|
||||
Opposite to seeResponseJsonMatchesXpath
|
||||
|
||||
* `param string` $xpath
|
||||
* `[Part]` json
|
||||
|
||||
|
||||
### dontSeeResponseMatchesJsonType
|
||||
|
||||
Opposite to `seeResponseMatchesJsonType`.
|
||||
|
||||
* `[Part]` json
|
||||
@see seeResponseMatchesJsonType
|
||||
* `param` $jsonType jsonType structure
|
||||
* `param null` $jsonPath optionally set specific path to structure with JsonPath
|
||||
* `Available since` 2.1.3
|
||||
|
||||
|
||||
### dontSeeXmlResponseEquals
|
||||
|
||||
Checks XML response does not equal to provided XML.
|
||||
Comparison is done by canonicalizing both xml`s.
|
||||
|
||||
Parameter can be passed either as XmlBuilder, DOMDocument, DOMNode, XML string, or array (if no attributes).
|
||||
|
||||
* `param` $xml
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### dontSeeXmlResponseIncludes
|
||||
|
||||
Checks XML response does not include provided XML.
|
||||
Comparison is done by canonicalizing both xml`s.
|
||||
Parameter can be passed either as XmlBuilder, DOMDocument, DOMNode, XML string, or array (if no attributes).
|
||||
|
||||
* `param` $xml
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### dontSeeXmlResponseMatchesXpath
|
||||
|
||||
Checks whether XML response does not match XPath
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->dontSeeXmlResponseMatchesXpath('//root/user[@id=1]');
|
||||
```
|
||||
* `[Part]` xml
|
||||
* `param` $xpath
|
||||
|
||||
|
||||
### grabAttributeFromXmlElement
|
||||
|
||||
Finds and returns attribute of element.
|
||||
Element is matched by either CSS or XPath
|
||||
|
||||
* `param` $cssOrXPath
|
||||
* `param` $attribute
|
||||
* `return` string
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### grabDataFromJsonResponse
|
||||
|
||||
Deprecated since 2.0.9 and removed since 2.1.0
|
||||
|
||||
* `param` $path
|
||||
@throws ModuleException
|
||||
@deprecated
|
||||
|
||||
|
||||
### grabDataFromResponseByJsonPath
|
||||
|
||||
Returns data from the current JSON response using [JSONPath](http://goessner.net/articles/JsonPath/) as selector.
|
||||
JsonPath is XPath equivalent for querying Json structures.
|
||||
Try your JsonPath expressions [online](http://jsonpath.curiousconcept.com/).
|
||||
Even for a single value an array is returned.
|
||||
|
||||
This method **require [`flow/jsonpath` > 0.2](https://github.com/FlowCommunications/JSONPath/) library to be installed**.
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// match the first `user.id` in json
|
||||
$firstUserId = $I->grabDataFromResponseByJsonPath('$..users[0].id');
|
||||
$I->sendPUT('/user', array('id' => $firstUserId[0], 'name' => 'davert'));
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $jsonPath
|
||||
* `return` array Array of matching items
|
||||
* `Available since` 2.0.9
|
||||
@throws \Exception
|
||||
* `[Part]` json
|
||||
|
||||
|
||||
### grabHttpHeader
|
||||
|
||||
Returns the value of the specified header name
|
||||
|
||||
* `param` $name
|
||||
* `param Boolean` $first Whether to return the first value or all header values
|
||||
|
||||
* `return string|array The first header value if` $first is true, an array of values otherwise
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### grabResponse
|
||||
|
||||
Returns current response so that it can be used in next scenario steps.
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$user_id = $I->grabResponse();
|
||||
$I->sendPUT('/user', array('id' => $user_id, 'name' => 'davert'));
|
||||
?>
|
||||
```
|
||||
|
||||
* `Available since` 1.1
|
||||
* `return` string
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### grabTextContentFromXmlElement
|
||||
|
||||
Finds and returns text contents of element.
|
||||
Element is matched by either CSS or XPath
|
||||
|
||||
* `param` $cssOrXPath
|
||||
* `return` string
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### haveHttpHeader
|
||||
|
||||
Sets HTTP header valid for all next requests. Use `deleteHeader` to unset it
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->haveHttpHeader('Content-Type', 'application/json');
|
||||
// all next requests will contain this header
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $name
|
||||
* `param` $value
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### seeBinaryResponseEquals
|
||||
|
||||
Checks if the hash of a binary response is exactly the same as provided.
|
||||
Parameter can be passed as any hash string supported by hash(), with an
|
||||
optional second parameter to specify the hash type, which defaults to md5.
|
||||
|
||||
Example: Using md5 hash key
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeBinaryResponseEquals("8c90748342f19b195b9c6b4eff742ded");
|
||||
?>
|
||||
```
|
||||
|
||||
Example: Using md5 for a file contents
|
||||
|
||||
```php
|
||||
<?php
|
||||
$fileData = file_get_contents("test_file.jpg");
|
||||
$I->seeBinaryResponseEquals(md5($fileData));
|
||||
?>
|
||||
```
|
||||
Example: Using sha256 hash
|
||||
|
||||
```php
|
||||
<?php
|
||||
$fileData = '/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k='; // very small jpeg
|
||||
$I->seeBinaryResponseEquals(hash("sha256", base64_decode($fileData)), 'sha256');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $hash the hashed data response expected
|
||||
* `param` $algo the hash algorithm to use. Default md5.
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### seeHttpHeader
|
||||
|
||||
Checks over the given HTTP header and (optionally)
|
||||
its value, asserting that are there
|
||||
|
||||
* `param` $name
|
||||
* `param` $value
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### seeHttpHeaderOnce
|
||||
|
||||
Checks that http response header is received only once.
|
||||
HTTP RFC2616 allows multiple response headers with the same name.
|
||||
You can check that you didn't accidentally sent the same header twice.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeHttpHeaderOnce('Cache-Control');
|
||||
?>>
|
||||
```
|
||||
|
||||
* `param` $name
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### seeResponseCodeIs
|
||||
|
||||
Checks response code equals to provided value.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeResponseCodeIs(200);
|
||||
|
||||
// preferred to use \Codeception\Util\HttpCode
|
||||
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
|
||||
```
|
||||
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
* `param` $code
|
||||
|
||||
|
||||
### seeResponseCodeIsClientError
|
||||
|
||||
Checks that the response code is 4xx
|
||||
|
||||
|
||||
### seeResponseCodeIsRedirection
|
||||
|
||||
Checks that the response code 3xx
|
||||
|
||||
|
||||
### seeResponseCodeIsServerError
|
||||
|
||||
Checks that the response code is 5xx
|
||||
|
||||
|
||||
### seeResponseCodeIsSuccessful
|
||||
|
||||
Checks that the response code is 2xx
|
||||
|
||||
|
||||
### seeResponseContains
|
||||
|
||||
Checks whether the last response contains text.
|
||||
|
||||
* `param` $text
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### seeResponseContainsJson
|
||||
|
||||
Checks whether the last JSON response contains provided array.
|
||||
The response is converted to array with json_decode($response, true)
|
||||
Thus, JSON is represented by associative array.
|
||||
This method matches that response array contains provided array.
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// response: {name: john, email: john@gmail.com}
|
||||
$I->seeResponseContainsJson(array('name' => 'john'));
|
||||
|
||||
// response {user: john, profile: { email: john@gmail.com }}
|
||||
$I->seeResponseContainsJson(array('email' => 'john@gmail.com'));
|
||||
|
||||
?>
|
||||
```
|
||||
|
||||
This method recursively checks if one array can be found inside of another.
|
||||
|
||||
* `param array` $json
|
||||
* `[Part]` json
|
||||
|
||||
|
||||
### seeResponseEquals
|
||||
|
||||
Checks if response is exactly the same as provided.
|
||||
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
* `param` $response
|
||||
|
||||
|
||||
### seeResponseIsJson
|
||||
|
||||
Checks whether last response was valid JSON.
|
||||
This is done with json_last_error function.
|
||||
|
||||
* `[Part]` json
|
||||
|
||||
|
||||
### seeResponseIsXml
|
||||
|
||||
Checks whether last response was valid XML.
|
||||
This is done with libxml_get_last_error function.
|
||||
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### seeResponseJsonMatchesJsonPath
|
||||
|
||||
Checks if json structure in response matches [JsonPath](http://goessner.net/articles/JsonPath/).
|
||||
JsonPath is XPath equivalent for querying Json structures.
|
||||
Try your JsonPath expressions [online](http://jsonpath.curiousconcept.com/).
|
||||
This assertion allows you to check the structure of response json.
|
||||
|
||||
This method **require [`flow/jsonpath` > 0.2](https://github.com/FlowCommunications/JSONPath/) library to be installed**.
|
||||
|
||||
```json
|
||||
{ "store": {
|
||||
"book": [
|
||||
{ "category": "reference",
|
||||
"author": "Nigel Rees",
|
||||
"title": "Sayings of the Century",
|
||||
"price": 8.95
|
||||
},
|
||||
{ "category": "fiction",
|
||||
"author": "Evelyn Waugh",
|
||||
"title": "Sword of Honour",
|
||||
"price": 12.99
|
||||
}
|
||||
],
|
||||
"bicycle": {
|
||||
"color": "red",
|
||||
"price": 19.95
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```php
|
||||
<?php
|
||||
// at least one book in store has author
|
||||
$I->seeResponseJsonMatchesJsonPath('$.store.book[*].author');
|
||||
// first book in store has author
|
||||
$I->seeResponseJsonMatchesJsonPath('$.store.book[0].author');
|
||||
// at least one item in store has price
|
||||
$I->seeResponseJsonMatchesJsonPath('$.store..price');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $jsonPath
|
||||
* `[Part]` json
|
||||
* `Available since` 2.0.9
|
||||
|
||||
|
||||
### seeResponseJsonMatchesXpath
|
||||
|
||||
Checks if json structure in response matches the xpath provided.
|
||||
JSON is not supposed to be checked against XPath, yet it can be converted to xml and used with XPath.
|
||||
This assertion allows you to check the structure of response json.
|
||||
*
|
||||
```json
|
||||
{ "store": {
|
||||
"book": [
|
||||
{ "category": "reference",
|
||||
"author": "Nigel Rees",
|
||||
"title": "Sayings of the Century",
|
||||
"price": 8.95
|
||||
},
|
||||
{ "category": "fiction",
|
||||
"author": "Evelyn Waugh",
|
||||
"title": "Sword of Honour",
|
||||
"price": 12.99
|
||||
}
|
||||
],
|
||||
"bicycle": {
|
||||
"color": "red",
|
||||
"price": 19.95
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```php
|
||||
<?php
|
||||
// at least one book in store has author
|
||||
$I->seeResponseJsonMatchesXpath('//store/book/author');
|
||||
// first book in store has author
|
||||
$I->seeResponseJsonMatchesXpath('//store/book[1]/author');
|
||||
// at least one item in store has price
|
||||
$I->seeResponseJsonMatchesXpath('/store//price');
|
||||
?>
|
||||
```
|
||||
* `param string` $xpath
|
||||
* `[Part]` json
|
||||
* `Available since` 2.0.9
|
||||
|
||||
|
||||
### seeResponseMatchesJsonType
|
||||
|
||||
Checks that Json matches provided types.
|
||||
In case you don't know the actual values of JSON data returned you can match them by type.
|
||||
Starts check with a root element. If JSON data is array it will check the first element of an array.
|
||||
You can specify the path in the json which should be checked with JsonPath
|
||||
|
||||
Basic example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// {'user_id': 1, 'name': 'davert', 'is_active': false}
|
||||
$I->seeResponseMatchesJsonType([
|
||||
'user_id' => 'integer',
|
||||
'name' => 'string|null',
|
||||
'is_active' => 'boolean'
|
||||
]);
|
||||
|
||||
// narrow down matching with JsonPath:
|
||||
// {"users": [{ "name": "davert"}, {"id": 1}]}
|
||||
$I->seeResponseMatchesJsonType(['name' => 'string'], '$.users[0]');
|
||||
?>
|
||||
```
|
||||
|
||||
In this case you can match that record contains fields with data types you expected.
|
||||
The list of possible data types:
|
||||
|
||||
* string
|
||||
* integer
|
||||
* float
|
||||
* array (json object is array as well)
|
||||
* boolean
|
||||
|
||||
You can also use nested data type structures:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// {'user_id': 1, 'name': 'davert', 'company': {'name': 'Codegyre'}}
|
||||
$I->seeResponseMatchesJsonType([
|
||||
'user_id' => 'integer|string', // multiple types
|
||||
'company' => ['name' => 'string']
|
||||
]);
|
||||
?>
|
||||
```
|
||||
|
||||
You can also apply filters to check values. Filter can be applied with `:` char after the type declaration.
|
||||
|
||||
Here is the list of possible filters:
|
||||
|
||||
* `integer:>{val}` - checks that integer is greater than {val} (works with float and string types too).
|
||||
* `integer:<{val}` - checks that integer is lower than {val} (works with float and string types too).
|
||||
* `string:url` - checks that value is valid url.
|
||||
* `string:date` - checks that value is date in JavaScript format: https://weblog.west-wind.com/posts/2014/Jan/06/JavaScript-JSON-Date-Parsing-and-real-Dates
|
||||
* `string:email` - checks that value is a valid email according to http://emailregex.com/
|
||||
* `string:regex({val})` - checks that string matches a regex provided with {val}
|
||||
|
||||
This is how filters can be used:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// {'user_id': 1, 'email' => 'davert@codeception.com'}
|
||||
$I->seeResponseMatchesJsonType([
|
||||
'user_id' => 'string:>0:<1000', // multiple filters can be used
|
||||
'email' => 'string:regex(~\@~)' // we just check that @ char is included
|
||||
]);
|
||||
|
||||
// {'user_id': '1'}
|
||||
$I->seeResponseMatchesJsonType([
|
||||
'user_id' => 'string:>0', // works with strings as well
|
||||
}
|
||||
?>
|
||||
```
|
||||
|
||||
You can also add custom filters y accessing `JsonType::addCustomFilter` method.
|
||||
See [JsonType reference](http://codeception.com/docs/reference/JsonType).
|
||||
|
||||
* `[Part]` json
|
||||
* `Available since` 2.1.3
|
||||
* `param array` $jsonType
|
||||
* `param string` $jsonPath
|
||||
|
||||
|
||||
### seeXmlResponseEquals
|
||||
|
||||
Checks XML response equals provided XML.
|
||||
Comparison is done by canonicalizing both xml`s.
|
||||
|
||||
Parameters can be passed either as DOMDocument, DOMNode, XML string, or array (if no attributes).
|
||||
|
||||
* `param` $xml
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### seeXmlResponseIncludes
|
||||
|
||||
Checks XML response includes provided XML.
|
||||
Comparison is done by canonicalizing both xml`s.
|
||||
Parameter can be passed either as XmlBuilder, DOMDocument, DOMNode, XML string, or array (if no attributes).
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeXmlResponseIncludes("<result>1</result>");
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $xml
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### seeXmlResponseMatchesXpath
|
||||
|
||||
Checks whether XML response matches XPath
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->seeXmlResponseMatchesXpath('//root/user[@id=1]');
|
||||
```
|
||||
* `[Part]` xml
|
||||
* `param` $xpath
|
||||
|
||||
|
||||
### sendDELETE
|
||||
|
||||
Sends DELETE request to given uri.
|
||||
|
||||
* `param` $url
|
||||
* `param array` $params
|
||||
* `param array` $files
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### sendGET
|
||||
|
||||
Sends a GET request to given uri.
|
||||
|
||||
* `param` $url
|
||||
* `param array` $params
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### sendHEAD
|
||||
|
||||
Sends a HEAD request to given uri.
|
||||
|
||||
* `param` $url
|
||||
* `param array` $params
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### sendLINK
|
||||
|
||||
Sends LINK request to given uri.
|
||||
|
||||
* `param` $url
|
||||
* `param array` $linkEntries (entry is array with keys "uri" and "link-param")
|
||||
|
||||
@link http://tools.ietf.org/html/rfc2068#section-19.6.2.4
|
||||
|
||||
@author samva.ua@gmail.com
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### sendOPTIONS
|
||||
|
||||
Sends an OPTIONS request to given uri.
|
||||
|
||||
* `param` $url
|
||||
* `param array` $params
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### sendPATCH
|
||||
|
||||
Sends PATCH request to given uri.
|
||||
|
||||
* `param` $url
|
||||
* `param array` $params
|
||||
* `param array` $files
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### sendPOST
|
||||
|
||||
Sends a POST request to given uri. Parameters and files can be provided separately.
|
||||
|
||||
Example:
|
||||
```php
|
||||
<?php
|
||||
//simple POST call
|
||||
$I->sendPOST('/message', ['subject' => 'Read this!', 'to' => 'johndoe@example.com']);
|
||||
//simple upload method
|
||||
$I->sendPOST('/message/24', ['inline' => 0], ['attachmentFile' => codecept_data_dir('sample_file.pdf')]);
|
||||
//uploading a file with a custom name and mime-type. This is also useful to simulate upload errors.
|
||||
$I->sendPOST('/message/24', ['inline' => 0], [
|
||||
'attachmentFile' => [
|
||||
'name' => 'document.pdf',
|
||||
'type' => 'application/pdf',
|
||||
'error' => UPLOAD_ERR_OK,
|
||||
'size' => filesize(codecept_data_dir('sample_file.pdf')),
|
||||
'tmp_name' => codecept_data_dir('sample_file.pdf')
|
||||
]
|
||||
]);
|
||||
```
|
||||
|
||||
* `param` $url
|
||||
* `param array|\JsonSerializable` $params
|
||||
* `param array` $files A list of filenames or "mocks" of $_FILES (each entry being an array with the following
|
||||
keys: name, type, error, size, tmp_name (pointing to the real file path). Each key works
|
||||
as the "name" attribute of a file input field.
|
||||
|
||||
@see http://php.net/manual/en/features.file-upload.post-method.php
|
||||
@see codecept_data_dir()
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### sendPUT
|
||||
|
||||
Sends PUT request to given uri.
|
||||
|
||||
* `param` $url
|
||||
* `param array` $params
|
||||
* `param array` $files
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### sendUNLINK
|
||||
|
||||
Sends UNLINK request to given uri.
|
||||
|
||||
* `param` $url
|
||||
* `param array` $linkEntries (entry is array with keys "uri" and "link-param")
|
||||
@link http://tools.ietf.org/html/rfc2068#section-19.6.2.4
|
||||
@author samva.ua@gmail.com
|
||||
* `[Part]` json
|
||||
* `[Part]` xml
|
||||
|
||||
|
||||
### startFollowingRedirects
|
||||
|
||||
Enables automatic redirects to be followed by the client
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->startFollowingRedirects();
|
||||
```
|
||||
|
||||
* `[Part]` xml
|
||||
* `[Part]` json
|
||||
|
||||
|
||||
### stopFollowingRedirects
|
||||
|
||||
Prevents automatic redirects to be followed by the client
|
||||
|
||||
```php
|
||||
<?php
|
||||
$I->stopFollowingRedirects();
|
||||
```
|
||||
|
||||
* `[Part]` xml
|
||||
* `[Part]` json
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/REST.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
285
vendor/codeception/base/docs/modules/Redis.md
vendored
Normal file
285
vendor/codeception/base/docs/modules/Redis.md
vendored
Normal file
@@ -0,0 +1,285 @@
|
||||
# Redis
|
||||
|
||||
|
||||
This module uses the [Predis](https://github.com/nrk/predis) library
|
||||
to interact with a Redis server.
|
||||
|
||||
## Status
|
||||
|
||||
* Stability: **beta**
|
||||
|
||||
## Configuration
|
||||
|
||||
* **`host`** (`string`, default `'127.0.0.1'`) - The Redis host
|
||||
* **`port`** (`int`, default `6379`) - The Redis port
|
||||
* **`database`** (`int`, no default) - The Redis database. Needs to be specified.
|
||||
* **`cleanupBefore`**: (`string`, default `'never'`) - Whether/when to flush the database:
|
||||
* `suite`: at the beginning of every suite
|
||||
* `test`: at the beginning of every test
|
||||
* Any other value: never
|
||||
|
||||
### Example (`unit.suite.yml`)
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
- Redis:
|
||||
host: '127.0.0.1'
|
||||
port: 6379
|
||||
database: 0
|
||||
cleanupBefore: 'never'
|
||||
```
|
||||
|
||||
## Public Properties
|
||||
|
||||
* **driver** - Contains the Predis client/driver
|
||||
|
||||
@author Marc Verney <marc@marcverney.net>
|
||||
|
||||
## Actions
|
||||
|
||||
### cleanup
|
||||
|
||||
Delete all the keys in the Redis database
|
||||
|
||||
@throws ModuleException
|
||||
|
||||
|
||||
### dontSeeInRedis
|
||||
|
||||
Asserts that a key does not exist or, optionally, that it doesn't have the
|
||||
provided $value
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// With only one argument, only checks the key does not exist
|
||||
$I->dontSeeInRedis('example:string');
|
||||
|
||||
// Checks a String does not exist or its value is not the one provided
|
||||
$I->dontSeeInRedis('example:string', 'life');
|
||||
|
||||
// Checks a List does not exist or its value is not the one provided (order of elements is compared).
|
||||
$I->dontSeeInRedis('example:list', ['riri', 'fifi', 'loulou']);
|
||||
|
||||
// Checks a Set does not exist or its value is not the one provided (order of members is ignored).
|
||||
$I->dontSeeInRedis('example:set', ['riri', 'fifi', 'loulou']);
|
||||
|
||||
// Checks a ZSet does not exist or its value is not the one provided (scores are required, order of members is compared)
|
||||
$I->dontSeeInRedis('example:zset', ['riri' => 1, 'fifi' => 2, 'loulou' => 3]);
|
||||
|
||||
// Checks a Hash does not exist or its value is not the one provided (order of members is ignored).
|
||||
$I->dontSeeInRedis('example:hash', ['riri' => true, 'fifi' => 'Dewey', 'loulou' => 2]);
|
||||
```
|
||||
|
||||
* `param string` $key The key name
|
||||
* `param mixed` $value Optional. If specified, also checks the key has this
|
||||
value. Booleans will be converted to 1 and 0 (even inside arrays)
|
||||
|
||||
|
||||
### dontSeeRedisKeyContains
|
||||
|
||||
Asserts that a given key does not contain a given item
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// Strings: performs a substring search
|
||||
$I->dontSeeRedisKeyContains('string', 'bar');
|
||||
|
||||
// Lists
|
||||
$I->dontSeeRedisKeyContains('example:list', 'poney');
|
||||
|
||||
// Sets
|
||||
$I->dontSeeRedisKeyContains('example:set', 'cat');
|
||||
|
||||
// ZSets: check whether the zset has this member
|
||||
$I->dontSeeRedisKeyContains('example:zset', 'jordan');
|
||||
|
||||
// ZSets: check whether the zset has this member with this score
|
||||
$I->dontSeeRedisKeyContains('example:zset', 'jordan', 23);
|
||||
|
||||
// Hashes: check whether the hash has this field
|
||||
$I->dontSeeRedisKeyContains('example:hash', 'magic');
|
||||
|
||||
// Hashes: check whether the hash has this field with this value
|
||||
$I->dontSeeRedisKeyContains('example:hash', 'magic', 32);
|
||||
```
|
||||
|
||||
* `param string` $key The key
|
||||
* `param mixed` $item The item
|
||||
* `param null` $itemValue Optional and only used for zsets and hashes. If
|
||||
specified, the method will also check that the $item has this value/score
|
||||
|
||||
* `return` bool
|
||||
|
||||
|
||||
### grabFromRedis
|
||||
|
||||
Returns the value of a given key
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// Strings
|
||||
$I->grabFromRedis('string');
|
||||
|
||||
// Lists: get all members
|
||||
$I->grabFromRedis('example:list');
|
||||
|
||||
// Lists: get a specific member
|
||||
$I->grabFromRedis('example:list', 2);
|
||||
|
||||
// Lists: get a range of elements
|
||||
$I->grabFromRedis('example:list', 2, 4);
|
||||
|
||||
// Sets: get all members
|
||||
$I->grabFromRedis('example:set');
|
||||
|
||||
// ZSets: get all members
|
||||
$I->grabFromRedis('example:zset');
|
||||
|
||||
// ZSets: get a range of members
|
||||
$I->grabFromRedis('example:zset', 3, 12);
|
||||
|
||||
// Hashes: get all fields of a key
|
||||
$I->grabFromRedis('example:hash');
|
||||
|
||||
// Hashes: get a specific field of a key
|
||||
$I->grabFromRedis('example:hash', 'foo');
|
||||
```
|
||||
|
||||
* `param string` $key The key name
|
||||
|
||||
@throws ModuleException if the key does not exist
|
||||
|
||||
|
||||
### haveInRedis
|
||||
|
||||
Creates or modifies keys
|
||||
|
||||
If $key already exists:
|
||||
|
||||
- Strings: its value will be overwritten with $value
|
||||
- Other types: $value items will be appended to its value
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// Strings: $value must be a scalar
|
||||
$I->haveInRedis('string', 'Obladi Oblada');
|
||||
|
||||
// Lists: $value can be a scalar or an array
|
||||
$I->haveInRedis('list', ['riri', 'fifi', 'loulou']);
|
||||
|
||||
// Sets: $value can be a scalar or an array
|
||||
$I->haveInRedis('set', ['riri', 'fifi', 'loulou']);
|
||||
|
||||
// ZSets: $value must be an associative array with scores
|
||||
$I->haveInRedis('zset', ['riri' => 1, 'fifi' => 2, 'loulou' => 3]);
|
||||
|
||||
// Hashes: $value must be an associative array
|
||||
$I->haveInRedis('hash', ['obladi' => 'oblada']);
|
||||
```
|
||||
|
||||
* `param string` $type The type of the key
|
||||
* `param string` $key The key name
|
||||
* `param mixed` $value The value
|
||||
|
||||
@throws ModuleException
|
||||
|
||||
|
||||
### seeInRedis
|
||||
|
||||
Asserts that a key exists, and optionally that it has the provided $value
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// With only one argument, only checks the key exists
|
||||
$I->seeInRedis('example:string');
|
||||
|
||||
// Checks a String exists and has the value "life"
|
||||
$I->seeInRedis('example:string', 'life');
|
||||
|
||||
// Checks the value of a List. Order of elements is compared.
|
||||
$I->seeInRedis('example:list', ['riri', 'fifi', 'loulou']);
|
||||
|
||||
// Checks the value of a Set. Order of members is ignored.
|
||||
$I->seeInRedis('example:set', ['riri', 'fifi', 'loulou']);
|
||||
|
||||
// Checks the value of a ZSet. Scores are required. Order of members is compared.
|
||||
$I->seeInRedis('example:zset', ['riri' => 1, 'fifi' => 2, 'loulou' => 3]);
|
||||
|
||||
// Checks the value of a Hash. Order of members is ignored.
|
||||
$I->seeInRedis('example:hash', ['riri' => true, 'fifi' => 'Dewey', 'loulou' => 2]);
|
||||
```
|
||||
|
||||
* `param string` $key The key name
|
||||
* `param mixed` $value Optional. If specified, also checks the key has this
|
||||
value. Booleans will be converted to 1 and 0 (even inside arrays)
|
||||
|
||||
|
||||
### seeRedisKeyContains
|
||||
|
||||
Asserts that a given key contains a given item
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
// Strings: performs a substring search
|
||||
$I->seeRedisKeyContains('example:string', 'bar');
|
||||
|
||||
// Lists
|
||||
$I->seeRedisKeyContains('example:list', 'poney');
|
||||
|
||||
// Sets
|
||||
$I->seeRedisKeyContains('example:set', 'cat');
|
||||
|
||||
// ZSets: check whether the zset has this member
|
||||
$I->seeRedisKeyContains('example:zset', 'jordan');
|
||||
|
||||
// ZSets: check whether the zset has this member with this score
|
||||
$I->seeRedisKeyContains('example:zset', 'jordan', 23);
|
||||
|
||||
// Hashes: check whether the hash has this field
|
||||
$I->seeRedisKeyContains('example:hash', 'magic');
|
||||
|
||||
// Hashes: check whether the hash has this field with this value
|
||||
$I->seeRedisKeyContains('example:hash', 'magic', 32);
|
||||
```
|
||||
|
||||
* `param string` $key The key
|
||||
* `param mixed` $item The item
|
||||
* `param null` $itemValue Optional and only used for zsets and hashes. If
|
||||
specified, the method will also check that the $item has this value/score
|
||||
|
||||
* `return` bool
|
||||
|
||||
|
||||
### sendCommandToRedis
|
||||
|
||||
Sends a command directly to the Redis driver. See documentation at
|
||||
https://github.com/nrk/predis
|
||||
Every argument that follows the $command name will be passed to it.
|
||||
|
||||
Examples:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->sendCommandToRedis('incr', 'example:string');
|
||||
$I->sendCommandToRedis('strLen', 'example:string');
|
||||
$I->sendCommandToRedis('lPop', 'example:list');
|
||||
$I->sendCommandToRedis('zRangeByScore', 'example:set', '-inf', '+inf', ['withscores' => true, 'limit' => [1, 2]]);
|
||||
$I->sendCommandToRedis('flushdb');
|
||||
```
|
||||
|
||||
* `param string` $command The command name
|
||||
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/Redis.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
235
vendor/codeception/base/docs/modules/SOAP.md
vendored
Normal file
235
vendor/codeception/base/docs/modules/SOAP.md
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
# SOAP
|
||||
|
||||
|
||||
Module for testing SOAP WSDL web services.
|
||||
Send requests and check if response matches the pattern.
|
||||
|
||||
This module can be used either with frameworks or PHPBrowser.
|
||||
It tries to guess the framework is is attached to.
|
||||
If a endpoint is a full url then it uses PHPBrowser.
|
||||
|
||||
### Using Inside Framework
|
||||
|
||||
Please note, that PHP SoapServer::handle method sends additional headers.
|
||||
This may trigger warning: "Cannot modify header information"
|
||||
If you use PHP SoapServer with framework, try to block call to this method in testing environment.
|
||||
|
||||
## Status
|
||||
|
||||
* Maintainer: **davert**
|
||||
* Stability: **stable**
|
||||
* Contact: codecept@davert.mail.ua
|
||||
|
||||
## Configuration
|
||||
|
||||
* endpoint *required* - soap wsdl endpoint
|
||||
* SOAPAction - replace SOAPAction HTTP header (Set to '' to SOAP 1.2)
|
||||
|
||||
## Public Properties
|
||||
|
||||
* xmlRequest - last SOAP request (DOMDocument)
|
||||
* xmlResponse - last SOAP response (DOMDocument)
|
||||
|
||||
|
||||
## Actions
|
||||
|
||||
### dontSeeSoapResponseContainsStructure
|
||||
|
||||
Opposite to `seeSoapResponseContainsStructure`
|
||||
* `param` $xml
|
||||
|
||||
|
||||
### dontSeeSoapResponseContainsXPath
|
||||
|
||||
Checks XML response doesn't contain XPath locator
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->dontSeeSoapResponseContainsXPath('//root/user[@id=1]');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $xpath
|
||||
|
||||
|
||||
### dontSeeSoapResponseEquals
|
||||
|
||||
Checks XML response equals provided XML.
|
||||
Comparison is done by canonicalizing both xml`s.
|
||||
|
||||
Parameter can be passed either as XmlBuilder, DOMDocument, DOMNode, XML string, or array (if no attributes).
|
||||
|
||||
* `param` $xml
|
||||
|
||||
|
||||
### dontSeeSoapResponseIncludes
|
||||
|
||||
Checks XML response does not include provided XML.
|
||||
Comparison is done by canonicalizing both xml`s.
|
||||
Parameter can be passed either as XmlBuilder, DOMDocument, DOMNode, XML string, or array (if no attributes).
|
||||
|
||||
* `param` $xml
|
||||
|
||||
|
||||
### grabAttributeFrom
|
||||
|
||||
Finds and returns attribute of element.
|
||||
Element is matched by either CSS or XPath
|
||||
|
||||
* `Available since` 1.1
|
||||
* `param` $cssOrXPath
|
||||
* `param` $attribute
|
||||
* `return` string
|
||||
|
||||
|
||||
### grabTextContentFrom
|
||||
|
||||
Finds and returns text contents of element.
|
||||
Element is matched by either CSS or XPath
|
||||
|
||||
* `Available since` 1.1
|
||||
* `param` $cssOrXPath
|
||||
* `return` string
|
||||
|
||||
|
||||
### haveSoapHeader
|
||||
|
||||
Prepare SOAP header.
|
||||
Receives header name and parameters as array.
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->haveSoapHeader('AuthHeader', array('username' => 'davert', 'password' => '123345'));
|
||||
```
|
||||
|
||||
Will produce header:
|
||||
|
||||
```
|
||||
<soapenv:Header>
|
||||
<SessionHeader>
|
||||
<AuthHeader>
|
||||
<username>davert</username>
|
||||
<password>12345</password>
|
||||
</AuthHeader>
|
||||
</soapenv:Header>
|
||||
```
|
||||
|
||||
* `param` $header
|
||||
* `param array` $params
|
||||
|
||||
|
||||
### seeResponseCodeIs
|
||||
|
||||
@deprecated use seeSoapResponseCodeIs instead
|
||||
|
||||
|
||||
### seeSoapResponseCodeIs
|
||||
|
||||
Checks response code from server.
|
||||
|
||||
* `param` $code
|
||||
|
||||
|
||||
### seeSoapResponseContainsStructure
|
||||
|
||||
Checks XML response contains provided structure.
|
||||
Response elements will be compared with XML provided.
|
||||
Only nodeNames are checked to see elements match.
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
$I->seeSoapResponseContainsStructure("<query><name></name></query>");
|
||||
?>
|
||||
```
|
||||
|
||||
Use this method to check XML of valid structure is returned.
|
||||
This method does not use schema for validation.
|
||||
This method does not require path from root to match the structure.
|
||||
|
||||
* `param` $xml
|
||||
|
||||
|
||||
### seeSoapResponseContainsXPath
|
||||
|
||||
Checks XML response with XPath locator
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeSoapResponseContainsXPath('//root/user[@id=1]');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $xpath
|
||||
|
||||
|
||||
### seeSoapResponseEquals
|
||||
|
||||
Checks XML response equals provided XML.
|
||||
Comparison is done by canonicalizing both xml`s.
|
||||
|
||||
Parameters can be passed either as DOMDocument, DOMNode, XML string, or array (if no attributes).
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeSoapResponseEquals("<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope><SOAP-ENV:Body><result>1</result></SOAP-ENV:Envelope>");
|
||||
|
||||
$dom = new \DOMDocument();
|
||||
$dom->load($file);
|
||||
$I->seeSoapRequestIncludes($dom);
|
||||
|
||||
```
|
||||
|
||||
* `param` $xml
|
||||
|
||||
|
||||
### seeSoapResponseIncludes
|
||||
|
||||
Checks XML response includes provided XML.
|
||||
Comparison is done by canonicalizing both xml`s.
|
||||
Parameter can be passed either as XmlBuilder, DOMDocument, DOMNode, XML string, or array (if no attributes).
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->seeSoapResponseIncludes("<result>1</result>");
|
||||
$I->seeSoapRequestIncludes(\Codeception\Utils\Soap::response()->result->val(1));
|
||||
|
||||
$dom = new \DDOMDocument();
|
||||
$dom->load('template.xml');
|
||||
$I->seeSoapRequestIncludes($dom);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $xml
|
||||
|
||||
|
||||
### sendSoapRequest
|
||||
|
||||
Submits request to endpoint.
|
||||
|
||||
Requires of api function name and parameters.
|
||||
Parameters can be passed either as DOMDocument, DOMNode, XML string, or array (if no attributes).
|
||||
|
||||
You are allowed to execute as much requests as you need inside test.
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
$I->sendSoapRequest('UpdateUser', '<user><id>1</id><name>notdavert</name></user>');
|
||||
$I->sendSoapRequest('UpdateUser', \Codeception\Utils\Soap::request()->user
|
||||
->id->val(1)->parent()
|
||||
->name->val('notdavert');
|
||||
```
|
||||
|
||||
* `param` $request
|
||||
* `param` $body
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/SOAP.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
97
vendor/codeception/base/docs/modules/Sequence.md
vendored
Normal file
97
vendor/codeception/base/docs/modules/Sequence.md
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
# Sequence
|
||||
|
||||
|
||||
Sequence solves data cleanup issue in alternative way.
|
||||
Instead cleaning up the database between tests,
|
||||
you can use generated unique names, that should not conflict.
|
||||
When you create article on a site, for instance, you can assign it a unique name and then check it.
|
||||
|
||||
This module has no actions, but introduces a function `sq` for generating unique sequences within test and
|
||||
`sqs` for generating unique sequences across suite.
|
||||
|
||||
### Usage
|
||||
|
||||
Function `sq` generates sequence, the only parameter it takes, is id.
|
||||
You can get back to previously generated sequence using that id:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
sq('post1'); // post1_521fbc63021eb
|
||||
sq('post2'); // post2_521fbc6302266
|
||||
sq('post1'); // post1_521fbc63021eb
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$I->wantTo('create article');
|
||||
$I->click('New Article');
|
||||
$I->fillField('Title', sq('Article'));
|
||||
$I->fillField('Body', 'Demo article with Lorem Ipsum');
|
||||
$I->click('save');
|
||||
$I->see(sq('Article') ,'#articles')
|
||||
```
|
||||
|
||||
Populating Database:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
for ($i = 0; $i<10; $i++) {
|
||||
$I->haveInDatabase('users', array('login' => sq("user$i"), 'email' => sq("user$i").'@email.com');
|
||||
}
|
||||
?>
|
||||
```
|
||||
|
||||
Cest Suite tests:
|
||||
|
||||
``` php
|
||||
<?php
|
||||
class UserTest
|
||||
{
|
||||
public function createUser(AcceptanceTester $I)
|
||||
{
|
||||
$I->createUser(sqs('user') . '@mailserver.com', sqs('login'), sqs('pwd'));
|
||||
}
|
||||
|
||||
public function checkEmail(AcceptanceTester $I)
|
||||
{
|
||||
$I->seeInEmailTo(sqs('user') . '@mailserver.com', sqs('login'));
|
||||
}
|
||||
|
||||
public function removeUser(AcceptanceTester $I)
|
||||
{
|
||||
$I->removeUser(sqs('user') . '@mailserver.com');
|
||||
}
|
||||
}
|
||||
?>
|
||||
```
|
||||
|
||||
### Config
|
||||
|
||||
By default produces unique string with param as a prefix:
|
||||
|
||||
```
|
||||
sq('user') => 'user_876asd8as87a'
|
||||
```
|
||||
|
||||
This behavior can be configured using `prefix` config param.
|
||||
|
||||
Old style sequences:
|
||||
|
||||
```yaml
|
||||
Sequence:
|
||||
prefix: '_'
|
||||
```
|
||||
|
||||
Using id param inside prefix:
|
||||
|
||||
```yaml
|
||||
Sequence:
|
||||
prefix: '{id}.'
|
||||
```
|
||||
|
||||
## Actions
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/Sequence.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
1337
vendor/codeception/base/docs/modules/Silex.md
vendored
Normal file
1337
vendor/codeception/base/docs/modules/Silex.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1501
vendor/codeception/base/docs/modules/Symfony.md
vendored
Normal file
1501
vendor/codeception/base/docs/modules/Symfony.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2136
vendor/codeception/base/docs/modules/WebDriver.md
vendored
Normal file
2136
vendor/codeception/base/docs/modules/WebDriver.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
66
vendor/codeception/base/docs/modules/XMLRPC.md
vendored
Normal file
66
vendor/codeception/base/docs/modules/XMLRPC.md
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
# XMLRPC
|
||||
|
||||
|
||||
Module for testing XMLRPC WebService.
|
||||
|
||||
This module can be used either with frameworks or PHPBrowser.
|
||||
It tries to guess the framework is is attached to.
|
||||
|
||||
Whether framework is used it operates via standard framework modules.
|
||||
Otherwise sends raw HTTP requests to url via PHPBrowser.
|
||||
|
||||
## Requirements
|
||||
|
||||
* Module requires installed php_xmlrpc extension
|
||||
|
||||
## Status
|
||||
|
||||
* Maintainer: **tiger-seo**
|
||||
* Stability: **beta**
|
||||
* Contact: tiger.seo@gmail.com
|
||||
|
||||
## Configuration
|
||||
|
||||
* url *optional* - the url of api
|
||||
|
||||
## Public Properties
|
||||
|
||||
* headers - array of headers going to be sent.
|
||||
* params - array of sent data
|
||||
* response - last response (string)
|
||||
|
||||
@since 1.1.5
|
||||
@author tiger.seo@gmail.com
|
||||
|
||||
## Actions
|
||||
|
||||
### haveHttpHeader
|
||||
|
||||
Sets HTTP header
|
||||
|
||||
* `param string` $name
|
||||
* `param string` $value
|
||||
|
||||
|
||||
### seeResponseCodeIs
|
||||
|
||||
Checks response code.
|
||||
|
||||
* `param` $num
|
||||
|
||||
|
||||
### seeResponseIsXMLRPC
|
||||
|
||||
Checks weather last response was valid XMLRPC.
|
||||
This is done with xmlrpc_decode function.
|
||||
|
||||
|
||||
|
||||
### sendXMLRPCMethodCall
|
||||
|
||||
Sends a XMLRPC method call to remote XMLRPC-server.
|
||||
|
||||
* `param string` $methodName
|
||||
* `param array` $parameters
|
||||
|
||||
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Module/XMLRPC.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
1385
vendor/codeception/base/docs/modules/Yii1.md
vendored
Normal file
1385
vendor/codeception/base/docs/modules/Yii1.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1623
vendor/codeception/base/docs/modules/Yii2.md
vendored
Normal file
1623
vendor/codeception/base/docs/modules/Yii2.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1357
vendor/codeception/base/docs/modules/ZF1.md
vendored
Normal file
1357
vendor/codeception/base/docs/modules/ZF1.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1366
vendor/codeception/base/docs/modules/ZF2.md
vendored
Normal file
1366
vendor/codeception/base/docs/modules/ZF2.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1292
vendor/codeception/base/docs/modules/ZendExpressive.md
vendored
Normal file
1292
vendor/codeception/base/docs/modules/ZendExpressive.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
82
vendor/codeception/base/docs/reference/Autoload.md
vendored
Normal file
82
vendor/codeception/base/docs/reference/Autoload.md
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
## Codeception\Util\Autoload
|
||||
|
||||
|
||||
|
||||
Autoloader, which is fully compatible with PSR-4,
|
||||
and can be used to autoload your `Helper`, `Page`, and `Step` classes.
|
||||
|
||||
|
||||
#### __construct()
|
||||
|
||||
*private* __construct()
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Autoload.php#L18)
|
||||
|
||||
#### addNamespace()
|
||||
|
||||
*public static* addNamespace($prefix, $base_dir, $prepend = null)
|
||||
|
||||
Adds a base directory for a namespace prefix.
|
||||
|
||||
Example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// app\Codeception\UserHelper will be loaded from '/path/to/helpers/UserHelper.php'
|
||||
Autoload::addNamespace('app\Codeception', '/path/to/helpers');
|
||||
|
||||
// LoginPage will be loaded from '/path/to/pageobjects/LoginPage.php'
|
||||
Autoload::addNamespace('', '/path/to/pageobjects');
|
||||
|
||||
Autoload::addNamespace('app\Codeception', '/path/to/controllers');
|
||||
?>
|
||||
```
|
||||
|
||||
* `param string` $prefix The namespace prefix.
|
||||
* `param string` $base_dir A base directory for class files in the namespace.
|
||||
* `param bool` $prepend If true, prepend the base directory to the stack instead of appending it;
|
||||
this causes it to be searched first rather than last.
|
||||
* `return` void
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Autoload.php#L45)
|
||||
|
||||
#### load()
|
||||
|
||||
*public static* load($class)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Autoload.php#L88)
|
||||
|
||||
#### loadMappedFile()
|
||||
|
||||
*protected static* loadMappedFile($prefix, $relative_class)
|
||||
|
||||
Load the mapped file for a namespace prefix and relative class.
|
||||
|
||||
* `param string` $prefix The namespace prefix.
|
||||
* `param string` $relative_class The relative class name.
|
||||
* `return` mixed Boolean false if no mapped file can be loaded, or the name of the mapped file that was loaded.
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Autoload.php#L136)
|
||||
|
||||
#### register()
|
||||
|
||||
*public static* register($namespace, $suffix, $path)
|
||||
* `deprecated` Use self::addNamespace() instead.
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Autoload.php#L75)
|
||||
|
||||
#### registerSuffix()
|
||||
|
||||
*public static* registerSuffix($suffix, $path)
|
||||
* `deprecated` Use self::addNamespace() instead.
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Autoload.php#L83)
|
||||
|
||||
#### requireFile()
|
||||
|
||||
*protected static* requireFile($file)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Autoload.php#L156)
|
||||
|
||||
<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/2.4/src//Codeception/Util/Autoload.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
321
vendor/codeception/base/docs/reference/Commands.md
vendored
Normal file
321
vendor/codeception/base/docs/reference/Commands.md
vendored
Normal file
@@ -0,0 +1,321 @@
|
||||
# Console Commands
|
||||
|
||||
## DryRun
|
||||
|
||||
Shows step by step execution process for scenario driven tests without actually running them.
|
||||
|
||||
* `codecept dry-run acceptance`
|
||||
* `codecept dry-run acceptance MyCest`
|
||||
* `codecept dry-run acceptance checkout.feature`
|
||||
* `codecept dry-run tests/acceptance/MyCest.php`
|
||||
|
||||
|
||||
|
||||
|
||||
## GenerateSuite
|
||||
|
||||
Create new test suite. Requires suite name and actor name
|
||||
|
||||
* ``
|
||||
* `codecept g:suite api` -> api + ApiTester
|
||||
* `codecept g:suite integration Code` -> integration + CodeTester
|
||||
* `codecept g:suite frontend Front` -> frontend + FrontTester
|
||||
|
||||
|
||||
|
||||
|
||||
## GherkinSnippets
|
||||
|
||||
Generates code snippets for matched feature files in a suite.
|
||||
Code snippets are expected to be implemented in Actor or PageObjects
|
||||
|
||||
Usage:
|
||||
|
||||
* `codecept gherkin:snippets acceptance` - snippets from all feature of acceptance tests
|
||||
* `codecept gherkin:snippets acceptance/feature/users` - snippets from `feature/users` dir of acceptance tests
|
||||
* `codecept gherkin:snippets acceptance user_account.feature` - snippets from a single feature file
|
||||
* `codecept gherkin:snippets acceptance/feature/users/user_accout.feature` - snippets from feature file in a dir
|
||||
|
||||
|
||||
|
||||
## Init
|
||||
|
||||
|
||||
|
||||
## Console
|
||||
|
||||
Try to execute test commands in run-time. You may try commands before writing the test.
|
||||
|
||||
* `codecept console acceptance` - starts acceptance suite environment. If you use WebDriver you can manipulate browser with Codeception commands.
|
||||
|
||||
|
||||
|
||||
## ConfigValidate
|
||||
|
||||
Validates and prints Codeception config.
|
||||
Use it do debug Yaml configs
|
||||
|
||||
Check config:
|
||||
|
||||
* `codecept config`: check global config
|
||||
* `codecept config unit`: check suite config
|
||||
|
||||
Load config:
|
||||
|
||||
* `codecept config:validate -c path/to/another/config`: from another dir
|
||||
* `codecept config:validate -c another_config.yml`: from another config file
|
||||
|
||||
Check overriding config values (like in `run` command)
|
||||
|
||||
* `codecept config:validate -o "settings: shuffle: true"`: enable shuffle
|
||||
* `codecept config:validate -o "settings: lint: false"`: disable linting
|
||||
* `codecept config:validate -o "reporters: report: \Custom\Reporter" --report`: use custom reporter
|
||||
|
||||
|
||||
|
||||
|
||||
## GenerateGroup
|
||||
|
||||
Creates empty GroupObject - extension which handles all group events.
|
||||
|
||||
* `codecept g:group Admin`
|
||||
|
||||
|
||||
|
||||
## GenerateCept
|
||||
|
||||
Generates Cept (scenario-driven test) file:
|
||||
|
||||
* `codecept generate:cept suite Login`
|
||||
* `codecept g:cept suite subdir/subdir/testnameCept.php`
|
||||
* `codecept g:cept suite LoginCept -c path/to/project`
|
||||
|
||||
|
||||
|
||||
|
||||
## Run
|
||||
|
||||
Executes tests.
|
||||
|
||||
Usage:
|
||||
|
||||
* `codecept run acceptance`: run all acceptance tests
|
||||
* `codecept run tests/acceptance/MyCept.php`: run only MyCept
|
||||
* `codecept run acceptance MyCept`: same as above
|
||||
* `codecept run acceptance MyCest:myTestInIt`: run one test from a Cest
|
||||
* `codecept run acceptance checkout.feature`: run feature-file
|
||||
* `codecept run acceptance -g slow`: run tests from *slow* group
|
||||
* `codecept run unit,functional`: run only unit and functional suites
|
||||
|
||||
Verbosity modes:
|
||||
|
||||
* `codecept run -v`:
|
||||
* `codecept run --steps`: print step-by-step execution
|
||||
* `codecept run -vv`:
|
||||
* `codecept run --debug`: print steps and debug information
|
||||
* `codecept run -vvv`: print internal debug information
|
||||
|
||||
Load config:
|
||||
|
||||
* `codecept run -c path/to/another/config`: from another dir
|
||||
* `codecept run -c another_config.yml`: from another config file
|
||||
|
||||
Override config values:
|
||||
|
||||
* `codecept run -o "settings: shuffle: true"`: enable shuffle
|
||||
* `codecept run -o "settings: lint: false"`: disable linting
|
||||
* `codecept run -o "reporters: report: \Custom\Reporter" --report`: use custom reporter
|
||||
|
||||
Run with specific extension
|
||||
|
||||
* `codecept run --ext Recorder` run with Recorder extension enabled
|
||||
* `codecept run --ext DotReporter` run with DotReporter printer
|
||||
* `codecept run --ext "My\Custom\Extension"` run with an extension loaded by class name
|
||||
|
||||
Full reference:
|
||||
```
|
||||
Arguments:
|
||||
suite suite to be tested
|
||||
test test to be run
|
||||
|
||||
Options:
|
||||
-o, --override=OVERRIDE Override config values (multiple values allowed)
|
||||
--config (-c) Use custom path for config
|
||||
--report Show output in compact style
|
||||
--html Generate html with results (default: "report.html")
|
||||
--xml Generate JUnit XML Log (default: "report.xml")
|
||||
--tap Generate Tap Log (default: "report.tap.log")
|
||||
--json Generate Json Log (default: "report.json")
|
||||
--colors Use colors in output
|
||||
--no-colors Force no colors in output (useful to override config file)
|
||||
--silent Only outputs suite names and final results
|
||||
--steps Show steps in output
|
||||
--debug (-d) Show debug and scenario output
|
||||
--coverage Run with code coverage (default: "coverage.serialized")
|
||||
--coverage-html Generate CodeCoverage HTML report in path (default: "coverage")
|
||||
--coverage-xml Generate CodeCoverage XML report in file (default: "coverage.xml")
|
||||
--coverage-text Generate CodeCoverage text report in file (default: "coverage.txt")
|
||||
--coverage-phpunit Generate CodeCoverage PHPUnit report in file (default: "coverage-phpunit")
|
||||
--no-exit Don't finish with exit code
|
||||
--group (-g) Groups of tests to be executed (multiple values allowed)
|
||||
--skip (-s) Skip selected suites (multiple values allowed)
|
||||
--skip-group (-x) Skip selected groups (multiple values allowed)
|
||||
--env Run tests in selected environments. (multiple values allowed, environments can be merged with ',')
|
||||
--fail-fast (-f) Stop after first failure
|
||||
--help (-h) Display this help message.
|
||||
--quiet (-q) Do not output any message.
|
||||
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||
--version (-V) Display this application version.
|
||||
--ansi Force ANSI output.
|
||||
--no-ansi Disable ANSI output.
|
||||
--no-interaction (-n) Do not ask any interactive question.
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
## SelfUpdate
|
||||
|
||||
Auto-updates phar archive from official site: 'http://codeception.com/codecept.phar' .
|
||||
|
||||
* `php codecept.phar self-update`
|
||||
|
||||
@author Franck Cassedanne <franck@cassedanne.com>
|
||||
|
||||
|
||||
|
||||
## CompletionFallback
|
||||
|
||||
|
||||
|
||||
## GenerateTest
|
||||
|
||||
Generates skeleton for Unit Test that extends `Codeception\TestCase\Test`.
|
||||
|
||||
* `codecept g:test unit User`
|
||||
* `codecept g:test unit "App\User"`
|
||||
|
||||
|
||||
|
||||
## Build
|
||||
|
||||
Generates Actor classes (initially Guy classes) from suite configs.
|
||||
Starting from Codeception 2.0 actor classes are auto-generated. Use this command to generate them manually.
|
||||
|
||||
* `codecept build`
|
||||
* `codecept build path/to/project`
|
||||
|
||||
|
||||
|
||||
|
||||
## GenerateHelper
|
||||
|
||||
Creates empty Helper class.
|
||||
|
||||
* `codecept g:helper MyHelper`
|
||||
* `codecept g:helper "My\Helper"`
|
||||
|
||||
|
||||
|
||||
|
||||
## Bootstrap
|
||||
|
||||
Creates default config, tests directory and sample suites for current project.
|
||||
Use this command to start building a test suite.
|
||||
|
||||
By default it will create 3 suites **acceptance**, **functional**, and **unit**.
|
||||
|
||||
* `codecept bootstrap` - creates `tests` dir and `codeception.yml` in current dir.
|
||||
* `codecept bootstrap --empty` - creates `tests` dir without suites
|
||||
* `codecept bootstrap --namespace Frontend` - creates tests, and use `Frontend` namespace for actor classes and helpers.
|
||||
* `codecept bootstrap --actor Wizard` - sets actor as Wizard, to have `TestWizard` actor in tests.
|
||||
* `codecept bootstrap path/to/the/project` - provide different path to a project, where tests should be placed
|
||||
|
||||
|
||||
|
||||
|
||||
## GenerateEnvironment
|
||||
|
||||
Generates empty environment configuration file into envs dir:
|
||||
|
||||
* `codecept g:env firefox`
|
||||
|
||||
Required to have `envs` path to be specified in `codeception.yml`
|
||||
|
||||
|
||||
|
||||
## GenerateFeature
|
||||
|
||||
Generates Feature file (in Gherkin):
|
||||
|
||||
* `codecept generate:feature suite Login`
|
||||
* `codecept g:feature suite subdir/subdir/login.feature`
|
||||
* `codecept g:feature suite login.feature -c path/to/project`
|
||||
|
||||
|
||||
|
||||
|
||||
## GenerateScenarios
|
||||
|
||||
Generates user-friendly text scenarios from scenario-driven tests (Cest, Cept).
|
||||
|
||||
* `codecept g:scenarios acceptance` - for all acceptance tests
|
||||
* `codecept g:scenarios acceptance --format html` - in html format
|
||||
* `codecept g:scenarios acceptance --path doc` - generate scenarios to `doc` dir
|
||||
|
||||
|
||||
|
||||
## GenerateStepObject
|
||||
|
||||
Generates StepObject class. You will be asked for steps you want to implement.
|
||||
|
||||
* `codecept g:stepobject acceptance AdminSteps`
|
||||
* `codecept g:stepobject acceptance UserSteps --silent` - skip action questions
|
||||
|
||||
|
||||
|
||||
|
||||
## Clean
|
||||
|
||||
Recursively cleans `output` directory and generated code.
|
||||
|
||||
* `codecept clean`
|
||||
|
||||
|
||||
|
||||
|
||||
## GherkinSteps
|
||||
|
||||
Prints all steps from all Gherkin contexts for a specific suite
|
||||
|
||||
```
|
||||
codecept gherkin:steps acceptance
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## GenerateCest
|
||||
|
||||
Generates Cest (scenario-driven object-oriented test) file:
|
||||
|
||||
* `codecept generate:cest suite Login`
|
||||
* `codecept g:cest suite subdir/subdir/testnameCest.php`
|
||||
* `codecept g:cest suite LoginCest -c path/to/project`
|
||||
* `codecept g:cest "App\Login"`
|
||||
|
||||
|
||||
|
||||
|
||||
## GeneratePageObject
|
||||
|
||||
Generates PageObject. Can be generated either globally, or just for one suite.
|
||||
If PageObject is generated globally it will act as UIMap, without any logic in it.
|
||||
|
||||
* `codecept g:page Login`
|
||||
* `codecept g:page Registration`
|
||||
* `codecept g:page acceptance Login`
|
||||
|
||||
|
||||
|
||||
159
vendor/codeception/base/docs/reference/Configuration.md
vendored
Normal file
159
vendor/codeception/base/docs/reference/Configuration.md
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
# Configuration
|
||||
|
||||
## Global Configuration
|
||||
|
||||
Configuration file `codeception.yml` is generated by `codecept bootstrap` command. It has preconfigured settings you can change.
|
||||
|
||||
Here are global options you can change inside configuration:
|
||||
|
||||
* `actor: Tester`: changes suffix for Actor classes. This defines a rule to generate new test suites. If you change `Tester` to `Ninja`, and generate new `api` test suite, you will get `ApiNinja` actor class.
|
||||
* `namespace`: set a namespace for tests. All new tests and support classes will be generated under that namespace. Allows to configure [multiple test setups for one runner](http://codeception.com/docs/08-Customization#Namespaces).
|
||||
* `include: []`: include additional Codeception configurations for [multiple applications setup](http://codeception.com/docs/08-Customization#Namespaces).
|
||||
* `paths` directories used by Codeception. Default values are:
|
||||
|
||||
```yaml
|
||||
paths:
|
||||
# where the tests stored
|
||||
tests: tests
|
||||
|
||||
# directory for fixture data
|
||||
data: tests/_data
|
||||
|
||||
# directory for support code
|
||||
support: tests/_support
|
||||
|
||||
# directory for output
|
||||
output: tests/_output
|
||||
|
||||
# directory for environment configuration
|
||||
envs: tests/_envs
|
||||
```
|
||||
|
||||
* `settings`: provide additional options for test runner. They may dramatically change the way Codeception is executed. For instance, take a note of `shuffle` option which allows to randomize tests execution order and `lint` option that toggles parsing a test file (using `php -l`) before loading it.
|
||||
|
||||
```yaml
|
||||
settings:
|
||||
|
||||
# name of bootstrap that will be used
|
||||
# each bootstrap file should be
|
||||
# inside a suite directory.
|
||||
bootstrap: _bootstrap.php
|
||||
|
||||
# enable/disable syntax of test files before loading
|
||||
# for php < 7 exec('php -l') is used
|
||||
# disable if you need to speed up tests execution
|
||||
lint: true
|
||||
|
||||
# randomize test order
|
||||
shuffle: true
|
||||
|
||||
# by default it's false on Windows
|
||||
# use [ANSICON](https://github.com/adoxa/ansicon) to colorize output.
|
||||
colors: true
|
||||
|
||||
# Generate XML JUnit report using strict schema
|
||||
# Avoid putting additional report fields like steps or scenario names tot it
|
||||
# Required for XML reports on Jenkins CI
|
||||
strict_xml: false
|
||||
|
||||
# Tests (especially functional) can take a lot of memory
|
||||
# We set a high limit for them by default.
|
||||
memory_limit: 1024M
|
||||
|
||||
# This value controls whether PHPUnit attempts to backup global variables
|
||||
# See https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.backupGlobals
|
||||
backup_globals: true
|
||||
|
||||
# PHPUnit can be strict about tests that do not test anything
|
||||
# See https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.useless-tests
|
||||
report_useless_tests: false
|
||||
|
||||
# PHPUnit can be strict about output during tests.
|
||||
# See https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.output-during-test-execution
|
||||
disallow_test_output: false
|
||||
|
||||
# PHPUnit can be strict about tests that manipulate global state.
|
||||
# See https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.global-state-manipulation
|
||||
be_strict_about_changes_to_global_state: false
|
||||
|
||||
# Log the incomplete and skipped tests into junit report
|
||||
# See https://phpunit.de/manual/current/en/appendixes.configuration.html
|
||||
# Section logging > junit
|
||||
log_incomplete_skipped: false
|
||||
```
|
||||
|
||||
* `modules`: allows to create shared module configuration for all included suites.
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: ''
|
||||
user: ''
|
||||
password: ''
|
||||
dump: tests/_data/dump.sql
|
||||
```
|
||||
* `extends`: allows you to specify a file (relative to the `codeception.yml` file) that holds some already pre-defined values. This can be used to always use the same configuration for modules or whatever.
|
||||
* `extensions`: allows to enable and configure [Codeception extensions](http://codeception.com/docs/08-Customization#Extension), [Group Objects](http://codeception.com/docs/08-Customization#Group-Objects), and [Custom Commands](http://codeception.com/docs/08-Customization#Custom-Commands).
|
||||
* `reporters`: allows to [change default reporters](http://codeception.com/docs/08-Customization#Custom-Reporters) of Codeception
|
||||
* `coverage`: [CodeCoverage](http://codeception.com/docs/11-Codecoverage#Configuration) settings.
|
||||
* `params`: allows to pass [external parameters](http://codeception.com/docs/06-ModulesAndHelpers#Dynamic-Configuration-With-Params) into module configuration.
|
||||
* `gherkin`: BDD-specific [Gherkin options](http://codeception.com/docs/07-BDD#Configuration).
|
||||
|
||||
## Suite Configuration
|
||||
|
||||
Each generated suite have its own configuration inside directory set by `paths: tests: ` configuration option in `codeception.yml`. Each suite configuration is named like `suitename.suite.yml`. It allows to enable and configure modules, and more.
|
||||
|
||||
* `actor`: name of the actor class for current suite.
|
||||
* `modules`: list of enabled modules with their configuration.
|
||||
|
||||
```yaml
|
||||
modules:
|
||||
# enabled modules and helpers
|
||||
enabled:
|
||||
# built-in modules are listed by their names
|
||||
- PhpBrowser:
|
||||
# module configuration
|
||||
url: http://localhost
|
||||
# this module is pre-configured in global config
|
||||
- Db
|
||||
|
||||
# helper names are listed by their class names
|
||||
# by convention their names start with \
|
||||
- \Helper\Acceptance
|
||||
|
||||
# additional modules configuration
|
||||
# can be used for modules which are not currently enabled
|
||||
config:
|
||||
WebDriver:
|
||||
browser: firefox
|
||||
|
||||
# list of modules disabled for this suite
|
||||
disabled:
|
||||
- WebDriver
|
||||
|
||||
```
|
||||
|
||||
* `extends`: allows you to specify a file (relative to the `*.suite.yml` file) that holds some already pre-defined values. This can be used to always use the same configuration for modules or whatever.
|
||||
* `namespace`: default namespace of actor, support classes and tests.
|
||||
* `suite_namespace`: default namespace for new tests of this suite (ignores `namespace` option)
|
||||
* `env`: override any configuration per [environment](http://codeception.com/docs/07-AdvancedUsage#Environments).
|
||||
* `groups`: [groups](http://codeception.com/docs/07-AdvancedUsage#Groups) with the list of tests of for corresponding group.
|
||||
* `formats`: [formats](http://codeception.com/docs/07-AdvancedUsage#Formats) with the list of extra test format classes.
|
||||
* `coverage`: pre suite [CodeCoverage](http://codeception.com/docs/11-Codecoverage#Configuration) settings.
|
||||
* `gherkin`: per suite [BDD Gherkin](http://codeception.com/docs/07-BDD#Configuration) settings.
|
||||
* `error_level`: [error level](http://codeception.com/docs/04-FunctionalTests#Error-Reporting) for runner in current suite. Should be specified for unit, integration, functional tests. Passes value to `error_reporting` function.
|
||||
|
||||
## Config Templates (dist)
|
||||
|
||||
To provide the same configuration template for your development team, you can create a `codeception.dist.yml` config file, which will be loaded before `codeception.yml`. The dist config provides shared options, while local `codeception.yml` files override them on a per-installation basis. Therefore, `codeception.yml` should be ignored by your VCS system.
|
||||
|
||||
Config templates can also be used for suite configuration, by creating a `suitename.suite.dist.yml` file.
|
||||
|
||||
Configuration loading order:
|
||||
|
||||
1. `codeception.dist.yml`
|
||||
2. `codeception.yml`
|
||||
3. `acceptance.suite.dist.yml`
|
||||
4. `acceptance.suite.yml`
|
||||
5. environment config
|
||||
43
vendor/codeception/base/docs/reference/Fixtures.md
vendored
Normal file
43
vendor/codeception/base/docs/reference/Fixtures.md
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
## Codeception\Util\Fixtures
|
||||
|
||||
|
||||
|
||||
Really basic class to store data in global array and use it in Cests/Tests.
|
||||
|
||||
```php
|
||||
<?php
|
||||
Fixtures::add('user1', ['name' => 'davert']);
|
||||
Fixtures::get('user1');
|
||||
Fixtures::exists('user1');
|
||||
|
||||
?>
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### add()
|
||||
|
||||
*public static* add($name, $data)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Fixtures.php#L21)
|
||||
|
||||
#### cleanup()
|
||||
|
||||
*public static* cleanup()
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Fixtures.php#L35)
|
||||
|
||||
#### exists()
|
||||
|
||||
*public static* exists($name)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Fixtures.php#L40)
|
||||
|
||||
#### get()
|
||||
|
||||
*public static* get($name)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Fixtures.php#L26)
|
||||
|
||||
<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/2.4/src//Codeception/Util/Fixtures.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
19
vendor/codeception/base/docs/reference/Functions.md
vendored
Normal file
19
vendor/codeception/base/docs/reference/Functions.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Shorthand Functions
|
||||
|
||||
Shorthand functions can be used in your Codeception tests or helpers.
|
||||
|
||||
#### codecept_debug($data)
|
||||
|
||||
Prints information when running in debug mode. String, array, or object can be provided as argument.
|
||||
|
||||
#### codecept_output_dir()
|
||||
|
||||
Returns absolute path to output directory (`tests/_output`)
|
||||
|
||||
#### codecept_root_dir()
|
||||
|
||||
Returns absolute path to the root directory (where `codeception.yml` is located)
|
||||
|
||||
#### codecept_data_dir()
|
||||
|
||||
Returns absolute path to data directory (`tests/_data`)
|
||||
40
vendor/codeception/base/docs/reference/HttpCode.md
vendored
Normal file
40
vendor/codeception/base/docs/reference/HttpCode.md
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
## Codeception\Util\HttpCode
|
||||
|
||||
|
||||
|
||||
Class containing constants of HTTP Status Codes
|
||||
and method to print HTTP code with its description.
|
||||
|
||||
Usage:
|
||||
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Util\HttpCode;
|
||||
|
||||
// using REST, PhpBrowser, or any Framework module
|
||||
$I->seeResponseCodeIs(HttpCode::OK);
|
||||
$I->dontSeeResponseCodeIs(HttpCode::NOT_FOUND);
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
#### getDescription()
|
||||
|
||||
*public static* getDescription($code)
|
||||
|
||||
Returns string with HTTP code and its description
|
||||
|
||||
```php
|
||||
<?php
|
||||
HttpCode::getDescription(200); // '200 (OK)'
|
||||
HttpCode::getDescription(401); // '401 (Unauthorized)'
|
||||
```
|
||||
|
||||
* `param` $code
|
||||
* `return` mixed
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/HttpCode.php#L155)
|
||||
|
||||
<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/2.4/src//Codeception/Util/HttpCode.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
219
vendor/codeception/base/docs/reference/InitTemplate.md
vendored
Normal file
219
vendor/codeception/base/docs/reference/InitTemplate.md
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
|
||||
## Codeception\InitTemplate
|
||||
|
||||
|
||||
* *Uses* `Codeception\Command\Shared\FileSystem`, `Codeception\Command\Shared\Style`
|
||||
|
||||
Codeception templates allow creating a customized setup and configuration for your project.
|
||||
An abstract class for installation template. Each init template should extend it and implement a `setup` method.
|
||||
Use it to build a custom setup class which can be started with `codecept init` command.
|
||||
|
||||
|
||||
```php
|
||||
<?php
|
||||
namespace Codeception\Template; // it is important to use this namespace so codecept init could locate this template
|
||||
class CustomInstall extends \Codeception\InitTemplate
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
// implement this
|
||||
}
|
||||
}
|
||||
```
|
||||
This class provides various helper methods for building customized setup
|
||||
|
||||
|
||||
#### __construct()
|
||||
|
||||
*public* __construct($input, $output)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L65)
|
||||
|
||||
#### addStyles()
|
||||
|
||||
*public* addStyles($output)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Command/Shared/Style.php#L9)
|
||||
|
||||
#### ask()
|
||||
|
||||
*protected* ask($question, $answer = null)
|
||||
|
||||
```php
|
||||
<?php
|
||||
// propose firefox as default browser
|
||||
$this->ask('select the browser of your choice', 'firefox');
|
||||
|
||||
// propose firefox or chrome possible options
|
||||
$this->ask('select the browser of your choice', ['firefox', 'chrome']);
|
||||
|
||||
// ask true/false question
|
||||
$this->ask('do you want to proceed (y/n)', true);
|
||||
```
|
||||
|
||||
* `param` $question
|
||||
* `param null` $answer
|
||||
* `return` mixed|string
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L107)
|
||||
|
||||
#### breakParts()
|
||||
|
||||
*protected* breakParts($class)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Namespaces.php#L6)
|
||||
|
||||
#### checkInstalled()
|
||||
|
||||
*protected* checkInstalled($dir = null)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L208)
|
||||
|
||||
#### completeSuffix()
|
||||
|
||||
*protected* completeSuffix($filename, $suffix)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Command/Shared/FileSystem.php#L25)
|
||||
|
||||
#### createActor()
|
||||
|
||||
*protected* createActor($name, $directory, $suiteConfig)
|
||||
|
||||
Create an Actor class and generate actions for it.
|
||||
Requires a suite config as array in 3rd parameter.
|
||||
|
||||
* `param` $name
|
||||
* `param` $directory
|
||||
* `param` $suiteConfig
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L223)
|
||||
|
||||
#### createDirectoryFor()
|
||||
|
||||
*protected* createDirectoryFor($basePath, $className = null)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Command/Shared/FileSystem.php#L10)
|
||||
|
||||
#### createEmptyDirectory()
|
||||
|
||||
*protected* createEmptyDirectory($dir)
|
||||
|
||||
Create an empty directory and add a placeholder file into it
|
||||
* `param` $dir
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L195)
|
||||
|
||||
#### createFile()
|
||||
|
||||
*protected* createFile($filename, $contents, $force = null, $flags = null)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Command/Shared/FileSystem.php#L46)
|
||||
|
||||
#### createHelper()
|
||||
|
||||
*protected* createHelper($name, $directory)
|
||||
|
||||
Create a helper class inside a directory
|
||||
|
||||
* `param` $name
|
||||
* `param` $directory
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L174)
|
||||
|
||||
#### getNamespaceHeader()
|
||||
|
||||
*protected* getNamespaceHeader($class)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Namespaces.php#L31)
|
||||
|
||||
#### getNamespaceString()
|
||||
|
||||
*protected* getNamespaceString($class)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Namespaces.php#L25)
|
||||
|
||||
#### getNamespaces()
|
||||
|
||||
*protected* getNamespaces($class)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Namespaces.php#L40)
|
||||
|
||||
#### getShortClassName()
|
||||
|
||||
*protected* getShortClassName($class)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Namespaces.php#L19)
|
||||
|
||||
#### gitIgnore()
|
||||
|
||||
*protected* gitIgnore($path)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L201)
|
||||
|
||||
#### initDir()
|
||||
|
||||
*public* initDir($workDir)
|
||||
|
||||
Change the directory where Codeception should be installed.
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L75)
|
||||
|
||||
#### removeSuffix()
|
||||
|
||||
*protected* removeSuffix($classname, $suffix)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Command/Shared/FileSystem.php#L40)
|
||||
|
||||
#### say()
|
||||
|
||||
*protected* say($message = null)
|
||||
|
||||
Print a message to console.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$this->say('Welcome to Setup');
|
||||
```
|
||||
|
||||
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L136)
|
||||
|
||||
#### sayInfo()
|
||||
|
||||
*protected* sayInfo($message)
|
||||
|
||||
Print info message
|
||||
* `param` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L163)
|
||||
|
||||
#### saySuccess()
|
||||
|
||||
*protected* saySuccess($message)
|
||||
|
||||
Print a successful message
|
||||
* `param` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L145)
|
||||
|
||||
#### sayWarning()
|
||||
|
||||
*protected* sayWarning($message)
|
||||
|
||||
Print warning message
|
||||
* `param` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L154)
|
||||
|
||||
#### setup()
|
||||
|
||||
*abstract public* setup()
|
||||
|
||||
Override this class to create customized setup.
|
||||
* `return` mixed
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php#L88)
|
||||
|
||||
<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/InitTemplate.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
107
vendor/codeception/base/docs/reference/JsonType.md
vendored
Normal file
107
vendor/codeception/base/docs/reference/JsonType.md
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
|
||||
## Codeception\Util\JsonType
|
||||
|
||||
|
||||
|
||||
JsonType matches JSON structures against templates.
|
||||
You can specify the type of fields in JSON or add additional validation rules.
|
||||
|
||||
JsonType is used by REST module in `seeResponseMatchesJsonType` and `dontSeeResponseMatchesJsonType` methods.
|
||||
|
||||
Usage example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$jsonType = new JsonType(['name' => 'davert', 'id' => 1]);
|
||||
$jsonType->matches([
|
||||
'name' => 'string:!empty',
|
||||
'id' => 'integer:>0|string:>0',
|
||||
]); // => true
|
||||
|
||||
$jsonType->matches([
|
||||
'id' => 'string',
|
||||
]); // => `id: 1` is not of type string
|
||||
?>
|
||||
```
|
||||
|
||||
Class JsonType
|
||||
@package Codeception\Util
|
||||
|
||||
|
||||
#### __construct()
|
||||
|
||||
*public* __construct($jsonArray)
|
||||
|
||||
Creates instance of JsonType
|
||||
Pass an array or `\Codeception\Util\JsonArray` with data.
|
||||
If non-associative array is passed - the very first element of it will be used for matching.
|
||||
|
||||
* `param` $jsonArray array|\Codeception\Util\JsonArray
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/JsonType.php#L42)
|
||||
|
||||
#### addCustomFilter()
|
||||
|
||||
*public static* addCustomFilter($name, callable $callable)
|
||||
|
||||
Adds custom filter to JsonType list.
|
||||
You should specify a name and parameters of a filter.
|
||||
|
||||
Example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
JsonType::addCustomFilter('slug', function($value) {
|
||||
return strpos(' ', $value) !== false;
|
||||
});
|
||||
// => use it as 'string:slug'
|
||||
|
||||
|
||||
// add custom function to matcher with `len($val)` syntax
|
||||
// parameter matching patterns should be valid regex and start with `/` char
|
||||
JsonType::addCustomFilter('/len\((.*?)\)/', function($value, $len) {
|
||||
return strlen($value) == $len;
|
||||
});
|
||||
// use it as 'string:len(5)'
|
||||
?>
|
||||
```
|
||||
|
||||
* `param` $name
|
||||
* `param callable` $callable
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/JsonType.php#L76)
|
||||
|
||||
#### cleanCustomFilters()
|
||||
|
||||
*public static* cleanCustomFilters()
|
||||
|
||||
Removes all custom filters
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/JsonType.php#L84)
|
||||
|
||||
#### matchFilter()
|
||||
|
||||
*protected* matchFilter($filter, $value)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/JsonType.php#L158)
|
||||
|
||||
#### matches()
|
||||
|
||||
*public* matches(array $jsonType)
|
||||
|
||||
Checks data against passed JsonType.
|
||||
If matching fails function returns a string with a message describing failure.
|
||||
On success returns `true`.
|
||||
|
||||
* `param array` $jsonType
|
||||
* `return` bool|string
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/JsonType.php#L97)
|
||||
|
||||
#### typeComparison()
|
||||
|
||||
*protected* typeComparison($data, $jsonType)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/JsonType.php#L116)
|
||||
|
||||
<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/2.4/src//Codeception/Util/JsonType.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
308
vendor/codeception/base/docs/reference/Locator.md
vendored
Normal file
308
vendor/codeception/base/docs/reference/Locator.md
vendored
Normal file
@@ -0,0 +1,308 @@
|
||||
|
||||
## Codeception\Util\Locator
|
||||
|
||||
|
||||
|
||||
Set of useful functions for using CSS and XPath locators.
|
||||
Please check them before writing complex functional or acceptance tests.
|
||||
|
||||
|
||||
|
||||
#### combine()
|
||||
|
||||
*public static* combine($selector1, $selector2)
|
||||
|
||||
Applies OR operator to any number of CSS or XPath selectors.
|
||||
You can mix up CSS and XPath selectors here.
|
||||
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Util\Locator;
|
||||
|
||||
$I->see('Title', Locator::combine('h1','h2','h3'));
|
||||
?>
|
||||
```
|
||||
|
||||
This will search for `Title` text in either `h1`, `h2`, or `h3` tag.
|
||||
You can also combine CSS selector with XPath locator:
|
||||
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Util\Locator;
|
||||
|
||||
$I->fillField(Locator::combine('form input[type=text]','//form/textarea[2]'), 'qwerty');
|
||||
?>
|
||||
```
|
||||
|
||||
As a result the Locator will produce a mixed XPath value that will be used in fillField action.
|
||||
* `static`
|
||||
* `param` $selector1
|
||||
* `param` $selector2
|
||||
* `throws` \Exception
|
||||
* `return` string
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L50)
|
||||
|
||||
#### contains()
|
||||
|
||||
*public static* contains($element, $text)
|
||||
|
||||
Locates an element containing a text inside.
|
||||
Either CSS or XPath locator can be passed, however they will be converted to XPath.
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Codeception\Util\Locator;
|
||||
|
||||
Locator::contains('label', 'Name'); // label containing name
|
||||
Locator::contains('div[@contenteditable=true]', 'hello world');
|
||||
```
|
||||
|
||||
* `param` $element
|
||||
* `param` $text
|
||||
* `return` string
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L292)
|
||||
|
||||
#### elementAt()
|
||||
|
||||
*public static* elementAt($element, $position)
|
||||
|
||||
Locates element at position.
|
||||
Either CSS or XPath locator can be passed as locator,
|
||||
position is an integer. If a negative value is provided, counting starts from the last element.
|
||||
First element has index 1
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Codeception\Util\Locator;
|
||||
|
||||
Locator::elementAt('//table/tr', 2); // second row
|
||||
Locator::elementAt('//table/tr', -1); // last row
|
||||
Locator::elementAt('table#grind>tr', -2); // previous than last row
|
||||
```
|
||||
|
||||
* `param string` $element CSS or XPath locator
|
||||
* `param int` $position xpath index
|
||||
* `return` mixed
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L318)
|
||||
|
||||
#### find()
|
||||
|
||||
*public static* find($element, array $attributes)
|
||||
|
||||
Finds element by it's attribute(s)
|
||||
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Util\Locator;
|
||||
|
||||
$I->seeElement(Locator::find('img', ['title' => 'diagram']));
|
||||
```
|
||||
* `static`
|
||||
* `param` $element
|
||||
* `param` $attributes
|
||||
* `return` string
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L159)
|
||||
|
||||
#### firstElement()
|
||||
|
||||
*public static* firstElement($element)
|
||||
|
||||
Locates first element of group elements.
|
||||
Either CSS or XPath locator can be passed as locator,
|
||||
Equal to `Locator::elementAt($locator, 1)`
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Codeception\Util\Locator;
|
||||
|
||||
Locator::firstElement('//table/tr');
|
||||
```
|
||||
|
||||
* `param` $element
|
||||
* `return` mixed
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L348)
|
||||
|
||||
#### href()
|
||||
|
||||
*public static* href($url)
|
||||
|
||||
Matches the *a* element with given URL
|
||||
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Util\Locator;
|
||||
|
||||
$I->see('Log In', Locator::href('/login.php'));
|
||||
?>
|
||||
```
|
||||
* `static`
|
||||
* `param` $url
|
||||
* `return` string
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L79)
|
||||
|
||||
#### humanReadableString()
|
||||
|
||||
*public static* humanReadableString($selector)
|
||||
|
||||
Transforms strict locator, \Facebook\WebDriver\WebDriverBy into a string represenation
|
||||
|
||||
* `param` $selector
|
||||
* `return` string
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L381)
|
||||
|
||||
#### isCSS()
|
||||
|
||||
*public static* isCSS($selector)
|
||||
|
||||
Checks that provided string is CSS selector
|
||||
|
||||
```php
|
||||
<?php
|
||||
Locator::isCSS('#user .hello') => true
|
||||
Locator::isCSS('body') => true
|
||||
Locator::isCSS('//body/p/user') => false
|
||||
```
|
||||
|
||||
* `param` $selector
|
||||
* `return` bool
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L186)
|
||||
|
||||
#### isClass()
|
||||
|
||||
*public static* isClass($class)
|
||||
|
||||
Checks that a string is valid CSS class
|
||||
|
||||
```php
|
||||
<?php
|
||||
Locator::isClass('.hello') => true
|
||||
Locator::isClass('body') => false
|
||||
Locator::isClass('//body/p/user') => false
|
||||
```
|
||||
|
||||
* `param` $class
|
||||
* `return` bool
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L270)
|
||||
|
||||
#### isID()
|
||||
|
||||
*public static* isID($id)
|
||||
|
||||
Checks that a string is valid CSS ID
|
||||
|
||||
```php
|
||||
<?php
|
||||
Locator::isID('#user') => true
|
||||
Locator::isID('body') => false
|
||||
Locator::isID('//body/p/user') => false
|
||||
```
|
||||
|
||||
* `param` $id
|
||||
* `return` bool
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L252)
|
||||
|
||||
#### isPrecise()
|
||||
|
||||
*public static* isPrecise($locator)
|
||||
|
||||
* `param` $locator
|
||||
* `return` bool
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L221)
|
||||
|
||||
#### isXPath()
|
||||
|
||||
*public static* isXPath($locator)
|
||||
|
||||
Checks that locator is an XPath
|
||||
|
||||
```php
|
||||
<?php
|
||||
Locator::isXPath('#user .hello') => false
|
||||
Locator::isXPath('body') => false
|
||||
Locator::isXPath('//body/p/user') => true
|
||||
```
|
||||
|
||||
* `param` $locator
|
||||
* `return` bool
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L210)
|
||||
|
||||
#### lastElement()
|
||||
|
||||
*public static* lastElement($element)
|
||||
|
||||
Locates last element of group elements.
|
||||
Either CSS or XPath locator can be passed as locator,
|
||||
Equal to `Locator::elementAt($locator, -1)`
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Codeception\Util\Locator;
|
||||
|
||||
Locator::lastElement('//table/tr');
|
||||
```
|
||||
|
||||
* `param` $element
|
||||
* `return` mixed
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L369)
|
||||
|
||||
#### option()
|
||||
|
||||
*public static* option($value)
|
||||
|
||||
Matches option by text:
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Codeception\Util\Locator;
|
||||
|
||||
$I->seeElement(Locator::option('Male'), '#select-gender');
|
||||
```
|
||||
|
||||
* `param` $value
|
||||
* `return` string
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L124)
|
||||
|
||||
#### tabIndex()
|
||||
|
||||
*public static* tabIndex($index)
|
||||
|
||||
Matches the element with given tab index
|
||||
|
||||
Do you often use the `TAB` key to navigate through the web page? How do your site respond to this navigation?
|
||||
You could try to match elements by their tab position using `tabIndex` method of `Locator` class.
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Util\Locator;
|
||||
|
||||
$I->fillField(Locator::tabIndex(1), 'davert');
|
||||
$I->fillField(Locator::tabIndex(2) , 'qwerty');
|
||||
$I->click('Login');
|
||||
?>
|
||||
```
|
||||
* `static`
|
||||
* `param` $index
|
||||
* `return` string
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L105)
|
||||
|
||||
#### toXPath()
|
||||
|
||||
*protected static* toXPath($selector)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Locator.php#L129)
|
||||
|
||||
<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/2.4/src//Codeception/Util/Locator.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
364
vendor/codeception/base/docs/reference/Mock.md
vendored
Normal file
364
vendor/codeception/base/docs/reference/Mock.md
vendored
Normal file
@@ -0,0 +1,364 @@
|
||||
# Mocks
|
||||
|
||||
Declare mocks inside `Codeception\Test\Unit` class.
|
||||
If you want to use mocks outside it, check the reference for [Codeception/Stub](https://github.com/Codeception/Stub) library.
|
||||
|
||||
|
||||
#### *public* make($class, $params = null)
|
||||
Instantiates a class without executing a constructor.
|
||||
Properties and methods can be set as a second parameter.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->make('User');
|
||||
$this->make('User', ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->make(new User, ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in second parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->make('User', ['save' => function () { return true; }]);
|
||||
$this->make('User', ['save' => true]);
|
||||
```
|
||||
|
||||
* `param mixed` $class - A class to be mocked
|
||||
* `param array` $params - properties and methods to set
|
||||
|
||||
@return object - mock
|
||||
@throws \RuntimeException when class does not exist
|
||||
@throws \Exception
|
||||
|
||||
#### *public* makeEmpty($class, $params = null)
|
||||
Instantiates class having all methods replaced with dummies.
|
||||
Constructor is not triggered.
|
||||
Properties and methods can be set as a second parameter.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->makeEmpty('User');
|
||||
$this->makeEmpty('User', ['name' => 'davert']);
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->makeEmpty(new User, ['name' => 'davert']);
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in second parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->makeEmpty('User', ['save' => function () { return true; }]);
|
||||
$this->makeEmpty('User', ['save' => true));
|
||||
```
|
||||
|
||||
* `param mixed` $class
|
||||
* `param array` $params
|
||||
* `param bool|\PHPUnit\Framework\TestCase` $testCase
|
||||
|
||||
@return object
|
||||
@throws \Exception
|
||||
|
||||
#### *public* makeEmptyExcept($class, $method, $params = null)
|
||||
Instantiates class having all methods replaced with dummies except one.
|
||||
Constructor is not triggered.
|
||||
Properties and methods can be replaced.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->makeEmptyExcept('User', 'save');
|
||||
$this->makeEmptyExcept('User', 'save', ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
* $this->makeEmptyExcept(new User, 'save');
|
||||
?>
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in second parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->makeEmptyExcept('User', 'save', ['isValid' => function () { return true; }]);
|
||||
$this->makeEmptyExcept('User', 'save', ['isValid' => true]);
|
||||
```
|
||||
|
||||
* `param mixed` $class
|
||||
* `param string` $method
|
||||
* `param array` $params
|
||||
|
||||
@return object
|
||||
@throws \Exception
|
||||
|
||||
#### *public* construct($class, $constructorParams = null, $params = null)
|
||||
Instantiates a class instance by running constructor.
|
||||
Parameters for constructor passed as second argument
|
||||
Properties and methods can be set in third argument.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->construct('User', ['autosave' => false]);
|
||||
$this->construct('User', ['autosave' => false], ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->construct(new User, ['autosave' => false), ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in third parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->construct('User', [], ['save' => function () { return true; }]);
|
||||
$this->construct('User', [], ['save' => true]);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param mixed` $class
|
||||
* `param array` $constructorParams
|
||||
* `param array` $params
|
||||
* `param bool|\PHPUnit\Framework\TestCase` $testCase
|
||||
|
||||
@return object
|
||||
@throws \Exception
|
||||
|
||||
#### *public* constructEmpty($class, $constructorParams = null, $params = null)
|
||||
Instantiates a class instance by running constructor with all methods replaced with dummies.
|
||||
Parameters for constructor passed as second argument
|
||||
Properties and methods can be set in third argument.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->constructEmpty('User', ['autosave' => false]);
|
||||
$this->constructEmpty('User', ['autosave' => false), ['name' => 'davert']);
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->constructEmpty(new User, ['autosave' => false], ['name' => 'davert']);
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in third parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->constructEmpty('User', array(), array('save' => function () { return true; }));
|
||||
$this->constructEmpty('User', array(), array('save' => true));
|
||||
```
|
||||
|
||||
**To create a mock, pass current testcase name as last argument:**
|
||||
|
||||
```php
|
||||
<?php
|
||||
$this->constructEmpty('User', [], [
|
||||
'save' => \Codeception\Stub\Expected::once()
|
||||
]);
|
||||
```
|
||||
|
||||
* `param mixed` $class
|
||||
* `param array` $constructorParams
|
||||
* `param array` $params
|
||||
|
||||
@return object
|
||||
|
||||
#### *public* constructEmptyExcept($class, $method, $constructorParams = null, $params = null)
|
||||
Instantiates a class instance by running constructor with all methods replaced with dummies, except one.
|
||||
Parameters for constructor passed as second argument
|
||||
Properties and methods can be set in third argument.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->constructEmptyExcept('User', 'save');
|
||||
$this->constructEmptyExcept('User', 'save', ['autosave' => false], ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->constructEmptyExcept(new User, 'save', ['autosave' => false], ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in third parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$this->constructEmptyExcept('User', 'save', [], ['save' => function () { return true; }]);
|
||||
$this->constructEmptyExcept('User', 'save', [], ['save' => true]);
|
||||
?>
|
||||
```
|
||||
|
||||
* `param mixed` $class
|
||||
* `param string` $method
|
||||
* `param array` $constructorParams
|
||||
* `param array` $params
|
||||
|
||||
@return object
|
||||
|
||||
|
||||
|
||||
|
||||
#### *public static* never($params = null)
|
||||
Checks if a method never has been invoked
|
||||
|
||||
If method invoked, it will immediately throw an
|
||||
exception.
|
||||
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Stub\Expected;
|
||||
|
||||
$user = $this->make('User', [
|
||||
'getName' => Expected::never(),
|
||||
'someMethod' => function() {}
|
||||
]);
|
||||
$user->someMethod();
|
||||
?>
|
||||
```
|
||||
|
||||
* `param mixed` $params
|
||||
@return StubMarshaler
|
||||
|
||||
#### *public static* once($params = null)
|
||||
Checks if a method has been invoked exactly one
|
||||
time.
|
||||
|
||||
If the number is less or greater it will later be checked in verify() and also throw an
|
||||
exception.
|
||||
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Stub\Expected;
|
||||
|
||||
$user = $this->make(
|
||||
'User',
|
||||
array(
|
||||
'getName' => Expected::once('Davert'),
|
||||
'someMethod' => function() {}
|
||||
)
|
||||
);
|
||||
$userName = $user->getName();
|
||||
$this->assertEquals('Davert', $userName);
|
||||
?>
|
||||
```
|
||||
Alternatively, a function can be passed as parameter:
|
||||
|
||||
```php
|
||||
<?php
|
||||
Expected::once(function() { return Faker::name(); });
|
||||
```
|
||||
|
||||
* `param mixed` $params
|
||||
|
||||
@return StubMarshaler
|
||||
|
||||
#### *public static* atLeastOnce($params = null)
|
||||
Checks if a method has been invoked at least one
|
||||
time.
|
||||
|
||||
If the number of invocations is 0 it will throw an exception in verify.
|
||||
|
||||
```php
|
||||
<?php
|
||||
use \Codeception\Stub\Expected;
|
||||
|
||||
$user = $this->make(
|
||||
'User',
|
||||
array(
|
||||
'getName' => Expected::atLeastOnce('Davert')),
|
||||
'someMethod' => function() {}
|
||||
)
|
||||
);
|
||||
$user->getName();
|
||||
$userName = $user->getName();
|
||||
$this->assertEquals('Davert', $userName);
|
||||
?>
|
||||
```
|
||||
|
||||
Alternatively, a function can be passed as parameter:
|
||||
|
||||
```php
|
||||
<?php
|
||||
Expected::atLeastOnce(function() { return Faker::name(); });
|
||||
```
|
||||
|
||||
* `param mixed` $params
|
||||
|
||||
@return StubMarshaler
|
||||
|
||||
#### *public static* exactly($count, $params = null)
|
||||
Checks if a method has been invoked a certain amount
|
||||
of times.
|
||||
If the number of invocations exceeds the value it will immediately throw an
|
||||
exception,
|
||||
If the number is less it will later be checked in verify() and also throw an
|
||||
exception.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
use \Codeception\Stub;
|
||||
use \Codeception\Stub\Expected;
|
||||
|
||||
$user = $this->make(
|
||||
'User',
|
||||
array(
|
||||
'getName' => Expected::exactly(3, 'Davert'),
|
||||
'someMethod' => function() {}
|
||||
)
|
||||
);
|
||||
$user->getName();
|
||||
$user->getName();
|
||||
$userName = $user->getName();
|
||||
$this->assertEquals('Davert', $userName);
|
||||
?>
|
||||
```
|
||||
Alternatively, a function can be passed as parameter:
|
||||
|
||||
```php
|
||||
<?php
|
||||
Expected::exactly(function() { return Faker::name() });
|
||||
```
|
||||
|
||||
* `param int` $count
|
||||
* `param mixed` $params
|
||||
|
||||
@return StubMarshaler
|
||||
|
||||
|
||||
741
vendor/codeception/base/docs/reference/Module.md
vendored
Normal file
741
vendor/codeception/base/docs/reference/Module.md
vendored
Normal file
@@ -0,0 +1,741 @@
|
||||
|
||||
## Codeception\Module
|
||||
|
||||
|
||||
* *Uses* `Codeception\Util\Shared\Asserts`
|
||||
|
||||
Basic class for Modules and Helpers.
|
||||
You must extend from it while implementing own helpers.
|
||||
|
||||
Public methods of this class start with `_` prefix in order to ignore them in actor classes.
|
||||
Module contains **HOOKS** which allow to handle test execution routine.
|
||||
|
||||
|
||||
|
||||
|
||||
#### $includeInheritedActions
|
||||
|
||||
*public static* **$includeInheritedActions**
|
||||
|
||||
By setting it to false module wan't inherit methods of parent class.
|
||||
|
||||
type `bool`
|
||||
|
||||
|
||||
#### $onlyActions
|
||||
|
||||
*public static* **$onlyActions**
|
||||
|
||||
Allows to explicitly set what methods have this class.
|
||||
|
||||
type `array`
|
||||
|
||||
|
||||
#### $excludeActions
|
||||
|
||||
*public static* **$excludeActions**
|
||||
|
||||
Allows to explicitly exclude actions from module.
|
||||
|
||||
type `array`
|
||||
|
||||
|
||||
#### $aliases
|
||||
|
||||
*public static* **$aliases**
|
||||
|
||||
Allows to rename actions
|
||||
|
||||
type `array`
|
||||
#### __construct()
|
||||
|
||||
*public* __construct($moduleContainer, $config = null)
|
||||
|
||||
Module constructor.
|
||||
|
||||
Requires module container (to provide access between modules of suite) and config.
|
||||
|
||||
* `param ModuleContainer` $moduleContainer
|
||||
* `param null` $config
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L70)
|
||||
|
||||
#### _after()
|
||||
|
||||
*public* _after($test)
|
||||
|
||||
**HOOK** executed after test
|
||||
|
||||
* `param TestInterface` $test
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L253)
|
||||
|
||||
#### _afterStep()
|
||||
|
||||
*public* _afterStep($step)
|
||||
|
||||
**HOOK** executed after step
|
||||
|
||||
* `param Step` $step
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L235)
|
||||
|
||||
#### _afterSuite()
|
||||
|
||||
*public* _afterSuite()
|
||||
|
||||
**HOOK** executed after suite
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L217)
|
||||
|
||||
#### _before()
|
||||
|
||||
*public* _before($test)
|
||||
|
||||
**HOOK** executed before test
|
||||
|
||||
* `param TestInterface` $test
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L244)
|
||||
|
||||
#### _beforeStep()
|
||||
|
||||
*public* _beforeStep($step)
|
||||
|
||||
**HOOK** executed before step
|
||||
|
||||
* `param Step` $step
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L226)
|
||||
|
||||
#### _beforeSuite()
|
||||
|
||||
*public* _beforeSuite($settings = null)
|
||||
|
||||
**HOOK** executed before suite
|
||||
|
||||
* `param array` $settings
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L210)
|
||||
|
||||
#### _failed()
|
||||
|
||||
*public* _failed($test, $fail)
|
||||
|
||||
**HOOK** executed when test fails but before `_after`
|
||||
|
||||
* `param TestInterface` $test
|
||||
* `param \Exception` $fail
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L263)
|
||||
|
||||
#### _getConfig()
|
||||
|
||||
*public* _getConfig($key = null)
|
||||
|
||||
Get config values or specific config item.
|
||||
|
||||
* `param null` $key
|
||||
* `return` array|mixed|null
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L338)
|
||||
|
||||
#### _getName()
|
||||
|
||||
*public* _getName()
|
||||
|
||||
Returns a module name for a Module, a class name for Helper
|
||||
* `return` string
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L177)
|
||||
|
||||
#### _hasRequiredFields()
|
||||
|
||||
*public* _hasRequiredFields()
|
||||
|
||||
Checks if a module has required fields
|
||||
* `return` bool
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L193)
|
||||
|
||||
#### _initialize()
|
||||
|
||||
*public* _initialize()
|
||||
|
||||
**HOOK** triggered after module is created and configuration is loaded
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L201)
|
||||
|
||||
#### _reconfigure()
|
||||
|
||||
*public* _reconfigure($config)
|
||||
|
||||
Allows to redefine config for a specific test.
|
||||
Config is restored at the end of a test.
|
||||
|
||||
```php
|
||||
<?php
|
||||
// cleanup DB only for specific group of tests
|
||||
public function _before(Test $test) {
|
||||
if (in_array('cleanup', $test->getMetadata()->getGroups()) {
|
||||
$this->getModule('Db')->_reconfigure(['cleanup' => true]);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* `param` $config
|
||||
* `throws` Exception\ModuleConfigException
|
||||
* `throws` ModuleException
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L119)
|
||||
|
||||
#### _resetConfig()
|
||||
|
||||
*public* _resetConfig()
|
||||
|
||||
Reverts config changed by `_reconfigure`
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L137)
|
||||
|
||||
#### _setConfig()
|
||||
|
||||
*public* _setConfig($config)
|
||||
|
||||
Allows to define initial module config.
|
||||
Can be used in `_beforeSuite` hook of Helpers or Extensions
|
||||
|
||||
```php
|
||||
<?php
|
||||
public function _beforeSuite($settings = []) {
|
||||
$this->getModule('otherModule')->_setConfig($this->myOtherConfig);
|
||||
}
|
||||
```
|
||||
|
||||
* `param` $config
|
||||
* `throws` Exception\ModuleConfigException
|
||||
* `throws` ModuleException
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L95)
|
||||
|
||||
#### assert()
|
||||
|
||||
*protected* assert($arguments, $not = null)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L6)
|
||||
|
||||
#### assertArrayHasKey()
|
||||
|
||||
*protected* assertArrayHasKey($key, $actual, $description = null)
|
||||
|
||||
* `param` $key
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L385)
|
||||
|
||||
#### assertArrayNotHasKey()
|
||||
|
||||
*protected* assertArrayNotHasKey($key, $actual, $description = null)
|
||||
|
||||
* `param` $key
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L395)
|
||||
|
||||
#### assertArraySubset()
|
||||
|
||||
*protected* assertArraySubset($subset, $array, $strict = null, $message = null)
|
||||
|
||||
Checks that array contains subset.
|
||||
|
||||
* `param array` $subset
|
||||
* `param array` $array
|
||||
* `param bool` $strict
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L408)
|
||||
|
||||
#### assertContains()
|
||||
|
||||
*protected* assertContains($needle, $haystack, $message = null)
|
||||
|
||||
Checks that haystack contains needle
|
||||
|
||||
* `param` $needle
|
||||
* `param` $haystack
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L149)
|
||||
|
||||
#### assertCount()
|
||||
|
||||
*protected* assertCount($expectedCount, $actual, $description = null)
|
||||
|
||||
* `param` $expectedCount
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L418)
|
||||
|
||||
#### assertEmpty()
|
||||
|
||||
*protected* assertEmpty($actual, $message = null)
|
||||
|
||||
Checks that variable is empty.
|
||||
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L221)
|
||||
|
||||
#### assertEquals()
|
||||
|
||||
*protected* assertEquals($expected, $actual, $message = null, $delta = null)
|
||||
|
||||
Checks that two variables are equal.
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
* `param float` $delta
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L35)
|
||||
|
||||
#### assertFalse()
|
||||
|
||||
*protected* assertFalse($condition, $message = null)
|
||||
|
||||
Checks that condition is negative.
|
||||
|
||||
* `param` $condition
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L287)
|
||||
|
||||
#### assertFileExists()
|
||||
|
||||
*protected* assertFileExists($filename, $message = null)
|
||||
|
||||
Checks if file exists
|
||||
|
||||
* `param string` $filename
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L334)
|
||||
|
||||
#### assertFileNotExists()
|
||||
|
||||
*protected* assertFileNotExists($filename, $message = null)
|
||||
|
||||
Checks if file doesn't exist
|
||||
|
||||
* `param string` $filename
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L346)
|
||||
|
||||
#### assertGreaterOrEquals()
|
||||
|
||||
*protected* assertGreaterOrEquals($expected, $actual, $description = null)
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L356)
|
||||
|
||||
#### assertGreaterThan()
|
||||
|
||||
*protected* assertGreaterThan($expected, $actual, $message = null)
|
||||
|
||||
Checks that actual is greater than expected
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L84)
|
||||
|
||||
#### assertGreaterThanOrEqual()
|
||||
|
||||
*protected* assertGreaterThanOrEqual($expected, $actual, $message = null)
|
||||
|
||||
Checks that actual is greater or equal than expected
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L104)
|
||||
|
||||
#### assertGreaterThen()
|
||||
|
||||
*protected* assertGreaterThen($expected, $actual, $message = null)
|
||||
* `deprecated`
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L92)
|
||||
|
||||
#### assertGreaterThenOrEqual()
|
||||
|
||||
*protected* assertGreaterThenOrEqual($expected, $actual, $message = null)
|
||||
* `deprecated`
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L112)
|
||||
|
||||
#### assertInstanceOf()
|
||||
|
||||
*protected* assertInstanceOf($class, $actual, $description = null)
|
||||
|
||||
* `param` $class
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L428)
|
||||
|
||||
#### assertInternalType()
|
||||
|
||||
*protected* assertInternalType($type, $actual, $description = null)
|
||||
|
||||
* `param` $type
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L448)
|
||||
|
||||
#### assertIsEmpty()
|
||||
|
||||
*protected* assertIsEmpty($actual, $description = null)
|
||||
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L375)
|
||||
|
||||
#### assertLessOrEquals()
|
||||
|
||||
*protected* assertLessOrEquals($expected, $actual, $description = null)
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L366)
|
||||
|
||||
#### assertLessThan()
|
||||
|
||||
*protected* assertLessThan($expected, $actual, $message = null)
|
||||
|
||||
Checks that actual is less than expected
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L124)
|
||||
|
||||
#### assertLessThanOrEqual()
|
||||
|
||||
*protected* assertLessThanOrEqual($expected, $actual, $message = null)
|
||||
|
||||
Checks that actual is less or equal than expected
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L136)
|
||||
|
||||
#### assertNot()
|
||||
|
||||
*protected* assertNot($arguments)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L22)
|
||||
|
||||
#### assertNotContains()
|
||||
|
||||
*protected* assertNotContains($needle, $haystack, $message = null)
|
||||
|
||||
Checks that haystack doesn't contain needle.
|
||||
|
||||
* `param` $needle
|
||||
* `param` $haystack
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L161)
|
||||
|
||||
#### assertNotEmpty()
|
||||
|
||||
*protected* assertNotEmpty($actual, $message = null)
|
||||
|
||||
Checks that variable is not empty.
|
||||
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L232)
|
||||
|
||||
#### assertNotEquals()
|
||||
|
||||
*protected* assertNotEquals($expected, $actual, $message = null, $delta = null)
|
||||
|
||||
Checks that two variables are not equal
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
* `param float` $delta
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L48)
|
||||
|
||||
#### assertNotFalse()
|
||||
|
||||
*protected* assertNotFalse($condition, $message = null)
|
||||
|
||||
Checks that the condition is NOT false (everything but false)
|
||||
|
||||
* `param` $condition
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L298)
|
||||
|
||||
#### assertNotInstanceOf()
|
||||
|
||||
*protected* assertNotInstanceOf($class, $actual, $description = null)
|
||||
|
||||
* `param` $class
|
||||
* `param` $actual
|
||||
* `param` $description
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L438)
|
||||
|
||||
#### assertNotNull()
|
||||
|
||||
*protected* assertNotNull($actual, $message = null)
|
||||
|
||||
Checks that variable is not NULL
|
||||
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L254)
|
||||
|
||||
#### assertNotRegExp()
|
||||
|
||||
*protected* assertNotRegExp($pattern, $string, $message = null)
|
||||
|
||||
Checks that string not match with pattern
|
||||
|
||||
* `param string` $pattern
|
||||
* `param string` $string
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L185)
|
||||
|
||||
#### assertNotSame()
|
||||
|
||||
*protected* assertNotSame($expected, $actual, $message = null)
|
||||
|
||||
Checks that two variables are not same
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L72)
|
||||
|
||||
#### assertNotTrue()
|
||||
|
||||
*protected* assertNotTrue($condition, $message = null)
|
||||
|
||||
Checks that the condition is NOT true (everything but true)
|
||||
|
||||
* `param` $condition
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L276)
|
||||
|
||||
#### assertNull()
|
||||
|
||||
*protected* assertNull($actual, $message = null)
|
||||
|
||||
Checks that variable is NULL
|
||||
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L243)
|
||||
|
||||
#### assertRegExp()
|
||||
|
||||
*protected* assertRegExp($pattern, $string, $message = null)
|
||||
|
||||
Checks that string match with pattern
|
||||
|
||||
* `param string` $pattern
|
||||
* `param string` $string
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L173)
|
||||
|
||||
#### assertSame()
|
||||
|
||||
*protected* assertSame($expected, $actual, $message = null)
|
||||
|
||||
Checks that two variables are same
|
||||
|
||||
* `param` $expected
|
||||
* `param` $actual
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L60)
|
||||
|
||||
#### assertStringStartsNotWith()
|
||||
|
||||
*protected* assertStringStartsNotWith($prefix, $string, $message = null)
|
||||
|
||||
Checks that a string doesn't start with the given prefix.
|
||||
|
||||
* `param string` $prefix
|
||||
* `param string` $string
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L209)
|
||||
|
||||
#### assertStringStartsWith()
|
||||
|
||||
*protected* assertStringStartsWith($prefix, $string, $message = null)
|
||||
|
||||
Checks that a string starts with the given prefix.
|
||||
|
||||
* `param string` $prefix
|
||||
* `param string` $string
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L197)
|
||||
|
||||
#### assertThat()
|
||||
|
||||
*protected* assertThat($haystack, $constraint, $message = null)
|
||||
|
||||
|
||||
* `param` $haystack
|
||||
* `param` $constraint
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L309)
|
||||
|
||||
#### assertThatItsNot()
|
||||
|
||||
*protected* assertThatItsNot($haystack, $constraint, $message = null)
|
||||
|
||||
Checks that haystack doesn't attend
|
||||
|
||||
* `param` $haystack
|
||||
* `param` $constraint
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L321)
|
||||
|
||||
#### assertTrue()
|
||||
|
||||
*protected* assertTrue($condition, $message = null)
|
||||
|
||||
Checks that condition is positive.
|
||||
|
||||
* `param` $condition
|
||||
* `param string` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L265)
|
||||
|
||||
#### debug()
|
||||
|
||||
*protected* debug($message)
|
||||
|
||||
Print debug message to the screen.
|
||||
|
||||
* `param` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L272)
|
||||
|
||||
#### debugSection()
|
||||
|
||||
*protected* debugSection($title, $message)
|
||||
|
||||
Print debug message with a title
|
||||
|
||||
* `param` $title
|
||||
* `param` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L283)
|
||||
|
||||
#### fail()
|
||||
|
||||
*protected* fail($message)
|
||||
|
||||
Fails the test with message.
|
||||
|
||||
* `param` $message
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/Shared/Asserts.php#L458)
|
||||
|
||||
#### getModule()
|
||||
|
||||
*protected* getModule($name)
|
||||
|
||||
Get another module by its name:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$this->getModule('WebDriver')->_findElements('.items');
|
||||
```
|
||||
|
||||
* `param` $name
|
||||
* `return` Module
|
||||
* `throws` ModuleException
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L324)
|
||||
|
||||
#### getModules()
|
||||
|
||||
*protected* getModules()
|
||||
|
||||
Get all enabled modules
|
||||
* `return` array
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L307)
|
||||
|
||||
#### hasModule()
|
||||
|
||||
*protected* hasModule($name)
|
||||
|
||||
Checks that module is enabled.
|
||||
|
||||
* `param` $name
|
||||
* `return` bool
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L297)
|
||||
|
||||
#### onReconfigure()
|
||||
|
||||
*protected* onReconfigure()
|
||||
|
||||
HOOK to be executed when config changes with `_reconfigure`.
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L129)
|
||||
|
||||
#### scalarizeArray()
|
||||
|
||||
*protected* scalarizeArray($array)
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L349)
|
||||
|
||||
#### validateConfig()
|
||||
|
||||
*protected* validateConfig()
|
||||
|
||||
Validates current config for required fields and required packages.
|
||||
* `throws` Exception\ModuleConfigException
|
||||
* `throws` ModuleException
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php#L148)
|
||||
|
||||
<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
328
vendor/codeception/base/docs/reference/Stub.md
vendored
Normal file
328
vendor/codeception/base/docs/reference/Stub.md
vendored
Normal file
@@ -0,0 +1,328 @@
|
||||
|
||||
## Codeception\Stub
|
||||
|
||||
|
||||
|
||||
#### *public static* make($class, $params = null, $testCase = null)
|
||||
Instantiates a class without executing a constructor.
|
||||
Properties and methods can be set as a second parameter.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::make('User');
|
||||
Stub::make('User', ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::make(new User, ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in second parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::make('User', ['save' => function () { return true; }]);
|
||||
Stub::make('User', ['save' => true]);
|
||||
?>
|
||||
```
|
||||
|
||||
**To create a mock, pass current testcase name as last argument:**
|
||||
|
||||
```php
|
||||
<?php
|
||||
Stub::make('User', [
|
||||
'save' => \Codeception\Stub\Expected::once()
|
||||
], $this);
|
||||
```
|
||||
|
||||
* `param mixed` $class - A class to be mocked
|
||||
* `param array` $params - properties and methods to set
|
||||
* `param bool|\PHPUnit\Framework\TestCase` $testCase
|
||||
|
||||
* return object - mock
|
||||
* throws \RuntimeException when class does not exist
|
||||
* throws \Exception
|
||||
|
||||
#### *public static* factory($class, $num = null, $params = null)
|
||||
Creates $num instances of class through `Stub::make`.
|
||||
|
||||
* `param mixed` $class
|
||||
* `param int` $num
|
||||
* `param array` $params
|
||||
|
||||
* return array
|
||||
* throws \Exception
|
||||
|
||||
#### *public static* makeEmptyExcept($class, $method, $params = null, $testCase = null)
|
||||
Instantiates class having all methods replaced with dummies except one.
|
||||
Constructor is not triggered.
|
||||
Properties and methods can be replaced.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::makeEmptyExcept('User', 'save');
|
||||
Stub::makeEmptyExcept('User', 'save', ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
* Stub::makeEmptyExcept(new User, 'save');
|
||||
?>
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in second parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::makeEmptyExcept('User', 'save', ['isValid' => function () { return true; }]);
|
||||
Stub::makeEmptyExcept('User', 'save', ['isValid' => true]);
|
||||
?>
|
||||
```
|
||||
|
||||
**To create a mock, pass current testcase name as last argument:**
|
||||
|
||||
```php
|
||||
<?php
|
||||
Stub::makeEmptyExcept('User', 'validate', [
|
||||
'save' => \Codeception\Stub\Expected::once()
|
||||
], $this);
|
||||
```
|
||||
|
||||
* `param mixed` $class
|
||||
* `param string` $method
|
||||
* `param array` $params
|
||||
* `param bool|\PHPUnit\Framework\TestCase` $testCase
|
||||
|
||||
* return object
|
||||
* throws \Exception
|
||||
|
||||
#### *public static* makeEmpty($class, $params = null, $testCase = null)
|
||||
Instantiates class having all methods replaced with dummies.
|
||||
Constructor is not triggered.
|
||||
Properties and methods can be set as a second parameter.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::makeEmpty('User');
|
||||
Stub::makeEmpty('User', ['name' => 'davert']);
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::makeEmpty(new User, ['name' => 'davert']);
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in second parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::makeEmpty('User', ['save' => function () { return true; }]);
|
||||
Stub::makeEmpty('User', ['save' => true));
|
||||
```
|
||||
|
||||
**To create a mock, pass current testcase name as last argument:**
|
||||
|
||||
```php
|
||||
<?php
|
||||
Stub::makeEmpty('User', [
|
||||
'save' => \Codeception\Stub\Expected::once()
|
||||
], $this);
|
||||
```
|
||||
|
||||
* `param mixed` $class
|
||||
* `param array` $params
|
||||
* `param bool|\PHPUnit\Framework\TestCase` $testCase
|
||||
|
||||
* return object
|
||||
* throws \Exception
|
||||
|
||||
#### *public static* copy($obj, $params = null)
|
||||
Clones an object and redefines it's properties (even protected and private)
|
||||
|
||||
* `param` $obj
|
||||
* `param array` $params
|
||||
|
||||
* return mixed
|
||||
* throws \Exception
|
||||
|
||||
#### *public static* construct($class, $constructorParams = null, $params = null, $testCase = null)
|
||||
Instantiates a class instance by running constructor.
|
||||
Parameters for constructor passed as second argument
|
||||
Properties and methods can be set in third argument.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::construct('User', ['autosave' => false]);
|
||||
Stub::construct('User', ['autosave' => false], ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::construct(new User, ['autosave' => false), ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in third parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::construct('User', [], ['save' => function () { return true; }]);
|
||||
Stub::construct('User', [], ['save' => true]);
|
||||
?>
|
||||
```
|
||||
|
||||
**To create a mock, pass current testcase name as last argument:**
|
||||
|
||||
```php
|
||||
<?php
|
||||
Stub::construct('User', [], [
|
||||
'save' => \Codeception\Stub\Expected::once()
|
||||
], $this);
|
||||
```
|
||||
|
||||
* `param mixed` $class
|
||||
* `param array` $constructorParams
|
||||
* `param array` $params
|
||||
* `param bool|\PHPUnit\Framework\TestCase` $testCase
|
||||
|
||||
* return object
|
||||
* throws \Exception
|
||||
|
||||
#### *public static* constructEmpty($class, $constructorParams = null, $params = null, $testCase = null)
|
||||
Instantiates a class instance by running constructor with all methods replaced with dummies.
|
||||
Parameters for constructor passed as second argument
|
||||
Properties and methods can be set in third argument.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::constructEmpty('User', ['autosave' => false]);
|
||||
Stub::constructEmpty('User', ['autosave' => false), ['name' => 'davert']);
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::constructEmpty(new User, ['autosave' => false], ['name' => 'davert']);
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in third parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::constructEmpty('User', [], ['save' => function () { return true; }]);
|
||||
Stub::constructEmpty('User', [], ['save' => true]);
|
||||
```
|
||||
|
||||
**To create a mock, pass current testcase name as last argument:**
|
||||
|
||||
```php
|
||||
<?php
|
||||
Stub::constructEmpty('User', [], [
|
||||
'save' => \Codeception\Stub\Expected::once()
|
||||
], $this);
|
||||
```
|
||||
|
||||
* `param mixed` $class
|
||||
* `param array` $constructorParams
|
||||
* `param array` $params
|
||||
* `param bool|\PHPUnit\Framework\TestCase` $testCase
|
||||
|
||||
* return object
|
||||
|
||||
#### *public static* constructEmptyExcept($class, $method, $constructorParams = null, $params = null, $testCase = null)
|
||||
Instantiates a class instance by running constructor with all methods replaced with dummies, except one.
|
||||
Parameters for constructor passed as second argument
|
||||
Properties and methods can be set in third argument.
|
||||
Even protected and private properties can be set.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::constructEmptyExcept('User', 'save');
|
||||
Stub::constructEmptyExcept('User', 'save', ['autosave' => false], ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
Accepts either name of class or object of that class
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::constructEmptyExcept(new User, 'save', ['autosave' => false], ['name' => 'davert']);
|
||||
?>
|
||||
```
|
||||
|
||||
To replace method provide it's name as a key in third parameter
|
||||
and it's return value or callback function as parameter
|
||||
|
||||
``` php
|
||||
<?php
|
||||
Stub::constructEmptyExcept('User', 'save', [], ['save' => function () { return true; }]);
|
||||
Stub::constructEmptyExcept('User', 'save', [], ['save' => true]);
|
||||
?>
|
||||
```
|
||||
|
||||
**To create a mock, pass current testcase name as last argument:**
|
||||
|
||||
```php
|
||||
<?php
|
||||
Stub::constructEmptyExcept('User', 'save', [], [
|
||||
'save' => \Codeception\Stub\Expected::once()
|
||||
], $this);
|
||||
```
|
||||
|
||||
* `param mixed` $class
|
||||
* `param string` $method
|
||||
* `param array` $constructorParams
|
||||
* `param array` $params
|
||||
* `param bool|\PHPUnit\Framework\TestCase` $testCase
|
||||
|
||||
* return object
|
||||
|
||||
#### *public static* update($mock, array $params)
|
||||
Replaces properties of current stub
|
||||
|
||||
* `param \PHPUnit\Framework\MockObject\MockObject` $mock
|
||||
* `param array` $params
|
||||
|
||||
* return mixed
|
||||
* throws \LogicException
|
||||
|
||||
#### *public static* consecutive()
|
||||
Stubbing a method call to return a list of values in the specified order.
|
||||
|
||||
``` php
|
||||
<?php
|
||||
$user = Stub::make('User', array('getName' => Stub::consecutive('david', 'emma', 'sam', 'amy')));
|
||||
$user->getName(); //david
|
||||
$user->getName(); //emma
|
||||
$user->getName(); //sam
|
||||
$user->getName(); //amy
|
||||
?>
|
||||
```
|
||||
|
||||
* return ConsecutiveMap
|
||||
|
||||
|
||||
141
vendor/codeception/base/docs/reference/XmlBuilder.md
vendored
Normal file
141
vendor/codeception/base/docs/reference/XmlBuilder.md
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
|
||||
## Codeception\Util\XmlBuilder
|
||||
|
||||
|
||||
|
||||
That's a pretty simple yet powerful class to build XML structures in jQuery-like style.
|
||||
With no XML line actually written!
|
||||
Uses DOM extension to manipulate XML data.
|
||||
|
||||
|
||||
```php
|
||||
<?php
|
||||
$xml = new \Codeception\Util\XmlBuilder();
|
||||
$xml->users
|
||||
->user
|
||||
->val(1)
|
||||
->email
|
||||
->val('davert@mail.ua')
|
||||
->attr('valid','true')
|
||||
->parent()
|
||||
->cart
|
||||
->attr('empty','false')
|
||||
->items
|
||||
->item
|
||||
->val('useful item');
|
||||
->parents('user')
|
||||
->active
|
||||
->val(1);
|
||||
echo $xml;
|
||||
```
|
||||
|
||||
This will produce this XML
|
||||
|
||||
```xml
|
||||
<?xml version="1.0"?>
|
||||
<users>
|
||||
<user>
|
||||
1
|
||||
<email valid="true">davert@mail.ua</email>
|
||||
<cart empty="false">
|
||||
<items>
|
||||
<item>useful item</item>
|
||||
</items>
|
||||
</cart>
|
||||
<active>1</active>
|
||||
</user>
|
||||
</users>
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
Builder uses chained calls. So each call to builder returns a builder object.
|
||||
Except for `getDom` and `__toString` methods.
|
||||
|
||||
* `$xml->node` - create new xml node and go inside of it.
|
||||
* `$xml->node->val('value')` - sets the inner value of node
|
||||
* `$xml->attr('name','value')` - set the attribute of node
|
||||
* `$xml->parent()` - go back to parent node.
|
||||
* `$xml->parents('user')` - go back through all parents to `user` node.
|
||||
|
||||
Export:
|
||||
|
||||
* `$xml->getDom` - get a DOMDocument object
|
||||
* `$xml->__toString` - get a string representation of XML.
|
||||
|
||||
[Source code](https://github.com/Codeception/Codeception/blob/master/src/Codeception/Util/XmlBuilder.php)
|
||||
|
||||
|
||||
#### __construct()
|
||||
|
||||
*public* __construct()
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/XmlBuilder.php#L80)
|
||||
|
||||
#### __get()
|
||||
|
||||
*public* __get($tag)
|
||||
|
||||
Appends child node
|
||||
|
||||
* `param` $tag
|
||||
* `return` XmlBuilder
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/XmlBuilder.php#L93)
|
||||
|
||||
#### __toString()
|
||||
|
||||
*public* __toString()
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/XmlBuilder.php#L165)
|
||||
|
||||
#### attr()
|
||||
|
||||
*public* attr($attr, $val)
|
||||
|
||||
Sets attribute for current node
|
||||
|
||||
* `param` $attr
|
||||
* `param` $val
|
||||
* `return` XmlBuilder
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/XmlBuilder.php#L120)
|
||||
|
||||
#### getDom()
|
||||
|
||||
*public* getDom()
|
||||
* `return` \DOMDocument
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/XmlBuilder.php#L173)
|
||||
|
||||
#### parent()
|
||||
|
||||
*public* parent()
|
||||
|
||||
Traverses to parent
|
||||
* `return` XmlBuilder
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/XmlBuilder.php#L131)
|
||||
|
||||
#### parents()
|
||||
|
||||
*public* parents($tag)
|
||||
|
||||
Traverses to parent with $name
|
||||
|
||||
* `param` $tag
|
||||
* `return` XmlBuilder
|
||||
* `throws` \Exception
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/XmlBuilder.php#L145)
|
||||
|
||||
#### val()
|
||||
|
||||
*public* val($val)
|
||||
|
||||
* `param` $val
|
||||
* `return` XmlBuilder
|
||||
|
||||
[See source](https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Util/XmlBuilder.php#L106)
|
||||
|
||||
<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/2.4/src//Codeception/Util/XmlBuilder.php">Help us to improve documentation. Edit module reference</a></div>
|
||||
110
vendor/codeception/base/ext/DotReporter.php
vendored
Normal file
110
vendor/codeception/base/ext/DotReporter.php
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
namespace Codeception\Extension;
|
||||
|
||||
use Codeception\Event\FailEvent;
|
||||
use Codeception\Events;
|
||||
use Codeception\Extension;
|
||||
use Codeception\Subscriber\Console;
|
||||
|
||||
/**
|
||||
* DotReporter provides less verbose output for test execution.
|
||||
* Like PHPUnit printer it prints dots "." for successful testes and "F" for failures.
|
||||
*
|
||||
* 
|
||||
*
|
||||
* ```bash
|
||||
* ..........
|
||||
* ..........
|
||||
* ..........
|
||||
* ..........
|
||||
* ..........
|
||||
* ..........
|
||||
* ..........
|
||||
* ..........
|
||||
*
|
||||
* Time: 2.07 seconds, Memory: 20.00MB
|
||||
*
|
||||
* OK (80 tests, 124 assertions)
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* Enable this reporter with `--ext option`
|
||||
*
|
||||
* ```
|
||||
* codecept run --ext DotReporter
|
||||
* ```
|
||||
*
|
||||
* Failures and Errors are printed by a standard Codeception reporter.
|
||||
* Use this extension as an example for building custom reporters.
|
||||
*/
|
||||
class DotReporter extends Extension
|
||||
{
|
||||
/**
|
||||
* @var Console
|
||||
*/
|
||||
protected $standardReporter;
|
||||
|
||||
protected $errors = [];
|
||||
protected $failures = [];
|
||||
|
||||
protected $width = 10;
|
||||
protected $currentPos = 0;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
$this->options['silent'] = false; // turn on printing for this extension
|
||||
$this->_reconfigure(['settings' => ['silent' => true]]); // turn off printing for everything else
|
||||
$this->standardReporter = new Console($this->options);
|
||||
$this->width = $this->standardReporter->detectWidth();
|
||||
}
|
||||
|
||||
// we are listening for events
|
||||
public static $events = [
|
||||
Events::SUITE_BEFORE => 'beforeSuite',
|
||||
Events::TEST_SUCCESS => 'success',
|
||||
Events::TEST_FAIL => 'fail',
|
||||
Events::TEST_ERROR => 'error',
|
||||
Events::TEST_SKIPPED => 'skipped',
|
||||
Events::TEST_FAIL_PRINT => 'printFailed'
|
||||
];
|
||||
|
||||
public function beforeSuite()
|
||||
{
|
||||
$this->writeln("");
|
||||
}
|
||||
|
||||
public function success()
|
||||
{
|
||||
$this->printChar('.');
|
||||
}
|
||||
|
||||
public function fail(FailEvent $e)
|
||||
{
|
||||
$this->printChar("<error>F</error>");
|
||||
}
|
||||
|
||||
public function error(FailEvent $e)
|
||||
{
|
||||
$this->printChar('<error>E</error>');
|
||||
}
|
||||
|
||||
public function skipped()
|
||||
{
|
||||
$this->printChar('S');
|
||||
}
|
||||
|
||||
protected function printChar($char)
|
||||
{
|
||||
if ($this->currentPos >= $this->width) {
|
||||
$this->writeln('');
|
||||
$this->currentPos = 0;
|
||||
}
|
||||
$this->write($char);
|
||||
$this->currentPos++;
|
||||
}
|
||||
|
||||
public function printFailed(FailEvent $event)
|
||||
{
|
||||
$this->standardReporter->printFail($event);
|
||||
}
|
||||
}
|
||||
123
vendor/codeception/base/ext/Logger.php
vendored
Normal file
123
vendor/codeception/base/ext/Logger.php
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
namespace Codeception\Extension;
|
||||
|
||||
use Codeception\Event\FailEvent;
|
||||
use Codeception\Event\StepEvent;
|
||||
use Codeception\Event\SuiteEvent;
|
||||
use Codeception\Event\TestEvent;
|
||||
use Codeception\Events;
|
||||
use Codeception\Exception\ConfigurationException;
|
||||
use Codeception\Extension;
|
||||
use Codeception\Test\Descriptor;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
|
||||
/**
|
||||
* Log suites/tests/steps using Monolog library.
|
||||
* Monolog should be installed additionally by Composer.
|
||||
*
|
||||
* ```
|
||||
* composer require monolog/monolog
|
||||
* ```
|
||||
*
|
||||
* Steps are logged into `tests/_output/codeception.log`
|
||||
*
|
||||
* To enable this module add to your `codeception.yml`:
|
||||
*
|
||||
* ``` yaml
|
||||
* extensions:
|
||||
* enabled: [Codeception\Extension\Logger]
|
||||
* ```
|
||||
*
|
||||
* #### Config
|
||||
*
|
||||
* * `max_files` (default: 3) - how many log files to keep
|
||||
*
|
||||
*/
|
||||
class Logger extends Extension
|
||||
{
|
||||
public static $events = [
|
||||
Events::SUITE_BEFORE => 'beforeSuite',
|
||||
Events::TEST_BEFORE => 'beforeTest',
|
||||
Events::TEST_AFTER => 'afterTest',
|
||||
Events::TEST_END => 'endTest',
|
||||
Events::STEP_BEFORE => 'beforeStep',
|
||||
Events::TEST_FAIL => 'testFail',
|
||||
Events::TEST_ERROR => 'testError',
|
||||
Events::TEST_INCOMPLETE => 'testIncomplete',
|
||||
Events::TEST_SKIPPED => 'testSkipped',
|
||||
];
|
||||
|
||||
protected $logHandler;
|
||||
|
||||
/**
|
||||
* @var \Monolog\Logger
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
protected $path;
|
||||
|
||||
protected $config = ['max_files' => 3];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
if (!class_exists('\Monolog\Logger')) {
|
||||
throw new ConfigurationException("Logger extension requires Monolog library to be installed");
|
||||
}
|
||||
$this->path = $this->getLogDir();
|
||||
|
||||
// internal log
|
||||
$logHandler = new RotatingFileHandler($this->path . 'codeception.log', $this->config['max_files']);
|
||||
$this->logger = new \Monolog\Logger('Codeception');
|
||||
$this->logger->pushHandler($logHandler);
|
||||
}
|
||||
|
||||
public function beforeSuite(SuiteEvent $e)
|
||||
{
|
||||
$suite = str_replace('\\', '_', $e->getSuite()->getName());
|
||||
$this->logHandler = new RotatingFileHandler($this->path . $suite, $this->config['max_files']);
|
||||
}
|
||||
|
||||
public function beforeTest(TestEvent $e)
|
||||
{
|
||||
$this->logger = new \Monolog\Logger(Descriptor::getTestFileName($e->getTest()));
|
||||
$this->logger->pushHandler($this->logHandler);
|
||||
$this->logger->info('------------------------------------');
|
||||
$this->logger->info("STARTED: " . ucfirst(Descriptor::getTestAsString($e->getTest())));
|
||||
}
|
||||
|
||||
public function afterTest(TestEvent $e)
|
||||
{
|
||||
}
|
||||
|
||||
public function endTest(TestEvent $e)
|
||||
{
|
||||
$this->logger->info("PASSED");
|
||||
}
|
||||
|
||||
public function testFail(FailEvent $e)
|
||||
{
|
||||
$this->logger->alert($e->getFail()->getMessage());
|
||||
$this->logger->info("# FAILED #");
|
||||
}
|
||||
|
||||
public function testError(FailEvent $e)
|
||||
{
|
||||
$this->logger->alert($e->getFail()->getMessage());
|
||||
$this->logger->info("# ERROR #");
|
||||
}
|
||||
|
||||
public function testSkipped(FailEvent $e)
|
||||
{
|
||||
$this->logger->info("# Skipped #");
|
||||
}
|
||||
|
||||
public function testIncomplete(FailEvent $e)
|
||||
{
|
||||
$this->logger->info("# Incomplete #");
|
||||
}
|
||||
|
||||
public function beforeStep(StepEvent $e)
|
||||
{
|
||||
$this->logger->info((string) $e->getStep());
|
||||
}
|
||||
}
|
||||
221
vendor/codeception/base/ext/README.md
vendored
Normal file
221
vendor/codeception/base/ext/README.md
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
# Official Extensions
|
||||
|
||||
## DotReporter
|
||||
|
||||
[See Source](https://github.com/Codeception/Codeception/blob/2.4/ext/DotReporter.php)
|
||||
|
||||
DotReporter provides less verbose output for test execution.
|
||||
Like PHPUnit printer it prints dots "." for successful testes and "F" for failures.
|
||||
|
||||

|
||||
|
||||
```bash
|
||||
..........
|
||||
..........
|
||||
..........
|
||||
..........
|
||||
..........
|
||||
..........
|
||||
..........
|
||||
..........
|
||||
|
||||
Time: 2.07 seconds, Memory: 20.00MB
|
||||
|
||||
OK (80 tests, 124 assertions)
|
||||
```
|
||||
|
||||
|
||||
Enable this reporter with `--ext option`
|
||||
|
||||
```
|
||||
codecept run --ext DotReporter
|
||||
```
|
||||
|
||||
Failures and Errors are printed by a standard Codeception reporter.
|
||||
Use this extension as an example for building custom reporters.
|
||||
|
||||
|
||||
|
||||
## Logger
|
||||
|
||||
[See Source](https://github.com/Codeception/Codeception/blob/2.4/ext/Logger.php)
|
||||
|
||||
Log suites/tests/steps using Monolog library.
|
||||
Monolog should be installed additionally by Composer.
|
||||
|
||||
```
|
||||
composer require monolog/monolog
|
||||
```
|
||||
|
||||
Steps are logged into `tests/_output/codeception.log`
|
||||
|
||||
To enable this module add to your `codeception.yml`:
|
||||
|
||||
``` yaml
|
||||
extensions:
|
||||
enabled: [Codeception\Extension\Logger]
|
||||
```
|
||||
|
||||
#### Config
|
||||
|
||||
* `max_files` (default: 3) - how many log files to keep
|
||||
|
||||
|
||||
|
||||
|
||||
## Recorder
|
||||
|
||||
[See Source](https://github.com/Codeception/Codeception/blob/2.4/ext/Recorder.php)
|
||||
|
||||
Saves a screenshot of each step in acceptance tests and shows them as a slideshow on one HTML page (here's an [example](http://codeception.com/images/recorder.gif))
|
||||
Activated only for suites with WebDriver module enabled.
|
||||
|
||||
The screenshots are saved to `tests/_output/record_*` directories, open `index.html` to see them as a slideshow.
|
||||
|
||||
#### Installation
|
||||
|
||||
Add this to the list of enabled extensions in `codeception.yml` or `acceptance.suite.yml`:
|
||||
|
||||
``` yaml
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\Recorder
|
||||
```
|
||||
|
||||
#### Configuration
|
||||
|
||||
* `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.
|
||||
* `ignore_steps` (default: []) - array of step names that should not be recorded, * wildcards supported
|
||||
|
||||
|
||||
#### Examples:
|
||||
|
||||
``` yaml
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\Recorder:
|
||||
module: AngularJS # enable for Angular
|
||||
delete_successful: false # keep screenshots of successful tests
|
||||
ignore_steps: [have, grab*]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
## RunBefore
|
||||
|
||||
[See Source](https://github.com/Codeception/Codeception/blob/2.4/ext/RunBefore.php)
|
||||
|
||||
Extension for execution of some processes before running tests.
|
||||
|
||||
Processes can be independent and dependent.
|
||||
Independent processes run independently of each other.
|
||||
Dependent processes run sequentially one by one.
|
||||
|
||||
Can be configured in suite config:
|
||||
|
||||
```yaml
|
||||
# acceptance.suite.yml
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunBefore:
|
||||
- independent_process_1
|
||||
-
|
||||
- dependent_process_1_1
|
||||
- dependent_process_1_2
|
||||
- independent_process_2
|
||||
-
|
||||
- dependent_process_2_1
|
||||
- dependent_process_2_2
|
||||
```
|
||||
|
||||
HINT: you can use different configurations per environment.
|
||||
|
||||
|
||||
|
||||
## RunFailed
|
||||
|
||||
[See Source](https://github.com/Codeception/Codeception/blob/2.4/ext/RunFailed.php)
|
||||
|
||||
Saves failed tests into tests/log/failed in order to rerun failed tests.
|
||||
|
||||
To rerun failed tests just run the `failed` group:
|
||||
|
||||
```
|
||||
php codecept run -g failed
|
||||
```
|
||||
|
||||
To change failed group name add:
|
||||
```
|
||||
--override "extensions: config: Codeception\Extension\RunFailed: fail-group: another_group1"
|
||||
```
|
||||
Remember: if you run tests and they generated custom-named fail group, to run this group, you should add override too
|
||||
|
||||
Starting from Codeception 2.1 **this extension is enabled by default**.
|
||||
|
||||
``` yaml
|
||||
extensions:
|
||||
enabled: [Codeception\Extension\RunFailed]
|
||||
```
|
||||
|
||||
On each execution failed tests are logged and saved into `tests/_output/failed` file.
|
||||
|
||||
|
||||
|
||||
## RunProcess
|
||||
|
||||
[See Source](https://github.com/Codeception/Codeception/blob/2.4/ext/RunProcess.php)
|
||||
|
||||
Extension to start and stop processes per suite.
|
||||
Can be used to start/stop selenium server, chromedriver, phantomjs, mailcatcher, etc.
|
||||
|
||||
Can be configured in suite config:
|
||||
|
||||
```yaml
|
||||
# acceptance.suite.yml
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunProcess:
|
||||
- chromedriver
|
||||
```
|
||||
|
||||
Multiple parameters can be passed as array:
|
||||
|
||||
```yaml
|
||||
# acceptance.suite.yml
|
||||
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunProcess:
|
||||
- php -S 127.0.0.1:8000 -t tests/data/app
|
||||
- java -jar ~/selenium-server.jar
|
||||
```
|
||||
|
||||
In the end of a suite all launched processes will be stopped.
|
||||
|
||||
To wait for the process to be launched use `sleep` option.
|
||||
In this case you need configuration to be specified as object:
|
||||
|
||||
```yaml
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunProcess:
|
||||
0: java -jar ~/selenium-server.jar
|
||||
1: mailcatcher
|
||||
sleep: 5 # wait 5 seconds for processes to boot
|
||||
```
|
||||
|
||||
HINT: you can use different configurations per environment.
|
||||
|
||||
|
||||
|
||||
## SimpleReporter
|
||||
|
||||
[See Source](https://github.com/Codeception/Codeception/blob/2.4/ext/SimpleReporter.php)
|
||||
|
||||
This extension demonstrates how you can implement console output of your own.
|
||||
Recommended to be used for development purposes only.
|
||||
|
||||
|
||||
|
||||
438
vendor/codeception/base/ext/Recorder.php
vendored
Normal file
438
vendor/codeception/base/ext/Recorder.php
vendored
Normal file
@@ -0,0 +1,438 @@
|
||||
<?php
|
||||
|
||||
namespace Codeception\Extension;
|
||||
|
||||
use Codeception\Event\StepEvent;
|
||||
use Codeception\Event\TestEvent;
|
||||
use Codeception\Events;
|
||||
use Codeception\Exception\ExtensionException;
|
||||
use Codeception\Lib\Interfaces\ScreenshotSaver;
|
||||
use Codeception\Module\WebDriver;
|
||||
use Codeception\Step;
|
||||
use Codeception\Step\Comment as CommentStep;
|
||||
use Codeception\Test\Descriptor;
|
||||
use Codeception\Util\FileSystem;
|
||||
use Codeception\Util\Template;
|
||||
|
||||
/**
|
||||
* Saves a screenshot of each step in acceptance tests and shows them as a slideshow on one HTML page (here's an [example](http://codeception.com/images/recorder.gif))
|
||||
* Activated only for suites with WebDriver module enabled.
|
||||
*
|
||||
* The screenshots are saved to `tests/_output/record_*` directories, open `index.html` to see them as a slideshow.
|
||||
*
|
||||
* #### Installation
|
||||
*
|
||||
* Add this to the list of enabled extensions in `codeception.yml` or `acceptance.suite.yml`:
|
||||
*
|
||||
* ``` yaml
|
||||
* extensions:
|
||||
* enabled:
|
||||
* - Codeception\Extension\Recorder
|
||||
* ```
|
||||
*
|
||||
* #### Configuration
|
||||
*
|
||||
* * `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.
|
||||
* * `ignore_steps` (default: []) - array of step names that should not be recorded, * wildcards supported
|
||||
*
|
||||
*
|
||||
* #### Examples:
|
||||
*
|
||||
* ``` yaml
|
||||
* extensions:
|
||||
* enabled:
|
||||
* - Codeception\Extension\Recorder:
|
||||
* module: AngularJS # enable for Angular
|
||||
* delete_successful: false # keep screenshots of successful tests
|
||||
* ignore_steps: [have, grab*]
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
class Recorder extends \Codeception\Extension
|
||||
{
|
||||
protected $config = [
|
||||
'delete_successful' => true,
|
||||
'module' => 'WebDriver',
|
||||
'template' => null,
|
||||
'animate_slides' => true,
|
||||
'ignore_steps' => [],
|
||||
];
|
||||
|
||||
protected $template = <<<EOF
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Recorder Result</title>
|
||||
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
.carousel,
|
||||
.item,
|
||||
.active {
|
||||
height: 100%;
|
||||
}
|
||||
.navbar {
|
||||
margin-bottom: 0px !important;
|
||||
}
|
||||
.carousel-caption {
|
||||
background: rgba(0,0,0,0.8);
|
||||
padding-bottom: 50px !important;
|
||||
}
|
||||
.carousel-caption.error {
|
||||
background: #c0392b !important;
|
||||
}
|
||||
|
||||
.carousel-inner {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.fill {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
overflow-y: scroll;
|
||||
background-position: top;
|
||||
-webkit-background-size: cover;
|
||||
-moz-background-size: cover;
|
||||
background-size: cover;
|
||||
-o-background-size: cover;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Navigation -->
|
||||
<nav class="navbar navbar-default" role="navigation">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="#">{{feature}}
|
||||
<small>{{test}}</small>
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
<header id="steps" class="carousel{{carousel_class}}">
|
||||
<!-- Indicators -->
|
||||
<ol class="carousel-indicators">
|
||||
{{indicators}}
|
||||
</ol>
|
||||
|
||||
<!-- Wrapper for Slides -->
|
||||
<div class="carousel-inner">
|
||||
{{slides}}
|
||||
</div>
|
||||
|
||||
<!-- Controls -->
|
||||
<a class="left carousel-control" href="#steps" data-slide="prev">
|
||||
<span class="icon-prev"></span>
|
||||
</a>
|
||||
<a class="right carousel-control" href="#steps" data-slide="next">
|
||||
<span class="icon-next"></span>
|
||||
</a>
|
||||
|
||||
</header>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Script to Activate the Carousel -->
|
||||
<script>
|
||||
$('.carousel').carousel({
|
||||
wrap: true,
|
||||
interval: false
|
||||
})
|
||||
|
||||
$(document).bind('keyup', function(e) {
|
||||
if(e.keyCode==39){
|
||||
jQuery('a.carousel-control.right').trigger('click');
|
||||
}
|
||||
|
||||
else if(e.keyCode==37){
|
||||
jQuery('a.carousel-control.left').trigger('click');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
EOF;
|
||||
|
||||
protected $indicatorTemplate = <<<EOF
|
||||
<li data-target="#steps" data-slide-to="{{step}}" {{isActive}}></li>
|
||||
EOF;
|
||||
|
||||
protected $indexTemplate = <<<EOF
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Recorder Results Index</title>
|
||||
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Navigation -->
|
||||
<nav class="navbar navbar-default" role="navigation">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="#">Recorded Tests
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container">
|
||||
<h1>Record #{{seed}}</h1>
|
||||
<ul>
|
||||
{{records}}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
EOF;
|
||||
|
||||
protected $slidesTemplate = <<<EOF
|
||||
<div class="item {{isActive}}">
|
||||
<div class="fill">
|
||||
<img src="{{image}}">
|
||||
</div>
|
||||
<div class="carousel-caption {{isError}}">
|
||||
<h2>{{caption}}</h2>
|
||||
<small>scroll up and down to see the full page</small>
|
||||
</div>
|
||||
</div>
|
||||
EOF;
|
||||
|
||||
public static $events = [
|
||||
Events::SUITE_BEFORE => 'beforeSuite',
|
||||
Events::SUITE_AFTER => 'afterSuite',
|
||||
Events::TEST_BEFORE => 'before',
|
||||
Events::TEST_ERROR => 'persist',
|
||||
Events::TEST_FAIL => 'persist',
|
||||
Events::TEST_SUCCESS => 'cleanup',
|
||||
Events::STEP_AFTER => 'afterStep',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var WebDriver
|
||||
*/
|
||||
protected $webDriverModule;
|
||||
protected $dir;
|
||||
protected $slides = [];
|
||||
protected $stepNum = 0;
|
||||
protected $seed;
|
||||
protected $recordedTests = [];
|
||||
protected $errors = [];
|
||||
protected $errorMessages = [];
|
||||
|
||||
public function beforeSuite()
|
||||
{
|
||||
$this->webDriverModule = null;
|
||||
if (!$this->hasModule($this->config['module'])) {
|
||||
$this->writeln("Recorder is disabled, no available modules");
|
||||
return;
|
||||
}
|
||||
$this->seed = uniqid();
|
||||
$this->webDriverModule = $this->getModule($this->config['module']);
|
||||
if (!$this->webDriverModule instanceof ScreenshotSaver) {
|
||||
throw new ExtensionException(
|
||||
$this,
|
||||
'You should pass module which implements Codeception\Lib\Interfaces\ScreenshotSaver interface'
|
||||
);
|
||||
}
|
||||
$this->writeln(sprintf(
|
||||
"⏺ <bold>Recording</bold> ⏺ step-by-step screenshots will be saved to <info>%s</info>",
|
||||
codecept_output_dir()
|
||||
));
|
||||
$this->writeln("Directory Format: <debug>record_{$this->seed}_{testname}</debug> ----");
|
||||
}
|
||||
|
||||
public function afterSuite()
|
||||
{
|
||||
if (!$this->webDriverModule or !$this->dir) {
|
||||
return;
|
||||
}
|
||||
$links = '';
|
||||
|
||||
if (count($this->slides)) {
|
||||
foreach ($this->recordedTests as $link => $url) {
|
||||
$links .= "<li><a href='$url'>$link</a></li>\n";
|
||||
}
|
||||
$indexHTML = (new Template($this->indexTemplate))
|
||||
->place('seed', $this->seed)
|
||||
->place('records', $links)
|
||||
->produce();
|
||||
|
||||
file_put_contents(codecept_output_dir() . 'records.html', $indexHTML);
|
||||
$this->writeln("⏺ Records saved into: <info>file://" . codecept_output_dir() . 'records.html</info>');
|
||||
}
|
||||
|
||||
foreach ($this->errors as $testPath => $screenshotPath) {
|
||||
while (count($this->errorMessages[$testPath])) {
|
||||
$this->writeln(array_pop($this->errorMessages[$testPath]));
|
||||
}
|
||||
|
||||
if ($screenshotPath !== null) {
|
||||
$this->writeln("⏺ Screenshot saved into: <info>file://{$screenshotPath}</info>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function before(TestEvent $e)
|
||||
{
|
||||
if (!$this->webDriverModule) {
|
||||
return;
|
||||
}
|
||||
$this->dir = null;
|
||||
$this->stepNum = 0;
|
||||
$this->slides = [];
|
||||
$this->errors = [];
|
||||
$this->errorMessages = [];
|
||||
|
||||
$testName = preg_replace('~\W~', '_', Descriptor::getTestAsString($e->getTest()));
|
||||
$this->dir = codecept_output_dir() . "record_{$this->seed}_$testName";
|
||||
@mkdir($this->dir);
|
||||
}
|
||||
|
||||
public function cleanup(TestEvent $e)
|
||||
{
|
||||
if (!$this->webDriverModule or !$this->dir) {
|
||||
return;
|
||||
}
|
||||
if (!$this->config['delete_successful']) {
|
||||
$this->persist($e);
|
||||
return;
|
||||
}
|
||||
|
||||
// deleting successfully executed tests
|
||||
FileSystem::deleteDir($this->dir);
|
||||
}
|
||||
|
||||
public function persist(TestEvent $e)
|
||||
{
|
||||
if (!$this->webDriverModule) {
|
||||
return;
|
||||
}
|
||||
$indicatorHtml = '';
|
||||
$slideHtml = '';
|
||||
|
||||
$testName = preg_replace('~\W~', '_', Descriptor::getTestAsString($e->getTest()));
|
||||
$testPath = codecept_relative_path(Descriptor::getTestFullName($e->getTest()));
|
||||
$dir = codecept_output_dir() . "record_{$this->seed}_$testName";
|
||||
|
||||
if ($this->dir !== $dir) {
|
||||
$screenshotPath = "{$dir}/error.png";
|
||||
@mkdir($dir);
|
||||
$this->errors = [];
|
||||
$this->recordedTests = [];
|
||||
$this->slides = [];
|
||||
$this->errorMessages[$testPath] = [
|
||||
"⏺ An error has occurred in <info>{$testName}</info> before any steps could've executed",
|
||||
];
|
||||
|
||||
try {
|
||||
$this->webDriverModule->webDriver->takeScreenshot($screenshotPath);
|
||||
$this->errors[$testPath] = $screenshotPath;
|
||||
} catch (\Exception $exception) {
|
||||
$this->errors[$testPath] = null;
|
||||
FileSystem::deleteDir($dir);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!array_key_exists($testPath, $this->errors)) {
|
||||
foreach ($this->slides as $i => $step) {
|
||||
$indicatorHtml .= (new Template($this->indicatorTemplate))
|
||||
->place('step', (int)$i)
|
||||
->place('isActive', (int)$i ? '' : 'class="active"')
|
||||
->produce();
|
||||
|
||||
$slideHtml .= (new Template($this->slidesTemplate))
|
||||
->place('image', $i)
|
||||
->place('caption', $step->getHtml('#3498db'))
|
||||
->place('isActive', (int)$i ? '' : 'active')
|
||||
->place('isError', $step->hasFailed() ? 'error' : '')
|
||||
->produce();
|
||||
}
|
||||
|
||||
$html = (new Template($this->template))
|
||||
->place('indicators', $indicatorHtml)
|
||||
->place('slides', $slideHtml)
|
||||
->place('feature', ucfirst($e->getTest()->getFeature()))
|
||||
->place('test', Descriptor::getTestSignature($e->getTest()))
|
||||
->place('carousel_class', $this->config['animate_slides'] ? ' slide' : '')
|
||||
->produce();
|
||||
|
||||
$indexFile = $this->dir . DIRECTORY_SEPARATOR . 'index.html';
|
||||
file_put_contents($indexFile, $html);
|
||||
$testName = Descriptor::getTestSignature($e->getTest()). ' - '.ucfirst($e->getTest()->getFeature());
|
||||
$this->recordedTests[$testName] = substr($indexFile, strlen(codecept_output_dir()));
|
||||
}
|
||||
}
|
||||
|
||||
public function afterStep(StepEvent $e)
|
||||
{
|
||||
if (!$this->webDriverModule or !$this->dir) {
|
||||
return;
|
||||
}
|
||||
if ($e->getStep() instanceof CommentStep) {
|
||||
return;
|
||||
}
|
||||
if ($this->isStepIgnored($e->getStep())) {
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = str_pad($this->stepNum, 3, "0", STR_PAD_LEFT) . '.png';
|
||||
|
||||
try {
|
||||
$this->webDriverModule->webDriver->takeScreenshot($this->dir . DIRECTORY_SEPARATOR . $filename);
|
||||
} catch (\Exception $exception) {
|
||||
$testPath = codecept_relative_path(Descriptor::getTestFullName($e->getTest()));
|
||||
$this->errors[$testPath] = null;
|
||||
|
||||
if (array_key_exists($testPath, $this->errorMessages)) {
|
||||
$this->errorMessages[$testPath] = array_merge(
|
||||
$this->errorMessages[$testPath],
|
||||
["⏺ Unable to capture a screenshot for <info>{$testPath}/{$e->getStep()->getAction()}</info>"]
|
||||
);
|
||||
} else {
|
||||
$this->errorMessages[$testPath] = [
|
||||
"⏺ Unable to capture a screenshot for <info>{$testPath}/{$e->getStep()->getAction()}</info>",
|
||||
];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->stepNum++;
|
||||
$this->slides[$filename] = $e->getStep();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Step $step
|
||||
* @return bool
|
||||
*/
|
||||
protected function isStepIgnored($step)
|
||||
{
|
||||
foreach ($this->config['ignore_steps'] as $stepPattern) {
|
||||
$stepRegexp = '/^' . str_replace('*', '.*?', $stepPattern) . '$/i';
|
||||
if (preg_match($stepRegexp, $step->getAction())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
145
vendor/codeception/base/ext/RunBefore.php
vendored
Normal file
145
vendor/codeception/base/ext/RunBefore.php
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Codeception\Extension;
|
||||
|
||||
use Codeception\Events;
|
||||
use Codeception\Exception\ExtensionException;
|
||||
use Codeception\Extension;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* Extension for execution of some processes before running tests.
|
||||
*
|
||||
* Processes can be independent and dependent.
|
||||
* Independent processes run independently of each other.
|
||||
* Dependent processes run sequentially one by one.
|
||||
*
|
||||
* Can be configured in suite config:
|
||||
*
|
||||
* ```yaml
|
||||
* # acceptance.suite.yml
|
||||
* extensions:
|
||||
* enabled:
|
||||
* - Codeception\Extension\RunBefore:
|
||||
* - independent_process_1
|
||||
* -
|
||||
* - dependent_process_1_1
|
||||
* - dependent_process_1_2
|
||||
* - independent_process_2
|
||||
* -
|
||||
* - dependent_process_2_1
|
||||
* - dependent_process_2_2
|
||||
* ```
|
||||
*
|
||||
* HINT: you can use different configurations per environment.
|
||||
*/
|
||||
class RunBefore extends Extension
|
||||
{
|
||||
protected $config = [];
|
||||
|
||||
protected static $events = [
|
||||
Events::SUITE_BEFORE => 'runBefore'
|
||||
];
|
||||
|
||||
/** @var array[] */
|
||||
private $processes = [];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
if (!class_exists('Symfony\Component\Process\Process')) {
|
||||
throw new ExtensionException($this, 'symfony/process package is required');
|
||||
}
|
||||
}
|
||||
|
||||
public function runBefore()
|
||||
{
|
||||
$this->runProcesses();
|
||||
$this->processMonitoring();
|
||||
}
|
||||
|
||||
private function runProcesses()
|
||||
{
|
||||
foreach ($this->config as $item) {
|
||||
if (is_array($item)) {
|
||||
$currentCommand = array_shift($item);
|
||||
$followingCommands = $item;
|
||||
} else {
|
||||
$currentCommand = $item;
|
||||
$followingCommands = [];
|
||||
}
|
||||
|
||||
$process = $this->runProcess($currentCommand);
|
||||
$this->addProcessToMonitoring($process, $followingCommands);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $command
|
||||
* @return Process
|
||||
*/
|
||||
private function runProcess($command)
|
||||
{
|
||||
$this->output->debug('[RunBefore] Starting ' . $command);
|
||||
$process = new Process($command, $this->getRootDir());
|
||||
$process->start();
|
||||
|
||||
return $process;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $followingCommands
|
||||
*/
|
||||
private function addProcessToMonitoring(Process $process, array $followingCommands)
|
||||
{
|
||||
$this->processes[] = [
|
||||
'instance' => $process,
|
||||
'following' => $followingCommands
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $index
|
||||
*/
|
||||
private function removeProcessFromMonitoring($index)
|
||||
{
|
||||
unset($this->processes[$index]);
|
||||
}
|
||||
|
||||
private function processMonitoring()
|
||||
{
|
||||
while (count($this->processes) !== 0) {
|
||||
$this->checkProcesses();
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function checkProcesses()
|
||||
{
|
||||
foreach ($this->processes as $index => $process) {
|
||||
if (!$this->isRunning($process['instance'])) {
|
||||
$this->output->debug('[RunBefore] Completing ' . $process['instance']->getCommandLine());
|
||||
$this->runFollowingCommand($process['following']);
|
||||
$this->removeProcessFromMonitoring($index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $followingCommands
|
||||
*/
|
||||
private function runFollowingCommand(array $followingCommands)
|
||||
{
|
||||
if (count($followingCommands) > 0) {
|
||||
$process = $this->runProcess(array_shift($followingCommands));
|
||||
$this->addProcessToMonitoring($process, $followingCommands);
|
||||
}
|
||||
}
|
||||
|
||||
private function isRunning(Process $process)
|
||||
{
|
||||
if ($process->isRunning()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
80
vendor/codeception/base/ext/RunFailed.php
vendored
Normal file
80
vendor/codeception/base/ext/RunFailed.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
namespace Codeception\Extension;
|
||||
|
||||
use Codeception\Event\PrintResultEvent;
|
||||
use Codeception\Events;
|
||||
use Codeception\Extension;
|
||||
use Codeception\Test\Descriptor;
|
||||
|
||||
/**
|
||||
* Saves failed tests into tests/log/failed in order to rerun failed tests.
|
||||
*
|
||||
* To rerun failed tests just run the `failed` group:
|
||||
*
|
||||
* ```
|
||||
* php codecept run -g failed
|
||||
* ```
|
||||
*
|
||||
* To change failed group name add:
|
||||
* ```
|
||||
* --override "extensions: config: Codeception\Extension\RunFailed: fail-group: another_group1"
|
||||
* ```
|
||||
* Remember: if you run tests and they generated custom-named fail group, to run this group, you should add override too
|
||||
*
|
||||
* Starting from Codeception 2.1 **this extension is enabled by default**.
|
||||
*
|
||||
* ``` yaml
|
||||
* extensions:
|
||||
* enabled: [Codeception\Extension\RunFailed]
|
||||
* ```
|
||||
*
|
||||
* On each execution failed tests are logged and saved into `tests/_output/failed` file.
|
||||
*/
|
||||
class RunFailed extends Extension
|
||||
{
|
||||
public static $events = [
|
||||
Events::RESULT_PRINT_AFTER => 'saveFailed'
|
||||
];
|
||||
|
||||
/** @var string filename/groupname for failed tests */
|
||||
protected $group = 'failed';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
if (array_key_exists('fail-group', $this->config) && $this->config['fail-group']) {
|
||||
$this->group = $this->config['fail-group'];
|
||||
}
|
||||
$logPath = str_replace($this->getRootDir(), '', $this->getLogDir()); // get local path to logs
|
||||
$this->_reconfigure(['groups' => [$this->group => $logPath . $this->group]]);
|
||||
}
|
||||
|
||||
public function saveFailed(PrintResultEvent $e)
|
||||
{
|
||||
$file = $this->getLogDir() . $this->group;
|
||||
$result = $e->getResult();
|
||||
if ($result->wasSuccessful()) {
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
return;
|
||||
}
|
||||
$output = [];
|
||||
foreach ($result->failures() as $fail) {
|
||||
$output[] = $this->localizePath(Descriptor::getTestFullName($fail->failedTest()));
|
||||
}
|
||||
foreach ($result->errors() as $fail) {
|
||||
$output[] = $this->localizePath(Descriptor::getTestFullName($fail->failedTest()));
|
||||
}
|
||||
|
||||
file_put_contents($file, implode("\n", $output));
|
||||
}
|
||||
|
||||
protected function localizePath($path)
|
||||
{
|
||||
$root = realpath($this->getRootDir()) . DIRECTORY_SEPARATOR;
|
||||
if (substr($path, 0, strlen($root)) == $root) {
|
||||
return substr($path, strlen($root));
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
105
vendor/codeception/base/ext/RunProcess.php
vendored
Normal file
105
vendor/codeception/base/ext/RunProcess.php
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace Codeception\Extension;
|
||||
|
||||
use Codeception\Events;
|
||||
use Codeception\Exception\ExtensionException;
|
||||
use Codeception\Extension;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* Extension to start and stop processes per suite.
|
||||
* Can be used to start/stop selenium server, chromedriver, phantomjs, mailcatcher, etc.
|
||||
*
|
||||
* Can be configured in suite config:
|
||||
*
|
||||
* ```yaml
|
||||
* # acceptance.suite.yml
|
||||
* extensions:
|
||||
* enabled:
|
||||
* - Codeception\Extension\RunProcess:
|
||||
* - chromedriver
|
||||
* ```
|
||||
*
|
||||
* Multiple parameters can be passed as array:
|
||||
*
|
||||
* ```yaml
|
||||
* # acceptance.suite.yml
|
||||
*
|
||||
* extensions:
|
||||
* enabled:
|
||||
* - Codeception\Extension\RunProcess:
|
||||
* - php -S 127.0.0.1:8000 -t tests/data/app
|
||||
* - java -jar ~/selenium-server.jar
|
||||
* ```
|
||||
*
|
||||
* In the end of a suite all launched processes will be stopped.
|
||||
*
|
||||
* To wait for the process to be launched use `sleep` option.
|
||||
* In this case you need configuration to be specified as object:
|
||||
*
|
||||
* ```yaml
|
||||
* extensions:
|
||||
* enabled:
|
||||
* - Codeception\Extension\RunProcess:
|
||||
* 0: java -jar ~/selenium-server.jar
|
||||
* 1: mailcatcher
|
||||
* sleep: 5 # wait 5 seconds for processes to boot
|
||||
* ```
|
||||
*
|
||||
* HINT: you can use different configurations per environment.
|
||||
*/
|
||||
class RunProcess extends Extension
|
||||
{
|
||||
public $config = ['sleep' => 0];
|
||||
|
||||
static $events = [
|
||||
Events::SUITE_BEFORE => 'runProcess',
|
||||
Events::SUITE_AFTER => 'stopProcess'
|
||||
];
|
||||
|
||||
protected $processes = [];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
if (!class_exists('Symfony\Component\Process\Process')) {
|
||||
throw new ExtensionException($this, 'symfony/process package is required');
|
||||
}
|
||||
}
|
||||
|
||||
public function runProcess()
|
||||
{
|
||||
$this->processes = [];
|
||||
foreach ($this->config as $key => $command) {
|
||||
if (!$command) {
|
||||
continue;
|
||||
}
|
||||
if (!is_int($key)) {
|
||||
continue; // configuration options
|
||||
}
|
||||
$process = new Process($command, $this->getRootDir(), null, null, null);
|
||||
$process->start();
|
||||
$this->processes[] = $process;
|
||||
$this->output->debug('[RunProcess] Starting '.$command);
|
||||
}
|
||||
sleep($this->config['sleep']);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->stopProcess();
|
||||
}
|
||||
|
||||
public function stopProcess()
|
||||
{
|
||||
foreach (array_reverse($this->processes) as $process) {
|
||||
/** @var $process Process **/
|
||||
if (!$process->isRunning()) {
|
||||
continue;
|
||||
}
|
||||
$this->output->debug('[RunProcess] Stopping ' . $process->getCommandLine());
|
||||
$process->stop();
|
||||
}
|
||||
$this->processes = [];
|
||||
}
|
||||
}
|
||||
61
vendor/codeception/base/ext/SimpleReporter.php
vendored
Normal file
61
vendor/codeception/base/ext/SimpleReporter.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace Codeception\Extension;
|
||||
|
||||
use Codeception\Event\TestEvent;
|
||||
use Codeception\Events;
|
||||
use Codeception\Extension;
|
||||
use Codeception\Test\Descriptor;
|
||||
|
||||
/**
|
||||
* This extension demonstrates how you can implement console output of your own.
|
||||
* Recommended to be used for development purposes only.
|
||||
*/
|
||||
class SimpleReporter extends Extension
|
||||
{
|
||||
public function _initialize()
|
||||
{
|
||||
$this->options['silent'] = false; // turn on printing for this extension
|
||||
$this->_reconfigure(['settings' => ['silent' => true]]); // turn off printing for everything else
|
||||
}
|
||||
|
||||
// we are listening for events
|
||||
public static $events = [
|
||||
Events::SUITE_BEFORE => 'beforeSuite',
|
||||
Events::TEST_END => 'after',
|
||||
Events::TEST_SUCCESS => 'success',
|
||||
Events::TEST_FAIL => 'fail',
|
||||
Events::TEST_ERROR => 'error',
|
||||
];
|
||||
|
||||
public function beforeSuite()
|
||||
{
|
||||
$this->writeln("");
|
||||
}
|
||||
|
||||
public function success()
|
||||
{
|
||||
$this->write('[+] ');
|
||||
}
|
||||
|
||||
public function fail()
|
||||
{
|
||||
$this->write('[-] ');
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
$this->write('[E] ');
|
||||
}
|
||||
|
||||
// we are printing test status and time taken
|
||||
public function after(TestEvent $e)
|
||||
{
|
||||
$seconds_input = $e->getTime();
|
||||
// stack overflow: http://stackoverflow.com/questions/16825240/how-to-convert-microtime-to-hhmmssuu
|
||||
$seconds = (int)($milliseconds = (int)($seconds_input * 1000)) / 1000;
|
||||
$time = ($seconds % 60) . (($milliseconds === 0) ? '' : '.' . $milliseconds);
|
||||
|
||||
$this->write(Descriptor::getTestSignature($e->getTest()));
|
||||
$this->writeln(' (' . $time . 's)');
|
||||
}
|
||||
}
|
||||
8
vendor/codeception/base/nitpick.json
vendored
Normal file
8
vendor/codeception/base/nitpick.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"ignore": [
|
||||
"tests/*",
|
||||
"RoboFile.php",
|
||||
"shim.php",
|
||||
"phpunit5-loggers.php"
|
||||
]
|
||||
}
|
||||
37
vendor/codeception/base/package/bin
vendored
Normal file
37
vendor/codeception/base/package/bin
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Codeception CLI
|
||||
*/
|
||||
|
||||
use Codeception\Application;
|
||||
|
||||
$app = new Application('Codeception', Codeception\Codecept::VERSION);
|
||||
$app->add(new Codeception\Command\Build('build'));
|
||||
$app->add(new Codeception\Command\Run('run'));
|
||||
$app->add(new Codeception\Command\Init('init'));
|
||||
$app->add(new Codeception\Command\Console('console'));
|
||||
$app->add(new Codeception\Command\Bootstrap('bootstrap'));
|
||||
$app->add(new Codeception\Command\GenerateCept('generate:cept'));
|
||||
$app->add(new Codeception\Command\GenerateCest('generate:cest'));
|
||||
$app->add(new Codeception\Command\GenerateTest('generate:test'));
|
||||
$app->add(new Codeception\Command\GenerateSuite('generate:suite'));
|
||||
$app->add(new Codeception\Command\GenerateHelper('generate:helper'));
|
||||
$app->add(new Codeception\Command\GenerateScenarios('generate:scenarios'));
|
||||
$app->add(new Codeception\Command\Clean('clean'));
|
||||
$app->add(new Codeception\Command\GenerateGroup('generate:groupobject'));
|
||||
$app->add(new Codeception\Command\GeneratePageObject('generate:pageobject'));
|
||||
$app->add(new Codeception\Command\GenerateStepObject('generate:stepobject'));
|
||||
$app->add(new Codeception\Command\GenerateEnvironment('generate:environment'));
|
||||
$app->add(new Codeception\Command\GenerateFeature('generate:feature'));
|
||||
$app->add(new Codeception\Command\GherkinSnippets('gherkin:snippets'));
|
||||
$app->add(new Codeception\Command\GherkinSteps('gherkin:steps'));
|
||||
$app->add(new Codeception\Command\DryRun('dry-run'));
|
||||
$app->add(new Codeception\Command\ConfigValidate('config:validate'));
|
||||
$app->registerCustomCommands();
|
||||
|
||||
// add only if within a phar archive.
|
||||
if ('phar:' === substr(__FILE__, 0, 5)) {
|
||||
$app->add(new Codeception\Command\SelfUpdate('self-update'));
|
||||
}
|
||||
|
||||
$app->run();
|
||||
9
vendor/codeception/base/package/stub.php
vendored
Normal file
9
vendor/codeception/base/package/stub.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
Phar::mapPhar();
|
||||
|
||||
require_once 'phar://codecept.phar/autoload.php';
|
||||
|
||||
require_once 'phar://codecept.phar/codecept';
|
||||
|
||||
__HALT_COMPILER();
|
||||
104
vendor/codeception/base/readme.md
vendored
Normal file
104
vendor/codeception/base/readme.md
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
# Codeception
|
||||
|
||||
[](https://packagist.org/packages/Codeception/Codeception)
|
||||
[](https://packagist.org/packages/codeception/codeception)
|
||||
[](https://scrutinizer-ci.com/g/Codeception/Codeception/?branch=2.4)
|
||||
|
||||
**Modern PHP Testing for everyone**
|
||||
|
||||
Codeception is a modern full-stack testing framework for PHP.
|
||||
Inspired by BDD, it provides an absolutely new way of writing acceptance, functional and even unit tests.
|
||||
Powered by PHPUnit.
|
||||
|
||||
| General | Windows | Webdriver | HHVM |
|
||||
| ------- | -------- | -------- | -------- |
|
||||
| [](http://travis-ci.org/Codeception/Codeception) | [](https://ci.appveyor.com/project/DavertMik/codeception/branch/2.4) | [](https://semaphoreci.com/codeception/codeception) | [](https://app.wercker.com/project/byKey/b4eecd0596bedb65333ff7ab7836bc7f) |
|
||||
|
||||
#### Contributions
|
||||
|
||||
At Codeception we are glad to receive contributions from the community. If you want to send additions or fixes to the code or the documentation please check the [Contributing guide](https://github.com/Codeception/Codeception/blob/2.4/CONTRIBUTING.md).
|
||||
|
||||
### At a Glance
|
||||
|
||||
Describe what you test and how you test it. Use PHP to write descriptions faster.
|
||||
|
||||
Run tests and see what actions were taken and what results were seen.
|
||||
|
||||
#### Requirements
|
||||
|
||||
* PHP 5.6+
|
||||
* `curl` and `mbstring` extensions
|
||||
|
||||
#### Sample test
|
||||
|
||||
``` php
|
||||
$I->wantTo('create wiki page');
|
||||
$I->amOnPage('/');
|
||||
$I->click('Pages');
|
||||
$I->click('New');
|
||||
$I->see('New Page');
|
||||
$I->submitForm('form#new_page', ['title' => 'Movie Review']);
|
||||
$I->see('page created'); // notice generated
|
||||
$I->see('Movie Review','h1'); // head of page of is our title
|
||||
$I->seeInCurrentUrl('pages/movie-review'); // slug is generated
|
||||
$I->seeInDatabase('pages', ['title' => 'Movie Review']); // data is stored in database
|
||||
```
|
||||
|
||||
For unit testing you can stay on classic PHPUnit tests, as Codeception can run them too.
|
||||
|
||||
## Installation
|
||||
|
||||
### Composer
|
||||
|
||||
```
|
||||
php composer.phar require "codeception/codeception"
|
||||
```
|
||||
|
||||
### Phar
|
||||
|
||||
Download [codecept.phar](http://codeception.com/codecept.phar)
|
||||
|
||||
Copy it into your project.
|
||||
|
||||
You can also make Codeception an executable and it put it into your `$PATH`, for instance:
|
||||
|
||||
```
|
||||
wget http://codeception.com/codecept.phar
|
||||
|
||||
chmod +x codecept.phar
|
||||
|
||||
sudo mv codecept.phar /usr/local/bin/codecept
|
||||
|
||||
```
|
||||
|
||||
You can then run Codecept in the command line using: `codecept bootstrap`, `codecept run`, etc
|
||||
|
||||
Run CLI utility:
|
||||
|
||||
```
|
||||
php codecept.phar
|
||||
```
|
||||
|
||||
See also [Installation](http://codeception.com/install) | **[QuickStart](http://codeception.com/quickstart)**
|
||||
|
||||
## Getting Started
|
||||
|
||||
After you successfully installed Codeception, run this command:
|
||||
|
||||
```
|
||||
codecept bootstrap
|
||||
```
|
||||
|
||||
This will create a default directory structure and default test suites.
|
||||
|
||||
## Documentation
|
||||
|
||||
[Documentation](http://codeception.com/docs/01-Introduction)
|
||||
|
||||
Documentation is included within the project. Look for it in the ['docs' directory](https://github.com/Codeception/Codeception/tree/master/docs).
|
||||
|
||||
## License
|
||||
MIT
|
||||
|
||||
(c) [Codeception Team](http://codeception.com/credits)
|
||||
2011-2018
|
||||
14
vendor/codeception/base/ruleset.xml
vendored
Normal file
14
vendor/codeception/base/ruleset.xml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="Codeception">
|
||||
<description>
|
||||
Codeception coding standard. Inherits from PSR-2.
|
||||
</description>
|
||||
|
||||
<rule ref="PSR2">
|
||||
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
|
||||
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols"/>
|
||||
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses"/>
|
||||
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
|
||||
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
|
||||
</rule>
|
||||
</ruleset>
|
||||
72
vendor/codeception/base/shim.php
vendored
Normal file
72
vendor/codeception/base/shim.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
|
||||
namespace {
|
||||
\Codeception\PHPUnit\Init::init();
|
||||
}
|
||||
|
||||
namespace Symfony\Component\CssSelector {
|
||||
if (!class_exists('Symfony\Component\CssSelector\CssSelectorConverter')) {
|
||||
class CssSelectorConverter {
|
||||
function toXPath($cssExpr, $prefix = 'descendant-or-self::') {
|
||||
return CssSelector::toXPath($cssExpr, $prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// prefering old names
|
||||
|
||||
namespace Codeception\TestCase {
|
||||
|
||||
class Test extends \Codeception\Test\Unit {
|
||||
}
|
||||
}
|
||||
|
||||
namespace Codeception\Module {
|
||||
|
||||
class Symfony2 extends Symfony {
|
||||
}
|
||||
|
||||
class Phalcon1 extends Phalcon {
|
||||
}
|
||||
|
||||
class Phalcon2 extends Phalcon {
|
||||
}
|
||||
}
|
||||
|
||||
namespace Codeception\Platform {
|
||||
abstract class Group extends \Codeception\GroupObject
|
||||
{
|
||||
}
|
||||
abstract class Extension extends \Codeception\Extension
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class_alias('Codeception\TestInterface', 'Codeception\TestCase');
|
||||
|
||||
// loading WebDriver aliases
|
||||
if (!class_exists('RemoteWebDriver') and class_exists('Facebook\WebDriver\Remote\RemoteWebDriver')) {
|
||||
class RemoteWebDriver extends \Facebook\WebDriver\Remote\RemoteWebDriver {};
|
||||
class InvalidSelectorException extends Facebook\WebDriver\Exception\InvalidSelectorException {};
|
||||
class NoSuchElementException extends Facebook\WebDriver\Exception\NoSuchElementException {};
|
||||
class WebDriverCurlException extends Facebook\WebDriver\Exception\WebDriverCurlException {};
|
||||
class WebDriverActions extends Facebook\WebDriver\Interactions\WebDriverActions {};
|
||||
class LocalFileDetector extends Facebook\WebDriver\Remote\LocalFileDetector {};
|
||||
class WebDriverCapabilityType extends Facebook\WebDriver\Remote\WebDriverCapabilityType {};
|
||||
class WebDriverAlert extends Facebook\WebDriver\WebDriverAlert {};
|
||||
class WebDriverBy extends Facebook\WebDriver\WebDriverBy {};
|
||||
class WebDriverDimension extends Facebook\WebDriver\WebDriverDimension {};
|
||||
class RemoteWebElement extends Facebook\WebDriver\Remote\RemoteWebElement {};
|
||||
class WebDriverExpectedCondition extends Facebook\WebDriver\WebDriverExpectedCondition {};
|
||||
class WebDriverKeys extends Facebook\WebDriver\WebDriverKeys {};
|
||||
class WebDriverSelect extends Facebook\WebDriver\WebDriverSelect {};
|
||||
class WebDriverTimeouts extends Facebook\WebDriver\WebDriverTimeouts {};
|
||||
class WebDriverWindow extends Facebook\WebDriver\WebDriverWindow {};
|
||||
interface WebDriverElement extends Facebook\WebDriver\WebDriverElement {};
|
||||
}
|
||||
}
|
||||
58
vendor/codeception/base/src/Codeception/Actor.php
vendored
Normal file
58
vendor/codeception/base/src/Codeception/Actor.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace Codeception;
|
||||
|
||||
use Codeception\Lib\Actor\Shared\Comment;
|
||||
use Codeception\Lib\Actor\Shared\Friend;
|
||||
use Codeception\Step\Executor;
|
||||
|
||||
abstract class Actor
|
||||
{
|
||||
use Comment;
|
||||
use Friend;
|
||||
|
||||
/**
|
||||
* @var \Codeception\Scenario
|
||||
*/
|
||||
protected $scenario;
|
||||
|
||||
public function __construct(Scenario $scenario)
|
||||
{
|
||||
$this->scenario = $scenario;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Codeception\Scenario
|
||||
*/
|
||||
protected function getScenario()
|
||||
{
|
||||
return $this->scenario;
|
||||
}
|
||||
|
||||
public function wantToTest($text)
|
||||
{
|
||||
$this->wantTo('test ' . $text);
|
||||
}
|
||||
|
||||
public function wantTo($text)
|
||||
{
|
||||
$this->scenario->setFeature(mb_strtolower($text, 'utf-8'));
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$class = get_class($this);
|
||||
throw new \RuntimeException("Call to undefined method $class::$method");
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy-execution given anonymous function
|
||||
* @param $callable \Closure
|
||||
* @return $this
|
||||
*/
|
||||
public function execute($callable)
|
||||
{
|
||||
$this->scenario->addStep(new Executor($callable, []));
|
||||
$callable();
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
183
vendor/codeception/base/src/Codeception/Application.php
vendored
Normal file
183
vendor/codeception/base/src/Codeception/Application.php
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
namespace Codeception;
|
||||
|
||||
use Codeception\Exception\ConfigurationException;
|
||||
use Symfony\Component\Console\Application as BaseApplication;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Application extends BaseApplication
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ArgvInput
|
||||
*/
|
||||
protected $coreArguments = null;
|
||||
|
||||
/**
|
||||
* Register commands from config file
|
||||
*
|
||||
* extensions:
|
||||
* commands:
|
||||
* - Project\Command\MyCustomCommand
|
||||
*
|
||||
*/
|
||||
public function registerCustomCommands()
|
||||
{
|
||||
try {
|
||||
$this->readCustomCommandsFromConfig();
|
||||
} catch (ConfigurationException $e) {
|
||||
if ($e->getCode() === 404) {
|
||||
return;
|
||||
}
|
||||
$this->renderException($e, new ConsoleOutput());
|
||||
exit(1);
|
||||
} catch (\Exception $e) {
|
||||
$this->renderException($e, new ConsoleOutput());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search custom commands and register them.
|
||||
*
|
||||
* @throws ConfigurationException
|
||||
*/
|
||||
protected function readCustomCommandsFromConfig()
|
||||
{
|
||||
$this->getCoreArguments(); // Maybe load outside configfile
|
||||
|
||||
$config = Configuration::config();
|
||||
|
||||
if (empty($config['extensions']['commands'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($config['extensions']['commands'] as $commandClass) {
|
||||
$commandName = $this->getCustomCommandName($commandClass);
|
||||
$this->add(new $commandClass($commandName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and get the name of the command
|
||||
*
|
||||
* @param CustomCommandInterface $commandClass
|
||||
*
|
||||
* @throws ConfigurationException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getCustomCommandName($commandClass)
|
||||
{
|
||||
if (!class_exists($commandClass)) {
|
||||
throw new ConfigurationException("Extension: Command class $commandClass not found");
|
||||
}
|
||||
|
||||
$interfaces = class_implements($commandClass);
|
||||
|
||||
if (!in_array('Codeception\CustomCommandInterface', $interfaces)) {
|
||||
throw new ConfigurationException("Extension: Command {$commandClass} must implement " .
|
||||
"the interface `Codeception\\CustomCommandInterface`");
|
||||
}
|
||||
|
||||
return $commandClass::getCommandName();
|
||||
}
|
||||
|
||||
/**
|
||||
* To cache Class ArgvInput
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function run(InputInterface $input = null, OutputInterface $output = null)
|
||||
{
|
||||
if ($input === null) {
|
||||
$input = $this->getCoreArguments();
|
||||
}
|
||||
|
||||
if (!ini_get('register_argc_argv') && empty($_SERVER['argv'])) {
|
||||
//register_argc_argv is always off on HHVM, but it has no effect
|
||||
throw new ConfigurationException('register_argc_argv must be set to On for running Codeception');
|
||||
}
|
||||
|
||||
return parent::run($input, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add global a --config option.
|
||||
*
|
||||
* @return InputDefinition
|
||||
*/
|
||||
protected function getDefaultInputDefinition()
|
||||
{
|
||||
$inputDefinition = parent::getDefaultInputDefinition();
|
||||
$inputDefinition->addOption(
|
||||
new InputOption('config', 'c', InputOption::VALUE_OPTIONAL, 'Use custom path for config')
|
||||
);
|
||||
return $inputDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for --config Option and if found will be loaded
|
||||
*
|
||||
* example:
|
||||
* -c file.yml|dir
|
||||
* -cfile.yml|dir
|
||||
* --config file.yml|dir
|
||||
* --config=file.yml|dir
|
||||
*
|
||||
* @return ArgvInput
|
||||
*/
|
||||
protected function getCoreArguments()
|
||||
{
|
||||
if ($this->coreArguments !== null) {
|
||||
return $this->coreArguments;
|
||||
}
|
||||
|
||||
$argvWithoutConfig = [];
|
||||
if (isset($_SERVER['argv'])) {
|
||||
$argv = $_SERVER['argv'];
|
||||
|
||||
for ($i = 0; $i < count($argv); $i++) {
|
||||
if (preg_match('/^(?:-([^c-]*)?c|--config(?:=|$))(.*)$/', $argv[$i], $match)) {
|
||||
if (!empty($match[2])) { //same index
|
||||
$this->preloadConfiguration($match[2]);
|
||||
} elseif (isset($argv[$i + 1])) { //next index
|
||||
$this->preloadConfiguration($argv[++$i]);
|
||||
}
|
||||
if (!empty($match[1])) {
|
||||
$argvWithoutConfig[] = "-" . $match[1]; //rest commands
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$argvWithoutConfig[] = $argv[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->coreArguments = new ArgvInput($argvWithoutConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre load Configuration, the config option is use.
|
||||
*
|
||||
* @param string $configFile Path to Configuration
|
||||
*
|
||||
* @throws ConfigurationException
|
||||
*/
|
||||
protected function preloadConfiguration($configFile)
|
||||
{
|
||||
try {
|
||||
Configuration::config($configFile);
|
||||
} catch (ConfigurationException $e) {
|
||||
if ($e->getCode() == 404) {
|
||||
throw new ConfigurationException("Your configuration file `{$configFile}` could not be found.", 405);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
236
vendor/codeception/base/src/Codeception/Codecept.php
vendored
Normal file
236
vendor/codeception/base/src/Codeception/Codecept.php
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
namespace Codeception;
|
||||
|
||||
use Codeception\Exception\ConfigurationException;
|
||||
use Codeception\Subscriber\ExtensionLoader;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
|
||||
class Codecept
|
||||
{
|
||||
const VERSION = "2.4.5";
|
||||
|
||||
/**
|
||||
* @var \Codeception\PHPUnit\Runner
|
||||
*/
|
||||
protected $runner;
|
||||
/**
|
||||
* @var \PHPUnit\Framework\TestResult
|
||||
*/
|
||||
protected $result;
|
||||
|
||||
/**
|
||||
* @var \Codeception\CodeCoverage
|
||||
*/
|
||||
protected $coverage;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\EventDispatcher\EventDispatcher
|
||||
*/
|
||||
protected $dispatcher;
|
||||
|
||||
/**
|
||||
* @var ExtensionLoader
|
||||
*/
|
||||
protected $extensionLoader;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [
|
||||
'silent' => false,
|
||||
'debug' => false,
|
||||
'steps' => false,
|
||||
'html' => false,
|
||||
'xml' => false,
|
||||
'json' => false,
|
||||
'tap' => false,
|
||||
'report' => false,
|
||||
'colors' => false,
|
||||
'coverage' => false,
|
||||
'coverage-xml' => false,
|
||||
'coverage-html' => false,
|
||||
'coverage-text' => false,
|
||||
'coverage-crap4j' => false,
|
||||
'coverage-phpunit'=> false,
|
||||
'groups' => null,
|
||||
'excludeGroups' => null,
|
||||
'filter' => null,
|
||||
'env' => null,
|
||||
'fail-fast' => false,
|
||||
'ansi' => true,
|
||||
'verbosity' => 1,
|
||||
'interactive' => true,
|
||||
'no-rebuild' => false,
|
||||
'quiet' => false,
|
||||
];
|
||||
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $extensions = [];
|
||||
|
||||
public function __construct($options = [])
|
||||
{
|
||||
$this->result = new \PHPUnit\Framework\TestResult;
|
||||
$this->dispatcher = new EventDispatcher();
|
||||
$this->extensionLoader = new ExtensionLoader($this->dispatcher);
|
||||
|
||||
$baseOptions = $this->mergeOptions($options);
|
||||
$this->extensionLoader->bootGlobalExtensions($baseOptions); // extensions may override config
|
||||
|
||||
$this->config = Configuration::config();
|
||||
$this->options = $this->mergeOptions($options); // options updated from config
|
||||
|
||||
$this->registerSubscribers();
|
||||
$this->registerPHPUnitListeners();
|
||||
$this->registerPrinter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges given options with default values and current configuration
|
||||
*
|
||||
* @param array $options options
|
||||
* @return array
|
||||
* @throws ConfigurationException
|
||||
*/
|
||||
protected function mergeOptions($options)
|
||||
{
|
||||
$config = Configuration::config();
|
||||
$baseOptions = array_merge($this->options, $config['settings']);
|
||||
return array_merge($baseOptions, $options);
|
||||
}
|
||||
|
||||
protected function registerPHPUnitListeners()
|
||||
{
|
||||
$listener = new PHPUnit\Listener($this->dispatcher);
|
||||
$this->result->addListener($listener);
|
||||
}
|
||||
|
||||
public function registerSubscribers()
|
||||
{
|
||||
// required
|
||||
$this->dispatcher->addSubscriber(new Subscriber\GracefulTermination());
|
||||
$this->dispatcher->addSubscriber(new Subscriber\ErrorHandler());
|
||||
$this->dispatcher->addSubscriber(new Subscriber\Dependencies());
|
||||
$this->dispatcher->addSubscriber(new Subscriber\Bootstrap());
|
||||
$this->dispatcher->addSubscriber(new Subscriber\PrepareTest());
|
||||
$this->dispatcher->addSubscriber(new Subscriber\Module());
|
||||
$this->dispatcher->addSubscriber(new Subscriber\BeforeAfterTest());
|
||||
|
||||
// optional
|
||||
if (!$this->options['no-rebuild']) {
|
||||
$this->dispatcher->addSubscriber(new Subscriber\AutoRebuild());
|
||||
}
|
||||
if (!$this->options['silent']) {
|
||||
$this->dispatcher->addSubscriber(new Subscriber\Console($this->options));
|
||||
}
|
||||
if ($this->options['fail-fast']) {
|
||||
$this->dispatcher->addSubscriber(new Subscriber\FailFast());
|
||||
}
|
||||
|
||||
if ($this->options['coverage']) {
|
||||
$this->dispatcher->addSubscriber(new Coverage\Subscriber\Local($this->options));
|
||||
$this->dispatcher->addSubscriber(new Coverage\Subscriber\LocalServer($this->options));
|
||||
$this->dispatcher->addSubscriber(new Coverage\Subscriber\RemoteServer($this->options));
|
||||
$this->dispatcher->addSubscriber(new Coverage\Subscriber\Printer($this->options));
|
||||
}
|
||||
$this->dispatcher->addSubscriber($this->extensionLoader);
|
||||
$this->extensionLoader->registerGlobalExtensions();
|
||||
}
|
||||
|
||||
public function run($suite, $test = null, array $config = null)
|
||||
{
|
||||
ini_set(
|
||||
'memory_limit',
|
||||
isset($this->config['settings']['memory_limit']) ? $this->config['settings']['memory_limit'] : '1024M'
|
||||
);
|
||||
|
||||
$config = $config ?: Configuration::config();
|
||||
|
||||
$settings = Configuration::suiteSettings($suite, $config);
|
||||
|
||||
$selectedEnvironments = $this->options['env'];
|
||||
$environments = Configuration::suiteEnvironments($suite);
|
||||
|
||||
if (!$selectedEnvironments or empty($environments)) {
|
||||
$this->runSuite($settings, $suite, $test);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (array_unique($selectedEnvironments) as $envList) {
|
||||
$envArray = explode(',', $envList);
|
||||
$config = [];
|
||||
foreach ($envArray as $env) {
|
||||
if (isset($environments[$env])) {
|
||||
$currentEnvironment = isset($config['current_environment']) ? [$config['current_environment']] : [];
|
||||
$config = Configuration::mergeConfigs($config, $environments[$env]);
|
||||
$currentEnvironment[] = $config['current_environment'];
|
||||
$config['current_environment'] = implode(',', $currentEnvironment);
|
||||
}
|
||||
}
|
||||
if (empty($config)) {
|
||||
continue;
|
||||
}
|
||||
$suiteToRun = $suite;
|
||||
if (!empty($envList)) {
|
||||
$suiteToRun .= ' (' . implode(', ', $envArray) . ')';
|
||||
}
|
||||
$this->runSuite($config, $suiteToRun, $test);
|
||||
}
|
||||
}
|
||||
|
||||
public function runSuite($settings, $suite, $test = null)
|
||||
{
|
||||
$suiteManager = new SuiteManager($this->dispatcher, $suite, $settings);
|
||||
$suiteManager->initialize();
|
||||
$suiteManager->loadTests($test);
|
||||
$suiteManager->run($this->runner, $this->result, $this->options);
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
public static function versionString()
|
||||
{
|
||||
return 'Codeception PHP Testing Framework v' . self::VERSION;
|
||||
}
|
||||
|
||||
public function printResult()
|
||||
{
|
||||
$result = $this->getResult();
|
||||
$result->flushListeners();
|
||||
|
||||
$printer = $this->runner->getPrinter();
|
||||
$printer->printResult($result);
|
||||
|
||||
$this->dispatcher->dispatch(Events::RESULT_PRINT_AFTER, new Event\PrintResultEvent($result, $printer));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \PHPUnit\Framework\TestResult
|
||||
*/
|
||||
public function getResult()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EventDispatcher
|
||||
*/
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->dispatcher;
|
||||
}
|
||||
|
||||
protected function registerPrinter()
|
||||
{
|
||||
$printer = new PHPUnit\ResultPrinter\UI($this->dispatcher, $this->options);
|
||||
$this->runner = new PHPUnit\Runner();
|
||||
$this->runner->setPrinter($printer);
|
||||
}
|
||||
}
|
||||
57
vendor/codeception/base/src/Codeception/Command/Bootstrap.php
vendored
Normal file
57
vendor/codeception/base/src/Codeception/Command/Bootstrap.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace Codeception\Command;
|
||||
|
||||
use Codeception\Template\Bootstrap as BootstrapTemplate;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Creates default config, tests directory and sample suites for current project.
|
||||
* Use this command to start building a test suite.
|
||||
*
|
||||
* By default it will create 3 suites **acceptance**, **functional**, and **unit**.
|
||||
*
|
||||
* * `codecept bootstrap` - creates `tests` dir and `codeception.yml` in current dir.
|
||||
* * `codecept bootstrap --empty` - creates `tests` dir without suites
|
||||
* * `codecept bootstrap --namespace Frontend` - creates tests, and use `Frontend` namespace for actor classes and helpers.
|
||||
* * `codecept bootstrap --actor Wizard` - sets actor as Wizard, to have `TestWizard` actor in tests.
|
||||
* * `codecept bootstrap path/to/the/project` - provide different path to a project, where tests should be placed
|
||||
*
|
||||
*/
|
||||
class Bootstrap extends Command
|
||||
{
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setDefinition(
|
||||
[
|
||||
new InputArgument('path', InputArgument::OPTIONAL, 'custom installation dir', null),
|
||||
new InputOption(
|
||||
'namespace',
|
||||
'ns',
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'Namespace to add for actor classes and helpers'
|
||||
),
|
||||
new InputOption('actor', 'a', InputOption::VALUE_OPTIONAL, 'Custom actor instead of Tester'),
|
||||
new InputOption('empty', 'e', InputOption::VALUE_NONE, 'Don\'t create standard suites')
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return "Creates default test suites and generates all required files";
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$bootstrap = new BootstrapTemplate($input, $output);
|
||||
if ($input->getArgument('path')) {
|
||||
$bootstrap->initDir($input->getArgument('path'));
|
||||
}
|
||||
$bootstrap->setup();
|
||||
}
|
||||
}
|
||||
108
vendor/codeception/base/src/Codeception/Command/Build.php
vendored
Normal file
108
vendor/codeception/base/src/Codeception/Command/Build.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
namespace Codeception\Command;
|
||||
|
||||
use Codeception\Configuration;
|
||||
use Codeception\Lib\Generator\Actions as ActionsGenerator;
|
||||
use Codeception\Lib\Generator\Actor as ActorGenerator;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Generates Actor classes (initially Guy classes) from suite configs.
|
||||
* Starting from Codeception 2.0 actor classes are auto-generated. Use this command to generate them manually.
|
||||
*
|
||||
* * `codecept build`
|
||||
* * `codecept build path/to/project`
|
||||
*
|
||||
*/
|
||||
class Build extends Command
|
||||
{
|
||||
use Shared\Config;
|
||||
use Shared\FileSystem;
|
||||
|
||||
protected $inheritedMethodTemplate = ' * @method void %s(%s)';
|
||||
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
protected $output;
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return 'Generates base classes for all suites';
|
||||
}
|
||||
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->buildActorsForConfig();
|
||||
}
|
||||
|
||||
private function buildActor(array $settings)
|
||||
{
|
||||
$actorGenerator = new ActorGenerator($settings);
|
||||
$this->output->writeln(
|
||||
'<info>' . Configuration::config()['namespace'] . '\\' . $actorGenerator->getActorName()
|
||||
. "</info> includes modules: " . implode(', ', $actorGenerator->getModules())
|
||||
);
|
||||
|
||||
$content = $actorGenerator->produce();
|
||||
|
||||
$file = $this->createDirectoryFor(
|
||||
Configuration::supportDir(),
|
||||
$settings['actor']
|
||||
) . $this->getShortClassName($settings['actor']);
|
||||
$file .= '.php';
|
||||
return $this->createFile($file, $content);
|
||||
}
|
||||
|
||||
private function buildActions(array $settings)
|
||||
{
|
||||
$actionsGenerator = new ActionsGenerator($settings);
|
||||
$this->output->writeln(
|
||||
" -> {$settings['actor']}Actions.php generated successfully. "
|
||||
. $actionsGenerator->getNumMethods() . " methods added"
|
||||
);
|
||||
|
||||
$content = $actionsGenerator->produce();
|
||||
|
||||
$file = $this->createDirectoryFor(Configuration::supportDir() . '_generated', $settings['actor']);
|
||||
$file .= $this->getShortClassName($settings['actor']) . 'Actions.php';
|
||||
return $this->createFile($file, $content, true);
|
||||
}
|
||||
|
||||
private function buildSuiteActors()
|
||||
{
|
||||
$suites = $this->getSuites();
|
||||
if (!empty($suites)) {
|
||||
$this->output->writeln("<info>Building Actor classes for suites: " . implode(', ', $suites) . '</info>');
|
||||
}
|
||||
foreach ($suites as $suite) {
|
||||
$settings = $this->getSuiteConfig($suite);
|
||||
if (!$settings['actor']) {
|
||||
continue; // no actor
|
||||
}
|
||||
$this->buildActions($settings);
|
||||
$actorBuilt = $this->buildActor($settings);
|
||||
|
||||
if ($actorBuilt) {
|
||||
$this->output->writeln("{$settings['actor']}.php created.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function buildActorsForConfig($configFile = null)
|
||||
{
|
||||
$config = $this->getGlobalConfig($configFile);
|
||||
|
||||
$dir = Configuration::projectDir();
|
||||
$this->buildSuiteActors();
|
||||
|
||||
foreach ($config['include'] as $subConfig) {
|
||||
$this->output->writeln("\n<comment>Included Configuration: $subConfig</comment>");
|
||||
$this->buildActorsForConfig($dir . DIRECTORY_SEPARATOR . $subConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
vendor/codeception/base/src/Codeception/Command/Clean.php
vendored
Normal file
45
vendor/codeception/base/src/Codeception/Command/Clean.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace Codeception\Command;
|
||||
|
||||
use Codeception\Configuration;
|
||||
use Codeception\Util\FileSystem;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Recursively cleans `output` directory and generated code.
|
||||
*
|
||||
* * `codecept clean`
|
||||
*
|
||||
*/
|
||||
class Clean extends Command
|
||||
{
|
||||
use Shared\Config;
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return 'Recursively cleans log and generated code';
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$projectDir = Configuration::projectDir();
|
||||
$this->cleanProjectsRecursively($output, $projectDir);
|
||||
$output->writeln("Done");
|
||||
}
|
||||
|
||||
private function cleanProjectsRecursively(OutputInterface $output, $projectDir)
|
||||
{
|
||||
$logDir = Configuration::logDir();
|
||||
$output->writeln("<info>Cleaning up output " . $logDir . "...</info>");
|
||||
FileSystem::doEmptyDir($logDir);
|
||||
|
||||
$config = Configuration::config($projectDir);
|
||||
$subProjects = $config['include'];
|
||||
foreach ($subProjects as $subProject) {
|
||||
$subProjectDir = $projectDir . $subProject;
|
||||
$this->cleanProjectsRecursively($output, $subProjectDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
84
vendor/codeception/base/src/Codeception/Command/Completion.php
vendored
Normal file
84
vendor/codeception/base/src/Codeception/Command/Completion.php
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
namespace Codeception\Command;
|
||||
|
||||
if (!class_exists('Stecman\Component\Symfony\Console\BashCompletion\Completion')) {
|
||||
echo "Please install `stecman/symfony-console-completion\n` to enable auto completion";
|
||||
return;
|
||||
}
|
||||
|
||||
use Codeception\Configuration;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion as ConsoleCompletion;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionHandler;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\ShellPathCompletion as ShellPathCompletion;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Completion extends CompletionCommand
|
||||
{
|
||||
protected function configureCompletion(CompletionHandler $handler)
|
||||
{
|
||||
// Can't set for all commands, because it wouldn't work well with generate:suite
|
||||
$suiteCommands = [
|
||||
'run',
|
||||
'config:validate',
|
||||
'console',
|
||||
'dry-run',
|
||||
'generate:cept',
|
||||
'generate:cest',
|
||||
'generate:feature',
|
||||
'generate:phpunit',
|
||||
'generate:scenarios',
|
||||
'generate:stepobject',
|
||||
'generate:test',
|
||||
'gherkin:snippets',
|
||||
'gherkin:steps'
|
||||
];
|
||||
|
||||
foreach ($suiteCommands as $suiteCommand) {
|
||||
$handler->addHandler(new ConsoleCompletion(
|
||||
$suiteCommand,
|
||||
'suite',
|
||||
ConsoleCompletion::TYPE_ARGUMENT,
|
||||
Configuration::suites()
|
||||
));
|
||||
}
|
||||
|
||||
$handler->addHandlers([
|
||||
new ShellPathCompletion(
|
||||
ConsoleCompletion::ALL_COMMANDS,
|
||||
'path',
|
||||
ConsoleCompletion::TYPE_ARGUMENT
|
||||
),
|
||||
new ShellPathCompletion(
|
||||
ConsoleCompletion::ALL_COMMANDS,
|
||||
'test',
|
||||
ConsoleCompletion::TYPE_ARGUMENT
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if ($input->getOption('generate-hook') && $input->getOption('use-vendor-bin')) {
|
||||
global $argv;
|
||||
$argv[0] = 'vendor/bin/' . basename($argv[0]);
|
||||
}
|
||||
|
||||
parent::execute($input, $output);
|
||||
}
|
||||
|
||||
protected function createDefinition()
|
||||
{
|
||||
$definition = parent::createDefinition();
|
||||
$definition->addOption(new InputOption(
|
||||
'use-vendor-bin',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Use the vendor bin for autocompletion.'
|
||||
));
|
||||
|
||||
return $definition;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user