You can install this package through composer:
composer require visavi/codeception-phpixie
Include the phpixie module in the tests/functional.suite
file
actor: FunctionalTester
modules:
enabled:
- Phpixie:
url: 'http://localhost'
- \Helper\Functional
In acceptance tests, you can use methods to work with a database of functional tests.
To do this, you must enable the module in the tests/acceptance.suite
file
actor: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://localhost
- Phpixie:
part: ORM
- \Helper\Acceptance
After that 7 methods will be available to work with the database.
All methods work in a transaction, which means that after the tests are completed, the database will be in its original form
$user = $I->haveRecord('user', ['name' => 'phpixie']);
$I->seeRecord('user', ['name' => 'phpixie']);
$I->dontSeeRecord('user', ['name' => 'trixie']);
$record = $I->grabRecord('user', ['name' => 'phpixie']);
$I->deleteRecord('user', ['id' => $user->id]);
Transaction control methods do not look at the global transaction enable settings, if you have transactions enabled by default, you can turn them off for each method
Conversely, if transactions are globally disabled (cleanup: false), then methods can force transactions to be enabled.
$I->startTransaction();
$I->stopTransaction();
Calling methods for functional and acceptance tests:
$I->methodName();
Calling methods for unit tests:
$this->tester->methodName();
$data = [
'login' => 'phpixie',
'password' => 'password',
'name' => 'trixie',
];
$entity = $I->haveRecord('user', $data);
$I->seeRecord('user', ['id' => $entity->id]);
$I->wantTo('Test user page');
$I->amOnPage('/user/' . $entity->login);
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
$I->seeInSource('trixie');
The class is open-sourced software licensed under the MIT license