|
|
4 лет назад | |
|---|---|---|
| .. | ||
| AMQP.php | 4 лет назад | |
| AngularJS.php | 4 лет назад | |
| Apc.php | 4 лет назад | |
| Asserts.php | 4 лет назад | |
| Cli.php | 4 лет назад | |
| DataFactory.php | 4 лет назад | |
| Db.php | 4 лет назад | |
| Doctrine2.php | 4 лет назад | |
| FTP.php | 4 лет назад | |
| Facebook.php | 4 лет назад | |
| Filesystem.php | 4 лет назад | |
| Laravel5.php | 4 лет назад | |
| Lumen.php | 4 лет назад | |
| Memcache.php | 4 лет назад | |
| MongoDb.php | 4 лет назад | |
| Phalcon.php | 4 лет назад | |
| PhpBrowser.php | 4 лет назад | |
| Queue.php | 4 лет назад | |
| README.md | 4 лет назад | |
| REST.php | 4 лет назад | |
| Redis.php | 4 лет назад | |
| SOAP.php | 4 лет назад | |
| Sequence.php | 4 лет назад | |
| Silex.php | 4 лет назад | |
| Symfony.php | 4 лет назад | |
| WebDriver.php | 4 лет назад | |
| XMLRPC.php | 4 лет назад | |
| Yii1.php | 4 лет назад | |
| Yii2.php | 4 лет назад | |
| ZF1.php | 4 лет назад | |
| ZF2.php | 4 лет назад | |
| ZendExpressive.php | 4 лет назад | |
Modules are high-level extensions that are used in tests. Modules are created for each test suites (according to suite configuration) and can be accessed directly from unit tests:
<?php
$this->getModule('PhpBrowser')->client;
?>
or used inside scenario-driven tests, where $I acts as an wrapper to different modules
<?php
$I->click(); // => PhpBrowser
$I->seeInDatabase(); // => Db
?>
Each module is extending Codeception\Module class and defined in Codeception\Module namespace. All Codeception modules are autoloaded by searching in this particular namespace: PhpBrowser => Codeception\Module\PhpBrowser.
The core principles:
Public methods of modules are actions of an actor inside a test. That's why they should be named in proper format:
doSomeStuff() => $I->doSomeStuff() => I do some stuff
doSomeStuffWith($a, $b) => $I->doSomeStuffWith("vodka", "gin"); => I do some stuff with "vodka", "gin"
seeIsGreat() => $I->seeIsGreat() => I see is great
am or havesee prefixgrab (grabbers) or have (definitions)Example:
$I->amSeller();
$I->haveProducts(['vodka', 'gin']);
$I->haveDiscount('0.1');
$I->setPrice('gin', '10$');
$I->seePrice('gin', '9.9');
$price = $I->grabPriceFor('gin');
Configuration parameters are set in .suite.yml config and stored in config property array of a module. All default values can be set there as well. Required parameters should be set in requiredFields property.
<?php
protected $config = ['browser' => 'firefox'];
protected $requiredFields = ['url'];
?>
You should not perform validation if url was set. Module would perform it for you, so you could access $this->config['url'] inside a module.
public properties of method.Also you may provide a closure method to access low-level API
<?php
$I->executeInSelenium(function(\WebDriverClient $wb) {
$wd->manage()->addCookie(['name' => 'verified']);
});
?>
Codeception\Module namespace. If you develop a module and you think it might be useful to others, please ask in Github Issues, maybe we would like to include it into the official repo.