I need to revert all changes that were made in database by acceptance test after each acceptance test.
As described in Yii2 docs, you should set transaction: false
for Yii2
module in acceptance.suite.yml
. And you should use cleanup: true and transaction: true
for Db
module in codeception.yml
.
Actual: changes that acceptance test did in database are not reverted.
Expected: changes that acceptance test did in database are reverted.
transaction: true
in Db
module should wrap all queries that were made in test into transaction and rollback transaction in the end of test.
That works for unit & functional tests but not for acceptance…
What am i doing wrong?
codeception.yml
namespace: common\tests
actor_suffix: Tester
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
modules:
config:
Yii2:
configFile: 'config/test-local.php'
Db:
dsn: '%TEST_DB_TYPE%:host=%TEST_DB_HOST%;port=%TEST_DB_PORT%;dbname=%TEST_DB_NAME%'
user: '%TEST_DB_USERNAME%'
password: '%TEST_DB_PASSWORD%'
cleanup: true
transaction: true
params:
- config/params-local.php
acceptance.suite.yml
suite_namespace: frontend\tests\acceptance
actor: AcceptanceTester
modules:
enabled:
- WebDriver
- Yii2
config:
Yii2:
part: init
transaction: false
cleanup: true
WebDriver:
browser: chrome
url: 'http://mysite.dev/'
port: 9515 # ChromeDriver port
window_size: 1920x1080
clear_cookies: true
restart: true
capabilities:
chromeOptions:
args: ["--headless", "--disable-gpu"]
binary: "/usr/bin/google-chrome-stable"
extensions:
enabled:
- Codeception\Extension\RunProcess:
- chromedriver --url-base=/wd/hub