Testomatio - Test Management for Codeception
If you use Codeception installed using composer, install this module with the following command:
composer require --dev codeception/module-phalcon4Alternatively, you can enable Phalcon4 module in suite configuration file and run
codecept init upgrade4This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately.
Some modules are bundled with PHAR files.
Warning. Using PHAR file and composer in the same project can cause unexpected errors.
This module provides integration with Phalcon framework (4.x). Please try it and leave your feedback.
The following configurations are required for this module:
string, default app/config/bootstrap.php - relative path to app.php config fileboolean, default true - all database queries will be run in a transaction,
which will be rolled back at the end of each testboolean, default true - use savepoints to emulate nested transactionsThe application bootstrap file must return Application object but not call its handle() method.
Phalcon\Di\Injectable instanceBrowserKit clientBy default all available methods are loaded, but you can specify parts to select only needed actions and avoid conflicts.
orm - include only haveRecord/grabRecord/seeRecord/dontSeeRecord actions.services - allows to use grabServiceFromContainer and addServiceToContainer.See WebDriver module for general information on how to load parts of a framework module.
Usage example:
Sample bootstrap (app/config/bootstrap.php):
<?php
$di = new \Phalcon\DI\FactoryDefault();
return new \Phalcon\Mvc\Application($di);
?>actor: AcceptanceTester
modules:
enabled:
- Phalcon4:
part: services
bootstrap: 'app/config/bootstrap.php'
cleanup: true
savepoints: true
- WebDriver:
url: http://your-url.com
browser: phantomjshidden API method, expected to be used from Helper classes
Locates element using available Codeception locator types:
Use it in Helpers or GroupObject or Extension classes:
<?php
$els = $this->getModule('Phalcon4')->_findElements('.items');
$els = $this->getModule('Phalcon4')->_findElements(['name' => 'username']);
$editLinks = $this->getModule('Phalcon4')->_findElements(['link' => 'Edit']);
// now you can iterate over $editLinks and check that all them have valid hrefsWebDriver module returns Facebook\WebDriver\Remote\RemoteWebElement instances
PhpBrowser and Framework modules return Symfony\Component\DomCrawler\Crawler instances
param $locatorreturn array of interactive elementshidden API method, expected to be used from Helper classes
Returns content of the last response Use it in Helpers when you want to retrieve response of request performed by another module.
<?php
// in Helper class
public function seeResponseContains($text)
{
$this->assertStringContainsString($text, $this->getModule('Phalcon4')->_getResponseContent(), "response contains");
}return string
@throws ModuleExceptionhidden API method, expected to be used from Helper classes
Opens a page with arbitrary request parameters. Useful for testing multi-step forms on a specific step.
<?php
// in Helper class
public function openCheckoutFormStep2($orderId) {
$this->getModule('Phalcon4')->_loadPage('POST', '/checkout/step2', ['order' => $orderId]);
}param string $methodparam string $uriparam string $contenthidden API method, expected to be used from Helper classes
Send custom request to a backend using method, uri, parameters, etc. Use it in Helpers to create special request actions, like accessing API Returns a string with response body.
<?php
// in Helper class
public function createUserByApi($name) {
$userData = $this->getModule('Phalcon4')->_request('POST', '/api/v1/users', ['name' => $name]);
$user = json_decode($userData);
return $user->id;
}Does not load the response into the module so you can’t interact with response page (click, fill forms).
To load arbitrary page for interaction, use _loadPage method.
param string $methodparam string $uriparam string $contentreturn string
@throws ExternalUrlException
@see _loadPagehidden API method, expected to be used from Helper classes
Saves page source of to a file
$this->getModule('Phalcon4')->_savePageSource(codecept_output_dir().'page.html');param $filenameRegisters a service in the services container and resolve it. This record will be erased after the test. Recommended to use for unit testing.
<?php
$filter = $I->addServiceToContainer('filter', ['className' => '\Phalcon\Filter']);
$filter = $I->addServiceToContainer('answer', function () {
return rand(0, 1) ? 'Yes' : 'No';
}, true);param string $nameparam mixed $definitionparam boolean $sharedreturn mixed|null[Part] servicesAuthenticates user for HTTP_AUTH
param string $usernameparam string $passwordOpens the page for the given relative URI.
<?php
// opens front page
$I->amOnPage('/');
// opens /register page
$I->amOnPage('/register');param string $pageOpens web page using route name and parameters.
<?php
$I->amOnRoute('posts.create');param string $routeNameparam array $paramsAttaches a file relative to the Codeception _data directory to the given file upload field.
<?php
// file is stored in 'tests/_data/prices.xls'