init
This commit is contained in:
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>
|
||||
Reference in New Issue
Block a user