diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9de0f0475..fc8539063 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,7 +19,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: token: ${{ secrets.GH_PAT }} @@ -33,7 +33,7 @@ jobs: env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - php-version: 8.0 + php-version: 8.2 - name: Install dependencies run: composer install --prefer-dist --no-progress diff --git a/Gemfile b/Gemfile index dc5c6ad74..52816f1c6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'jekyll', '~> 4.3.2' +gem 'jekyll', '~> 4.3.3' gem 'kramdown' gem 'rouge' gem 'webrick' diff --git a/README.md b/README.md index 918c34b10..925d83538 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Codeception Site +# Codeception.com Website https://codeception.com diff --git a/RoboFile.php b/RoboFile.php index 770ca1403..bca066714 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -10,8 +10,8 @@ class RoboFile extends \Robo\Tasks use DocumentationHelpers; const REPO_BLOB_URL = 'https://github.com/Codeception/Codeception/blob'; - const BRANCH_4x = '4.2'; - const BRANCH_5x = '5.0'; + const BRANCH_5x = '5.3'; + const BRANCH_MAIN = 'main'; function post() { @@ -263,7 +263,7 @@ public function buildDocsExtensions() ->prepend("# Official Extensions\n") ->processClassSignature(function (ReflectionClass $r, $text) { $name = $r->getShortName(); - return "## $name\n\n[See Source](" . self::REPO_BLOB_URL . "/" . self::BRANCH_5x . "/ext/$name.php)"; + return "## $name\n\n[See Source](" . self::REPO_BLOB_URL . "/" . self::BRANCH_MAIN . "/ext/$name.php)"; }) ->filterMethods(function (ReflectionMethod $r) { return false; @@ -277,7 +277,7 @@ public function buildDocsExtensions() protected function documentApiClass($file, $className, $all = false, $repositoryName = null) { if ($repositoryName === null) { - $repositoryUrl = self::REPO_BLOB_URL . "/" . self::BRANCH_5x; + $repositoryUrl = self::REPO_BLOB_URL . "/" . self::BRANCH_MAIN; } else { $repositoryUrl = 'https://github.com/Codeception/' . $repositoryName . '/blob/master'; } @@ -412,102 +412,34 @@ private function postProcessFile($pageName, $documentationFile) file_put_contents($documentationFile, $contents); } - public function buildPhar80() + public function buildPhar82() { - $version = self::BRANCH_5x . '.' . date('Ymd'); - $releaseDir = "releases/$version"; - $this->stopOnFail(); - - $this->taskFilesystemStack()->mkdir('build/80')->run(); - $this->setCodeceptionVersionTo('^5.0'); - $this->setPlatformVersionTo('8.0.2'); - $buildFile = 'build/80/codecept.phar'; - $this->buildPhar($buildFile); - $this->updateVersionFile($buildFile, 'php80/codecept.version'); - $versionedFile = "$releaseDir/codecept.phar"; - $this->taskFilesystemStack() - ->stopOnFail() - ->mkdir($releaseDir) - ->copy($buildFile, $versionedFile) - ->remove('php80/codecept.phar') - ->symlink("../$versionedFile", 'php80/codecept.phar') - ->run(); - } + $ignoredPlatformReqs = array( + 'ext-apcu', + 'ext-mongodb', + 'ext-phalcon', + ); - public function buildPhar72() - { - $version = self::BRANCH_4x . '.' . date('Ymd'); + $version = self::BRANCH_5x . '.' . date('Ymd'); $releaseDir = "releases/$version"; $this->stopOnFail(); - - $this->taskFilesystemStack()->mkdir('build/72')->run(); - $this->setCodeceptionVersionTo('^4.1'); - $this->setPlatformVersionTo('7.2.0'); - $this->requireHoaConsole(); - $buildFile = 'build/72/codecept.phar'; + $this->taskFilesystemStack()->mkdir('build/82')->run(); + $this->setCodeceptionVersionTo('^' . self::BRANCH_5x, $ignoredPlatformReqs); + $this->setPlatformVersionTo('8.2.0', $ignoredPlatformReqs); + $buildFile = 'build/82/codecept.phar'; $this->buildPhar($buildFile); - $this->updateVersionFile($buildFile, 'codecept.version'); + $this->updateVersionFile($buildFile, 'php82/codecept.version'); $versionedFile = "$releaseDir/codecept.phar"; $this->taskFilesystemStack() ->stopOnFail() ->mkdir($releaseDir) ->copy($buildFile, $versionedFile) - ->remove('codecept.phar') - ->symlink($versionedFile, 'codecept.phar') + ->remove('php82/codecept.phar') + ->symlink("../$versionedFile", 'php82/codecept.phar') ->run(); } - public function buildPhar56() - { - $version = self::BRANCH_4x . '.' . date('Ymd'); - $releaseDir = "releases/$version"; - $this->stopOnFail(); - - $this->taskFilesystemStack()->mkdir('build/56')->run(); - $this->setCodeceptionVersionTo('^4.1'); - $this->setPlatformVersionTo('5.6.4'); - $this->requireHoaConsole(); - //filenames must be different, because Phar refuses to build second file with the same name - $buildFile = 'build/56/codecept.phar'; - $this->buildPhar($buildFile); - $this->updateVersionFile($buildFile, 'php56/codecept.version'); - $versionedFile = "$releaseDir/php56/codecept.phar"; - $this->taskFilesystemStack() - ->stopOnFail() - ->mkdir("$releaseDir/php56") - ->copy($buildFile, $versionedFile) - ->remove('php56/codecept.phar') - ->symlink("../$versionedFile", 'php56/codecept.phar') - ->run(); - } - - private function requireHoaConsole(): void - { - $this->taskComposerRequire() - ->dependency('hoa/console') - ->workingDir('package') - ->run(); - } - - public function release() - { - $version = self::BRANCH_4x . '.' . date('Ymd'); - $releaseDir = "releases/$version"; - $this->updateBuildsPage(); - - $this->taskGitStack() - ->stopOnFail() - ->checkout('-- package/composer.json') - ->add('builds.markdown') - ->add('codecept.phar') - ->add('codecept.version') - ->add('php56/codecept.phar') - ->add('php56/codecept.version') - ->add($releaseDir) - ->run(); - } - - public function release80() + public function release82() { $version = self::BRANCH_5x . '.' . date('Ymd'); $releaseDir = "releases/$version"; @@ -517,23 +449,30 @@ public function release80() ->stopOnFail() ->checkout('-- package/composer.json') ->add('builds.markdown') - ->add('php80/codecept.phar') - ->add('php80/codecept.version') + ->add('php82/codecept.phar') + ->add('php82/codecept.version') ->add($releaseDir) ->run(); } - private function setPlatformVersionTo($version) + private function setPlatformVersionTo($version, $ignoredPlatformReqs = array()) { $this->taskComposerConfig()->workingDir('package')->set('platform.php', $version)->run(); - $this->taskComposerUpdate()->preferDist()->optimizeAutoloader()->workingDir('package')->run(); + $composerUpdate = $this->taskComposerUpdate(); + foreach ($ignoredPlatformReqs as $ignoredPlatformReq) { + $composerUpdate->option('--ignore-platform-req', $ignoredPlatformReq); + } + $composerUpdate->preferDist()->optimizeAutoloader()->workingDir('package')->run(); } - private function setCodeceptionVersionTo($version) + private function setCodeceptionVersionTo($version, $ignoredPlatformReqs = array()) { - $this->taskComposerRequire() - ->dependency('codeception/codeception', $version) - ->workingDir('package') + $composerRequire = $this->taskComposerRequire() + ->dependency('codeception/codeception', $version); + foreach ($ignoredPlatformReqs as $ignoredPlatformReq) { + $composerRequire->option('--ignore-platform-req', $ignoredPlatformReq); + } + $composerRequire->workingDir('package') ->run(); } @@ -638,7 +577,7 @@ public function processChangelog() $repo = $release['repo'] ?? 'Codeception'; $changelog .= sprintf("\n\n### %s %s: %s\n\n", $repo, $release['tag_name'], $release['name']); - $changelog .= sprintf("Released by [![](%s) %s](%s) on %s", + $changelog .= sprintf('Released by [![](%s){:height="16" width="16"} %s](%s) on %s', $release['author']['avatar_url'] . '&s=16', $release['author']['login'], $release['author']['html_url'], @@ -695,8 +634,10 @@ public function updateBuildsPage() $releaseFile->line("*Requires: PHP 5.4 and higher + CURL*\n"); } elseif ($major < 5) { $releaseFile->line("*Requires: PHP 5.6 and higher + CURL*\n"); - } else { + } elseif ($minor < 3) { $releaseFile->line("*Requires: PHP 8.0 and higher + CURL*\n"); + } else { + $releaseFile->line("*Requires: PHP 8.2 and higher + CURL*\n"); } $releaseFile->line("* **[Download Latest $branch Release]($downloadUrl)**"); } diff --git a/_config.yml b/_config.yml index 4be72f287..1339b5f28 100644 --- a/_config.yml +++ b/_config.yml @@ -29,4 +29,4 @@ banner: # disable content to show last blogpost # content: 'πŸŽ‰ Codeception truns 10! Join online celebration on November 30!' # content: 'Codeception is on OpenCollective! Support us πŸ’–' - content: 'πŸŽ‰ Codeception 5 is out! | πŸ‡ΊπŸ‡¦ Help Ukraine!' + content: 'πŸ‡ΊπŸ‡¦ Help Ukraine!' diff --git a/_data/extensions.yml b/_data/extensions.yml index fc0428a10..f5c77f180 100644 --- a/_data/extensions.yml +++ b/_data/extensions.yml @@ -1,3 +1,8 @@ +- name: Testomat.io Reporter + link: https://github.com/testomatio/php-reporter + description: Run reports and analytics via [Testomat.io](https://testomat.io) + image: https://testomat.io/wp-content/uploads/2022/03/Real_time_report_test_result-936x573.jpg + - name: Allure Codeception Adapter link: https://github.com/allure-framework/allure-codeception description: This is a Codeception adapter for [Allure Framework](http://allure.qatools.ru) diff --git a/_data/modules.yml b/_data/modules.yml index 6b8b770e3..d36e1192f 100644 --- a/_data/modules.yml +++ b/_data/modules.yml @@ -15,6 +15,10 @@ link: https://github.com/walterwhites/Appium-codeception-module description: Easy Appium integration, iOS Automation +- name: Axeception + link: https://github.com/flowdgmbh/codeception-axeception + description: Run axe-core acceptance tests in codeception + - name: BrowserMob link: https://github.com/edno/codeception-browsermob description: Codeception module for BrowserMob Proxy. @@ -87,10 +91,14 @@ description: Codeception module to test email using MailCare.io (Free, Open Source or paid services). color: "#e65722" +- name: Mailpit + image: ../images/mailpit.svg + link: https://github.com/koehnlein/codeception-email-mailpit + description: Mailpit is a standalone local SMTP server to test email deliveries. The Codeception module provides assertions such as `$I->haveUnreadEmails();` or `$I->seeInOpenedEmailHtmlBody()`. + - name: MailCatcher link: https://github.com/captbaritone/codeception-mailcatcher-module description: MailCatcher is a standalone software which can be configured to catch *any* email sent by your development server, and display it on a webpage. The MailCatcher Module allows you to test the contents of those emails in an acceptance test. - color: "#FFF5C4" - name: MailSMTP link: https://github.com/AhmedSamy/codeception-smtp-mail @@ -161,3 +169,7 @@ - name: Yandex link: https://github.com/portrino/codeception-yandex-module description: Validation of structured data via yandex API. + +- name: Grpc + link: https://github.com/MercerMorning/codeception-grpc-module + description: Validation of grpc server. diff --git a/_includes/announcement.html b/_includes/announcement.html deleted file mode 100644 index 1ebe1020d..000000000 --- a/_includes/announcement.html +++ /dev/null @@ -1,4 +0,0 @@ - \ No newline at end of file diff --git a/_includes/extensions.md b/_includes/extensions.md index 107bd5f04..0552d693e 100644 --- a/_includes/extensions.md +++ b/_includes/extensions.md @@ -2,10 +2,10 @@ ## DotReporter -[See Source](https://github.com/Codeception/Codeception/blob/5.0/ext/DotReporter.php) +[See Source](https://github.com/Codeception/Codeception/blob/main/ext/DotReporter.php) DotReporter provides less verbose output for test execution. -Like PHPUnit printer it prints dots "." for successful testes and "F" for failures. +Like PHPUnit printer it prints dots "." for successful tests and "F" for failures. ![](https://cloud.githubusercontent.com/assets/220264/26132800/4d23f336-3aab-11e7-81ba-2896a4c623d2.png) @@ -38,7 +38,7 @@ Use this extension as an example for building custom reporters. ## Logger -[See Source](https://github.com/Codeception/Codeception/blob/5.0/ext/Logger.php) +[See Source](https://github.com/Codeception/Codeception/blob/main/ext/Logger.php) Log suites/tests/steps using Monolog library. Monolog should be installed additionally by Composer. @@ -66,16 +66,16 @@ extensions: ## Recorder -[See Source](https://github.com/Codeception/Codeception/blob/5.0/ext/Recorder.php) +[See Source](https://github.com/Codeception/Codeception/blob/main/ext/Recorder.php) -Saves a screenshot of each step in acceptance tests and shows them as a slideshow on one HTML page (here's an [example](https://codeception.com/images/recorder.gif)) -Activated only for suites with WebDriver module enabled. +Saves a screenshot of each step in acceptance tests and shows them as a slideshow on one HTML page (here's an [example](https://codeception.com/images/recorder.gif)). +Works only for suites with WebDriver module enabled. The screenshots are saved to `tests/_output/record_*` directories, open `index.html` to see them as a slideshow. #### Installation -Add this to the list of enabled extensions in `codeception.yml` or `acceptance.suite.yml`: +Add this to the list of enabled extensions in `codeception.yml` or `Acceptance.suite.yml`: ``` yaml extensions: @@ -106,7 +106,7 @@ extensions: ``` #### Skipping recording of steps with annotations -It is also possible to skip recording of steps for specified tests by using the @skipRecording annotation. +It is also possible to skip recording of steps for specified tests by using the `@skipRecording` annotation. ```php /** @@ -122,10 +122,9 @@ public function testLogin(AcceptanceTester $I) - ## RunBefore -[See Source](https://github.com/Codeception/Codeception/blob/5.0/ext/RunBefore.php) +[See Source](https://github.com/Codeception/Codeception/blob/main/ext/RunBefore.php) Extension for execution of some processes before running tests. @@ -156,9 +155,9 @@ HINT: you can use different configurations per environment. ## RunFailed -[See Source](https://github.com/Codeception/Codeception/blob/5.0/ext/RunFailed.php) +[See Source](https://github.com/Codeception/Codeception/blob/main/ext/RunFailed.php) -Saves failed tests into tests/_output/failed in order to rerun failed tests. +Saves failed tests into `tests/_output/failed` in order to rerun failed tests. To rerun failed tests just run the `failed` group: @@ -170,9 +169,9 @@ To change failed group name add: ``` --override "extensions: config: Codeception\Extension\RunFailed: fail-group: another_group1" ``` -Remember: if you run tests and they generated custom-named fail group, to run this group, you should add override too +Remember: If you run tests and they generated custom-named fail group, to run this group, you should add override too -Starting from Codeception 2.1 **this extension is enabled by default**. +**This extension is enabled by default.** ``` yaml extensions: @@ -185,15 +184,16 @@ On each execution failed tests are logged and saved into `tests/_output/failed` ## RunProcess -[See Source](https://github.com/Codeception/Codeception/blob/5.0/ext/RunProcess.php) +[See Source](https://github.com/Codeception/Codeception/blob/main/ext/RunProcess.php) Extension to start and stop processes per suite. -Can be used to start/stop selenium server, chromedriver, mailcatcher, etc. +Can be used to start/stop selenium server, chromedriver, etc. +Each command is executed only once, at the beginning of the test suite. To execute a command before each test, see [Before/After Attributes](https://codeception.com/docs/AdvancedUsage#BeforeAfter-Attributes). -Can be configured in suite config: +Can be enabled in suite config: ```yaml -# acceptance.suite.yml +# Acceptance.suite.yml extensions: enabled: - Codeception\Extension\RunProcess: @@ -203,8 +203,7 @@ extensions: Multiple parameters can be passed as array: ```yaml -# acceptance.suite.yml - +# Acceptance.suite.yml extensions: enabled: - Codeception\Extension\RunProcess: @@ -214,28 +213,33 @@ extensions: In the end of a suite all launched processes will be stopped. -To wait for the process to be launched use `sleep` option. -In this case you need configuration to be specified as object: +To wait for the process to be launched use the `sleep` option. In this case you need configuration to be specified as object: ```yaml extensions: enabled: - Codeception\Extension\RunProcess: - 0: java -jar ~/selenium-server.jar - 1: mailcatcher - sleep: 5 # wait 5 seconds for processes to boot + 0: php -S 127.0.0.1:8000 -t tests/data/app + 1: java -jar ~/selenium-server.jar + sleep: 5 # wait 5 seconds for the processes to boot ``` -HINT: you can use different configurations per environment. +HINT: You can use different configurations per environment. ## SimpleReporter -[See Source](https://github.com/Codeception/Codeception/blob/5.0/ext/SimpleReporter.php) +[See Source](https://github.com/Codeception/Codeception/blob/main/ext/SimpleReporter.php) This extension demonstrates how you can implement console output of your own. Recommended to be used for development purposes only. +## SuiteInitSubscriberTrait + +[See Source](https://github.com/Codeception/Codeception/blob/main/ext/SuiteInitSubscriberTrait.php) + + + diff --git a/_includes/for.html b/_includes/for.html deleted file mode 100644 index 98fcead04..000000000 --- a/_includes/for.html +++ /dev/null @@ -1,55 +0,0 @@ -
-
- -
- Symfony -

Symfony

-
-
-
-
- -
- laravel -

Laravel

-
-
-
-
- -
- wordPress -

WordPress

-
-
-
-
- -
-
- -
- joomla -

joomla

-
-
-
-
- -
- yii -

Yii Framework

-
-
-
- -
- -
- Phalcon -

Phalcon

-
-
-
-
- diff --git a/_includes/frameworks.html b/_includes/frameworks.html new file mode 100644 index 000000000..e8e305b13 --- /dev/null +++ b/_includes/frameworks.html @@ -0,0 +1,35 @@ +
+
+ +
+ Symfony +

Symfony

+
+
+
+
+ +
+ laravel +

Laravel

+
+
+
+
+ +
+ yii +

Yii Framework

+
+
+
+
+ +
+ Phalcon +

Phalcon

+
+
+
+
+ diff --git a/_includes/modules.html b/_includes/modules.html index 064f069d6..1a27a238f 100644 --- a/_includes/modules.html +++ b/_includes/modules.html @@ -4,7 +4,7 @@
  • Cli
  • DataFactory
  • Db
  • -
  • Doctrine2
  • +
  • Doctrine
  • FTP
  • Filesystem
  • Laminas
  • @@ -23,4 +23,4 @@
  • SOAP
  • Symfony
  • WebDriver
  • -
  • Yii2
  • \ No newline at end of file +
  • Yii2
  • diff --git a/_includes/phar.html b/_includes/phar.html index c59fee619..203c45952 100644 --- a/_includes/phar.html +++ b/_includes/phar.html @@ -8,7 +8,7 @@

    -
    @@ -38,7 +38,7 @@

    -
    +
    @@ -66,7 +66,7 @@

    -
    +
    @@ -89,7 +89,7 @@

    - Install Phar Globally diff --git a/_includes/sponsors.html b/_includes/sponsors.html index 14658a1fd..788179c46 100644 --- a/_includes/sponsors.html +++ b/_includes/sponsors.html @@ -23,23 +23,18 @@

    Premium Sponsors

    -
    - -
    + + + + + + + + + + + + +
    diff --git a/_layouts/bootstrap.html b/_layouts/bootstrap.html index 79e525c58..299f8ffea 100644 --- a/_layouts/bootstrap.html +++ b/_layouts/bootstrap.html @@ -67,21 +67,14 @@
    diff --git a/docs/BDD.md b/docs/BDD.md index 94b2fd182..85cbe3d53 100644 --- a/docs/BDD.md +++ b/docs/BDD.md @@ -88,7 +88,7 @@ Feature file is written in Gherkin format. Codeception can generate a feature fi We will assume that we will use scenarios in feature files for acceptance tests, so feature files to be placed in `acceptance` suite directory: ```bash -php vendor/bin/codecept g:feature acceptance checkout +php vendor/bin/codecept g:feature Acceptance checkout ``` Generated template will look like this: @@ -151,13 +151,13 @@ And in the end we are verifying our expectation using **Then** keyword. The acti We can test this scenario by executing it in dry-run mode. In this mode test won't be executed (actually, we didn't define any step for it, so it won't be executed in any case). ```bash -php vendor/bin/codecept dry-run acceptance checkout.feature +php vendor/bin/codecept dry-run Acceptance checkout.feature ``` ```bash checkout: order several products Signature: checkout:order several products -Test: tests/acceptance/checkout.feature:order several products +Test: tests/Acceptance/checkout.feature:order several products Scenario -- In order to buy product As a customer @@ -181,7 +181,7 @@ Besides the scenario steps listed we got the notification that our steps are not We can define them easily by executing `gherkin:snippets` command for the given suite: ```bash -php vendor/bin/codecept gherkin:snippets acceptance +php vendor/bin/codecept gherkin:snippets Acceptance ``` This will produce code templates for all undefined steps in all feature files of this suite. @@ -403,7 +403,7 @@ Inside a step definition data is stored in argument passed as `\Behat\Gherkin\No public function iHaveProductsInCart(\Behat\Gherkin\Node\TableNode $products) { // iterate over all rows - foreach ($node->getRows() as $index => $row) { + foreach ($products->getRows() as $index => $row) { if ($index === 0) { // first row to define fields $keys = $row; continue; @@ -551,7 +551,7 @@ While Behat is a great tool for Behavior Driven Development, you still may prefe If you decided to run your features with Codeception, we recommend to start with symlinking your `features` directory into one of the test suites: ```bash -ln -s $PWD/features tests/acceptance +ln -s $PWD/features tests/Acceptance ``` Then you will need to implement all step definitions. Run `gherkin:snippets` to generate stubs for them. diff --git a/docs/Codecoverage.md b/docs/Codecoverage.md index 599493b6b..d164cfd1a 100644 --- a/docs/Codecoverage.md +++ b/docs/Codecoverage.md @@ -92,10 +92,13 @@ All you need is to execute codeception with `--coverage` option. To generate a clover xml report or a tasty html report append also `--coverage-xml` and `--coverage-html` options. -```yaml +```bash php vendor/bin/codecept run --coverage --coverage-xml --coverage-html ``` +> note: If you don't need to generate default PHP coverage report (coverage.serialized) you can call `--disable-coverage-php` option. +This option can help you reduce memory usage and fix problems with memory leak on the huge projects. + XML and HTML reports are stored to the `_output` directory. The best way to review report is to open `index.html` from `tests/_output/coverage` in your browser. XML clover reports are used by IDEs (like PHPStorm) or Continuous Integration servers (like Jenkins). @@ -150,7 +153,7 @@ coverage: ### Remote Server But if you run tests on different server (or your webserver doesn't use code from current directory) a single option `remote` should be added to config. -For example, let's turn on remote coverage for acceptance suite in `acceptance.suite.yml`: +For example, let's turn on remote coverage for acceptance suite in `Acceptance.suite.yml`: ```yaml diff --git a/docs/ContinuousIntegration.md b/docs/ContinuousIntegration.md index a7c781502..c8c893d7d 100644 --- a/docs/ContinuousIntegration.md +++ b/docs/ContinuousIntegration.md @@ -89,39 +89,36 @@ Jenkins should locate `report.html` at `tests/_output/`. Now Jenkins will displa GitHub Actions CI can be used to launch tests. Install PHP and Composer and execute tests: ```yaml -on: - pull_request: - branches-ignore: gh-pages - push: - branches-ignore: gh-pages - name: Codeception Tests - +on: + pull_request: + branches-ignore: gh-pages + push: + branches-ignore: gh-pages + jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: curl, mbstring, openssl, pdo, pdo_sqlite - ini-values: memory_limit=-1, date.timezone='UTC' - coverage: xdebug - tools: composer:v2 - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-interaction --no-suggest - - - name: Run tests - run: php vendor/bin/codecept run + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: curl, mbstring, openssl, pdo, pdo_sqlite + ini-values: memory_limit=-1, date.timezone='UTC' + coverage: xdebug + tools: composer:v2 + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction --no-suggest + + - name: Run tests + run: php vendor/bin/codecept run ``` ## GitLab CI @@ -181,7 +178,7 @@ before_script: # Test test: script: - - vendor/bin/codecept run acceptance --xml --html + - vendor/bin/codecept run Acceptance --xml --html artifacts: when: always expire_in: 1 week diff --git a/docs/Customization.md b/docs/Customization.md index 9e296b4f5..393897afd 100644 --- a/docs/Customization.md +++ b/docs/Customization.md @@ -35,10 +35,10 @@ and you want to get a single report in JUnit and HTML format. The code coverage If you want to run a specific suite from the application you can execute: ```bash -php vendor/bin/codecept run unit -c frontend +php vendor/bin/codecept run Unit -c frontend ``` -Where `unit` is the name of suite and the `-c` option specifies the path to the `codeception.yml` configuration file to use. +Where `Unit` is the name of suite and the `-c` option specifies the path to the `codeception.yml` configuration file to use. In this example we will assume that there is `frontend/codeception.yml` configuration file and that we will execute the unit tests for only that app. @@ -147,7 +147,7 @@ The extension class itself is inherited from `Codeception\Extension`: ```php getModule('Doctrine2')->_reconfigure(['cleanup' => false]); + $this->getModule('Doctrine')->_reconfigure(['cleanup' => false]); } ``` @@ -343,9 +343,9 @@ Contrary to standard assertions those assertions won't stop test on failure. Thi List of available step decorators: -- [ConditionalAssertion](https://github.com/Codeception/Codeception/blob/4.0/src/Codeception/Step/ConditionalAssertion.php) - failed assertion will be logged, but test will continue. -- [TryTo](https://github.com/Codeception/Codeception/blob/4.0/src/Codeception/Step/TryTo.php) - failed action will be ignored. -- [Retry](https://github.com/Codeception/Codeception/blob/4.0/src/Codeception/Step/Retry.php) - failed action will be retried automatically. +- [ConditionalAssertion](https://github.com/Codeception/Codeception/blob/5.0.0/src/Codeception/Step/ConditionalAssertion.php) - failed assertion will be logged, but test will continue. +- [TryTo](https://github.com/Codeception/Codeception/blob/5.0.0/src/Codeception/Step/TryTo.php) - failed action will be ignored. +- [Retry](https://github.com/Codeception/Codeception/blob/5.0.0/src/Codeception/Step/Retry.php) - failed action will be retried automatically. Step decorators can be added to suite config inside `steps` block: @@ -371,7 +371,7 @@ You can pass the `-c` option to any Codeception command (except `bootstrap`), to ``` php vendor/bin/codecept run -c ~/projects/ecommerce/ php vendor/bin/codecept run -c ~/projects/drupal -php vendor/bin/codecept generate:cest acceptance CreateArticle -c ~/projects/drupal/ +php vendor/bin/codecept generate:cest Acceptance CreateArticle -c ~/projects/drupal/ ``` @@ -393,19 +393,19 @@ Tests for groups can be specified as an array of file names or directories conta ```yaml groups: # add 2 tests to db group - db: [tests/unit/PersistTest.php, tests/unit/DataTest.php] + db: [tests/Unit/PersistTest.php, tests/Unit/DataTest.php] # add all tests from a directory to api group - api: [tests/functional/api] + api: [tests/Functional/api] ``` A list of tests for the group can be passed from a Group file. It should be defined in plain text with test names on separate lines: ``` -tests/unit/DbTest.php -tests/unit/UserTest.php:creat -tests/unit/UserTest.php:update +tests/Unit/DbTest.php +tests/Unit/UserTest.php:creat +tests/Unit/UserTest.php:update ``` A group file can be included by its relative filename: @@ -484,9 +484,9 @@ Installation template which will help your users to start testing on their proje Codeception has built-in installation templates for -* [Acceptance tests](https://github.com/Codeception/Codeception/blob/4.0/src/Codeception/Template/Acceptance.php) -* [Unit tests](https://github.com/Codeception/Codeception/blob/4.0/src/Codeception/Template/Unit.php) -* [REST API tests](https://github.com/Codeception/Codeception/blob/4.0/src/Codeception/Template/Api.php) +* [Acceptance tests](https://github.com/Codeception/Codeception/blob/5.0.0/src/Codeception/Template/Acceptance.php) +* [Unit tests](https://github.com/Codeception/Codeception/blob/5.0.0/src/Codeception/Template/Unit.php) +* [REST API tests](https://github.com/Codeception/Codeception/blob/5.0.0/src/Codeception/Template/Api.php) They can be executed with `init` command: @@ -511,7 +511,7 @@ Learn from the examples above to build a custom Installation Template. Here are * Use methods like `say`, `saySuccess`, `sayWarning`, `sayError`, `ask`, to interact with a user. * Use `createDirectoryFor`, `createEmptyDirectory` methods to create directories * Use `createHelper`, `createActor` methods to create helpers and actors. -* Use [Codeception generators](https://github.com/Codeception/Codeception/tree/4.0/src/Codeception/Lib/Generator) to create other support classes. +* Use [Codeception generators](https://github.com/Codeception/Codeception/tree/5.0.0/src/Codeception/Lib/Generator) to create other support classes. ## One Runner for Multiple Applications @@ -542,11 +542,11 @@ You should also specify the path to the `log` directory, where the reports and l It is possible to run specific suites from included applications: * `codecept run` β¬… Execute all tests from all apps and all suites -* `codecept run unit` β¬… Runs unit suite from the current app -* `codecept run admin::unit` β¬… Runs unit suite from admin app -* `codecept run *::unit` β¬… Runs unit suites from all included apps and NOT the root suite -* `codecept run unit,*::unit` β¬… Runs included unit suites AND root unit suite -* `codecept run functional,*::unit` β¬… Runs included unit suites and root functional suite +* `codecept run Unit` β¬… Runs unit suite from the current app +* `codecept run admin::Unit` β¬… Runs unit suite from admin app +* `codecept run *::Unit` β¬… Runs unit suites from all included apps and NOT the root suite +* `codecept run Unit,*::Unit` β¬… Runs included unit suites AND root unit suite +* `codecept run Functional,*::Unit` β¬… Runs included unit suites and root functional suite diff --git a/docs/Data.md b/docs/Data.md index c3511153a..9f9a44d20 100644 --- a/docs/Data.md +++ b/docs/Data.md @@ -202,21 +202,21 @@ modules: ### Doctrine Doctrine is also a popular ORM, unlike some others it implements the DataMapper pattern and is not bound to any framework. -The [Doctrine2](https://codeception.com/docs/modules/Doctrine2) module requires an `EntityManager` instance to work with. +The [Doctrine](https://codeception.com/docs/modules/Doctrine) module requires an `EntityManager` instance to work with. It can be obtained from a Symfony framework or Zend Framework (configured with Doctrine): ```yaml modules: enabled: - Symfony - - Doctrine2: + - Doctrine: depends: Symfony ``` If no framework is used with Doctrine you should provide the `connection_callback` option with a valid callback to a function which returns an `EntityManager` instance. -Doctrine2 also provides methods to create and check data: +Doctrine also provides methods to create and check data: * `haveInRepository` * `grabFromRepository` @@ -257,10 +257,10 @@ modules: modules: enabled: - Symfony - - Doctrine2: + - Doctrine: depends: Symfony - DataFactory: - depends: Doctrine2 + depends: Doctrine ``` DataFactory provides a powerful solution for managing data in integration/functional/acceptance tests. diff --git a/docs/Debugging.md b/docs/Debugging.md index b275652ae..f81445490 100644 --- a/docs/Debugging.md +++ b/docs/Debugging.md @@ -8,7 +8,7 @@ title: Debugging - Codeception Docs # Debugging Writing a test is always the process of learning the code and the application. -It is ok, if a test can't be writtng from scratch or you don't understand the effects of the code. +It is ok, if a test can't be written from scratch or you don't understand the effects of the code. By looking into the following debugging practices you will learn how to get all required information inside a test to finish it. ## Re-Running Failed Tests diff --git a/docs/FunctionalTests.md b/docs/FunctionalTests.md index 8e47885dd..f1e065637 100644 --- a/docs/FunctionalTests.md +++ b/docs/FunctionalTests.md @@ -25,7 +25,7 @@ This is a sample functional test: namespace Tests\Functional; -use \Tests\Support\FunctionalTester; +use Tests\Support\FunctionalTester; class LoginCest { @@ -75,9 +75,9 @@ To start, you need to include one of the framework modules in the suite configur ### Symfony -To perform Symfony integration you just need to include the Symfony module into your test suite. If you also use Doctrine2, -don't forget to include it too. To make the Doctrine2 module connect using the `doctrine` service from Symfony, -you should specify the Symfony module as a dependency for Doctrine2: +To perform Symfony integration you just need to include the Symfony module into your test suite. If you also use Doctrine, +don't forget to include it too. To make the Doctrine module connect using the `doctrine` service from Symfony, +you should specify the Symfony module as a dependency for Doctrine: ```yaml # Functional.suite.yml @@ -86,7 +86,7 @@ actor: FunctionalTester modules: enabled: - Symfony - - Doctrine2: + - Doctrine: depends: Symfony # connect to Symfony ``` diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 47f93f4e8..c5cf46406 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -9,8 +9,7 @@ title: Getting Started - Codeception Docs Let's take a look at Codeception's architecture. We'll assume that you have already [installed](https://codeception.com/install) it and bootstrapped your first test suites. Codeception has generated three of them: Unit, Functional, and Acceptance. -They are well described in the [previous chapter](https://codeception.com/docs/01-Introduction). Inside your __/tests__ folder you will have three `.yml` config files and three directories -with names corresponding to these suites: `Unit`, `Functional`, `Acceptance`. +They are well described in the [Introduction](https://codeception.com/docs/Introduction). Inside your __/tests__ folder you will have three `.yml` config files and three directories: `Unit`, `Functional`, `Acceptance`. ## The Codeception Syntax @@ -18,40 +17,39 @@ Codeception follows simple naming rules to make it easy to remember (as well as * **Actions** start with a plain english verb, like "click" or "fill". Examples: -```php -$I->click('Login'); -$I->fillField('#input-username', 'John Dough'); -$I->pressKey('#input-remarks', 'foo'); -``` + ```php + $I->click('Login'); + $I->fillField('#input-username', 'John Dough'); + $I->pressKey('#input-remarks', 'foo'); + ``` * **Assertions** always start with "see" or "dontSee". Examples: -```php -$I->see('Welcome'); -$I->seeInTitle('My Company'); -$I->seeElement('nav'); -$I->dontSeeElement('#error-message'); -$I->dontSeeInPageSource('
    '); -``` - -* **Grabbers** take information. The return value of those are meant to be saved as variables and used later. Example: + ```php + $I->see('Welcome'); + $I->seeInTitle('My Company'); + $I->seeElement('nav'); + $I->dontSeeElement('#error-message'); + $I->dontSeeInPageSource('
    '); + ``` -```php -$method = $I->grabAttributeFrom('#login-form', 'method'); -$I->assertEquals('post', $method); -``` +* **Grabbers** take information. The return value of those is meant to be saved as a variable and used later. Example: + ```php + $method = $I->grabAttributeFrom('#login-form', 'method'); + $I->assertSame('post', $method); + ``` ## Actors -One of the main concepts of Codeception is representation of tests as actions of a person. We have a "UnitTester", who executes functions and tests the code. We also have a "FunctionalTester", a qualified tester, +One of the main concepts of Codeception is the representation of tests as actions of a person. We have a "UnitTester", who executes functions and tests the code. We also have a "FunctionalTester", a qualified tester, who tests the application as a whole, with knowledge of its internals. Lastly we have an "AcceptanceTester", a user who works with our application in a real browser. -Methods of actor classes are generally taken from [Codeception Modules](https://codeception.com/docs/06-ModulesAndHelpers). Each module provides predefined actions for different testing purposes, and they can be combined to fit the testing environment. +Methods of actor classes are generally taken from [Codeception Modules](https://codeception.com/docs/ModulesAndHelpers). Each module provides predefined actions for different testing purposes, and they can be combined to fit the testing environment. Codeception tries to solve 90% of possible testing issues in its modules, so you don't have to reinvent the wheel. We think that you can spend more time on writing tests and less on writing support code to make those tests run. -By default, AcceptanceTester relies on [PhpBrowser](https://codeception.com/docs/modules/PhpBrowser) module, which is set in the `tests/Acceptance.suite.yml` configuration file: +By default, AcceptanceTester relies on the [PhpBrowser](https://codeception.com/docs/modules/PhpBrowser) module, which is set in the `tests/Acceptance.suite.yml` configuration file: ```yaml actor: AcceptanceTester @@ -61,7 +59,6 @@ modules: url: 'http://localhost/myapp/' ``` - In this configuration file you can enable/disable and reconfigure modules for your needs. When you change the configuration, the actor classes are rebuilt automatically. If the actor classes are not created or updated as you expect, try to generate them manually with the `build` command: @@ -70,22 +67,19 @@ try to generate them manually with the `build` command: php vendor/bin/codecept build ``` - ## Writing a Sample Test -Codeception has its own testing format called "Cest" ("Codecept" + "Test"). +Codeception has its own testing format called "Cest" (a combination of "Codecept" and "Test"). To start writing a test we need to create a new Cest file. We can do that by running the following command: ```bash php vendor/bin/codecept generate:cest Acceptance Signin ``` - -This will generate `SigninCest.php` file inside `tests/Acceptance` directory. Let's open it: +This will generate the `SigninCest.php` file inside the `tests/Acceptance` directory. Let's open it: ```php amOnPage('/login'); - $I->fillField('Username','davert'); - $I->fillField('Password','qwerty'); + $I->fillField('Username', 'davert'); + $I->fillField('Password', 'qwerty'); $I->click('Login'); $I->see('Hello, davert'); } } ``` - -This scenario can probably be read by non-technical people. If you just remove all special chars like braces, arrows and `$`, -this test transforms into plain English text: - -```yaml -I amOnPage '/login' -I fillField 'Username','davert' -I fillField 'Password','qwerty' -I click 'Login' -I see 'Hello, davert' -``` - - -Codeception generates this text representation from PHP code by executing: - -```bash -php vendor/bin/codecept generate:scenarios -``` - - -These generated scenarios will be stored in your `_data` directory in text files. - Before we execute this test, we should make sure that the website is running on a local web server. -Let's open the `tests/acceptance.suite.yml` file and replace the URL with the URL of your web application: +Let's open the `tests/Acceptance.suite.yml` file and fill in the URL of your web application: ```yaml actor: AcceptanceTester @@ -162,7 +130,6 @@ modules: url: 'http://myappurl.local' ``` - After configuring the URL we can run this test with the `run` command: ```bash @@ -174,102 +141,73 @@ This is the output we should see: ```bash Acceptance Tests (1) ------------------------------- -βœ” SigninCest: sign in successfully +βœ” SigninCest: sign in successfully (0.00s) ---------------------------------------------------- -Time: 1 second, Memory: 21.00Mb +Time: 00:00.019, Memory: 12.00 MB -OK (1 test, 1 assertions) +OK (1 test, 1 assertion) ``` - Let's get some detailed output: ``` -php vendor/bin/codecept run acceptance --steps +php vendor/bin/codecept run Acceptance --steps ``` - We should see a step-by-step report on the performed actions: ```bash Acceptance Tests (1) ------------------------------- SigninCest: Login to website Signature: SigninCest.php:signInSuccessfully -Test: tests/acceptance/SigninCest.php:signInSuccessfully +Test: tests/Acceptance/SigninCest.php:signInSuccessfully Scenario -- I am on page "/login" I fill field "Username" "davert" I fill field "Password" "qwerty" I click "Login" I see "Hello, davert" - OK + PASSED ---------------------------------------------------- -Time: 0 seconds, Memory: 21.00Mb +Time: 00:00.019, Memory: 12.00 MB -OK (1 test, 1 assertions) +OK (1 test, 1 assertion) ``` +This simple test can be extended to a complete scenario of site usage, therefore, by emulating the user's actions, you can test any of your websites. -This simple test can be extended to a complete scenario of site usage, therefore, -by emulating the user's actions, you can test any of your websites. - -To run more tests create a public method for each of them. Include `AcceptanceTester` object as `$I` as a method parameter and use the same `$I->` API you've seen before. -If your tests share common setup actions put them into `_before` method. - -For instance, to test CRUD we want 4 methods to be implemented and all next tests should start at `/task` page: +To run more tests, create a public method for each of them. If your tests share common setup actions, put them into the `_before()` method: ```php amOnPage('/task'); } - - function createTask(AcceptanceTester $I) - { - // todo: write test - } - - function viewTask(AcceptanceTester $I) - { - // todo: write test - } - - function updateTask(AcceptanceTester $I) - { - // todo: write test - } - - function deleteTask(AcceptanceTester $I) - { - // todo: write test - } } ``` +Learn more about the [Cest format](https://codeception.com/docs/AdvancedUsage#Cest-Classes) in the Advanced Testing chapter. -Learn more about the [Cest format](https://codeception.com/docs/07-AdvancedUsage#Cest-Classes) in the Advanced Testing section. - -## BDD +## Behavior Driven Development (BDD) -Codeception allows execution of user stories in Gherkin format in a similar manner as is done in Cucumber or Behat. -Please refer to [the BDD chapter](https://codeception.com/docs/07-BDD) to learn more. +Codeception allows execution of user stories in Gherkin format in a similar manner as it is done in Cucumber or Behat. +Please refer to [the BDD chapter](https://codeception.com/docs/BDD) to learn more. ## Configuration -Codeception has a global configuration in `codeception.yml` and a config for each suite. We also support `.dist` configuration files. +Codeception has a global configuration file `codeception.yml` and a config for each suite. We also support `.dist` configuration files. If you have several developers in a project, put shared settings into `codeception.dist.yml` and personal settings into `codeception.yml`. -The same goes for suite configs. For example, the `unit.suite.yml` will be merged with `unit.suite.dist.yml`. +The same goes for suite configs. For example, the `Unit.suite.yml` will be merged with `Unit.suite.dist.yml`. ## Running Tests @@ -279,51 +217,44 @@ Tests can be started with the `run` command: php vendor/bin/codecept run ``` - With the first argument you can run all tests from one suite: ```bash -php vendor/bin/codecept run acceptance +php vendor/bin/codecept run Acceptance ``` - To limit tests run to a single class, add a second argument. Provide a local path to the test class, from the suite directory: ```bash -php vendor/bin/codecept run acceptance SigninCest.php +php vendor/bin/codecept run Acceptance SigninCest.php ``` - -Alternatively you can provide the full path to test file: +Alternatively you can provide the full path to the test file: ```bash -php vendor/bin/codecept run tests/acceptance/SigninCest.php +php vendor/bin/codecept run tests/Acceptance/SigninCest.php ``` - -You can further filter which tests are run by appending a method name to the class, separated by a colon (for Cest or Test formats): +You can further filter which tests to run by appending a method name to the class, separated by a colon: ```bash -php vendor/bin/codecept run tests/acceptance/SigninCest.php:^anonymousLogin$ +php vendor/bin/codecept run tests/Acceptance/SigninCest.php:^anonymousLogin$ ``` - -You can provide a directory path as well. This will execute all acceptance tests from the `backend` dir: +You can provide a directory path as well. This will execute all Acceptance tests from the `backend` dir: ```bash -php vendor/bin/codecept run tests/acceptance/backend +php vendor/bin/codecept run tests/Acceptance/backend ``` - Using regular expressions, you can even run many different test methods from the same directory or class. -For example, this will execute all acceptance tests from the `backend` dir beginning with the word "login": +For example, this will execute all Acceptance tests from the `backend` dir beginning with the word "login": ```bash -php vendor/bin/codecept run tests/acceptance/backend:^login +php vendor/bin/codecept run tests/Acceptance/backend:^login ``` - -To execute a group of tests that are not stored in the same directory, you can organize them in [groups](https://codeception.com/docs/07-AdvancedUsage#Groups). +To execute a group of tests that are not stored in the same directory, you can organize them in [groups](https://codeception.com/docs/AdvancedUsage#Groups). ### Reports @@ -334,7 +265,7 @@ php vendor/bin/codecept run --steps --xml --html ``` -This command will run all tests for all suites, displaying the steps, and building HTML and XML reports. Reports will be stored in the `tests/_output/` directory. +This command will run all tests for all suites, displaying the steps, and building HTML and XML reports. The reports will be stored in the `tests/_output/` directory. Learn more about [available reports](/docs/Reporting). @@ -352,7 +283,6 @@ There are plenty of useful Codeception commands: * `generate:test` *suite* *filename* - Generates a sample PHPUnit Test with Codeception hooks * `generate:feature` *suite* *filename* - Generates Gherkin feature file * `generate:suite` *suite* *actor* - Generates a new suite with the given Actor class name -* `generate:scenarios` *suite* - Generates text files containing scenarios from tests * `generate:helper` *filename* - Generates a sample Helper File * `generate:pageobject` *suite* *filename* - Generates a sample Page object * `generate:stepobject` *suite* *filename* - Generates a sample Step object @@ -361,7 +291,7 @@ There are plenty of useful Codeception commands: ## Conclusion -We have taken a look into the Codeception structure. Most of the things you need were already generated by the `bootstrap` command. +We have taken a look into Codeception's structure. Most of the things you need were already generated by the `bootstrap` command. After you have reviewed the basic concepts and configurations, you can start writing your first scenario. diff --git a/docs/Introduction.md b/docs/Introduction.md index bd625e9fa..eefbfacea 100644 --- a/docs/Introduction.md +++ b/docs/Introduction.md @@ -13,15 +13,12 @@ Having your application covered with tests gives you more trust in the stability In most cases tests don't guarantee that the application works 100% as it is supposed to. You can't predict all possible scenarios and exceptional situations for complex apps, -but with tests you can cover the most important parts of your app and at least be sure they work as predicted. +but with tests you can cover the most important parts of your app. There are plenty of ways to test your application. The most popular paradigm is [Unit Testing](https://en.wikipedia.org/wiki/Unit_testing). -For web applications, testing just the controller and/or the model doesn't prove that your application is working. -To test the behavior of your application as a whole, you should write functional or acceptance tests. - -Codeception supports all three testing types. -Out of the box you have tools for writing unit, functional, and acceptance tests in a unified framework. +But for web applications, testing just the controller and/or the model doesn't prove that your application is working. +To test the behavior of your application as a whole, you should also write functional or acceptance tests. | | Unit Tests | Functional Tests | Acceptance Tests | --- | --- | --- | --- | @@ -29,20 +26,21 @@ Out of the box you have tools for writing unit, functional, and acceptance tests | Testing computer needs access to project's PHP files | Yes | Yes | No | | Webserver required | No | No | Yes | | JavaScript | No | No | Yes | -| Additional software required | None | None | Drivers for Firefox/Chrome | +| Additional software required | None | None | chromedriver / geckodriver | | Test execution speed | Very fast | Fast | Slow | | Configuration file | `Unit.suite.yml` | `Functional.suite.yml` | `Acceptance.suite.yml` | -One of the main advantages of Codeception is that you don't have to decide on just *one* type of testing. You should have all three! +One of the main advantages of Codeception is that you don't have to decide on just *one* type of testing. You can have all three! And chances are, that you will (sooner or later) need all three. That's why Codeception consists of three so-called "suites": -A "Unit suite" for all unit tests, a "functional suite" for all functional tests, and an "Acceptance suite" for all acceptance tests. +* A "Unit suite" for all unit tests, +* a "Functional suite" for all functional tests, +* and an "Acceptance suite" for all acceptance tests. Let's review those three test types in reverse order. ### Acceptance Tests -How does your client, manager, tester, or any other non-technical person know your website is working? By opening the browser, accessing the site, clicking on links, filling in the forms, and actually seeing the content on a web page. They have no idea of the programming language, framework, database, web-server, -or why the application did (or did not) behave as expected. +How does your client know your website is working? By opening the browser, accessing the site, clicking on links, filling in the forms, and actually seeing the content on a web page. This is what acceptance tests are doing. They cover scenarios from a user's perspective. With acceptance tests, you can be confident that users, following all the defined scenarios, won't get errors. @@ -52,13 +50,16 @@ With acceptance tests, you can be confident that users, following all the define #### Sample acceptance test ```php -$I->amOnPage('/'); -$I->click('Sign Up'); -$I->submitForm('#signup', [ - 'username' => 'MilesDavis', - 'email' => 'miles@davis.com' -]); -$I->see('Thank you for Signing Up!'); +public function trySignupForm(AcceptanceTester $I): void +{ + $I->amOnPage('/'); + $I->click('Sign Up'); + $I->submitForm('#signup', [ + 'username' => 'MilesDavis', + 'email' => 'miles@example.com' + ]); + $I->see('Thank you for Signing Up!'); +} ``` ### Functional Tests @@ -73,15 +74,21 @@ For functional tests, your application needs to be structured in order to run in #### Sample functional test ```php -$I->amOnPage('/'); -$I->click('Sign Up'); -$I->submitForm('#signup', ['username' => 'MilesDavis', 'email' => 'miles@davis.com']); -$I->see('Thank you for Signing Up!'); -$I->seeEmailIsSent('miles@davis.com', 'Thank you for your registration'); -$I->seeInDatabase('users', ['email' => 'miles@davis.com']); +public function trySignupForm(FunctionalTester $I): void +{ + $I->amOnPage('/'); + $I->click('Sign Up'); + $I->submitForm('#signup', [ + 'username' => 'MilesDavis', + 'email' => 'miles@example.com' + ]); + $I->see('Thank you for Signing Up!'); + $I->seeEmailIsSent('miles@example.com', 'Thank you for your registration'); + $I->seeInDatabase('users', ['email' => 'miles@example.com']); +} ``` -> This looks very similar to acceptance tests. The behavior is the same, however, the test is executed inside PHP without launching a real browser. +This looks very similar to acceptance tests. The behavior is the same, however, the test is executed in PHP without launching a real browser. ### Unit Tests @@ -97,19 +104,19 @@ Requirements and code can change rapidly, and unit tests should be updated every time to fit the requirements. The better you understand the testing scenario, the faster you can update it for new behavior. -#### Sample integration test +#### Sample unit test ```php -public function testSavingUser() +public function testSavingUser(): void { $user = new User(); - $user->setName('Miles'); - $user->setSurname('Davis'); + $user->setFirstName('Miles'); + $user->setLastName('Davis'); $user->save(); - $this->assertEquals('Miles Davis', $user->getFullName()); + $this->assertSame('Miles Davis', $user->getFullName()); $this->tester->seeInDatabase('users', [ - 'name' => 'Miles', - 'surname' => 'Davis' + 'firstName' => 'Miles', + 'lastName' => 'Davis' ]); } ``` @@ -120,6 +127,6 @@ The Codeception framework was developed to actually make testing fun. It allows writing unit, functional, integration, and acceptance tests in a single, coherent style. All Codeception tests are written in a descriptive manner. -Just by looking at the test body, you can clearly understand what is being tested and how it is performed. +Just by looking at the test body, you can clearly understand what is being tested. diff --git a/docs/ParallelExecution.md b/docs/ParallelExecution.md index 8bf25da48..c3c2a15e8 100644 --- a/docs/ParallelExecution.md +++ b/docs/ParallelExecution.md @@ -146,9 +146,9 @@ Codeception can organize tests into [groups](https://codeception.com/docs/Advanc ```bash -tests/functional/LoginCept.php -tests/functional/AdminCest.php:createUser -tests/functional/AdminCest.php:deleteUser +tests/Functional/LoginCept.php +tests/Functional/AdminCest.php:createUser +tests/Functional/AdminCest.php:deleteUser ``` Tasks from `\Codeception\Task\SplitTestsByGroups` will generate non-intersecting group files. You can either split your tests by files or by single tests: @@ -159,7 +159,7 @@ public function parallelSplitTests() // Split your tests by files $this->taskSplitTestFilesByGroups(5) ->projectRoot('.') - ->testsFrom('tests/acceptance') + ->testsFrom('tests/Acceptance') ->groupsTo('tests/Support/Data/paracept_') ->run(); @@ -167,7 +167,7 @@ public function parallelSplitTests() // Split your tests by single tests (alternatively) $this->taskSplitTestsByGroups(5) ->projectRoot('.') - ->testsFrom('tests/acceptance') + ->testsFrom('tests/Acceptance') ->groupsTo('tests/Support/Data/paracept_') ->run(); */ @@ -207,7 +207,7 @@ Let's try to execute tests from the second group: ```bash -php vendor/bin/codecept run acceptance -g paracept_2 +php vendor/bin/codecept run Acceptance -g paracept_2 ``` #### Step 2: Running Tests @@ -228,7 +228,7 @@ public function parallelRun() for ($i = 1; $i <= 5; $i++) { $parallel->process( $this->taskCodecept() // use built-in Codecept task - ->suite('acceptance') // run acceptance tests + ->suite('Acceptance') // run acceptance tests ->group("paracept_$i") // for all paracept_* groups ->xml("tests/_log/result_$i.xml") // save XML results ); diff --git a/docs/Reporting.md b/docs/Reporting.md index f863ae49a..f715a0f33 100644 --- a/docs/Reporting.md +++ b/docs/Reporting.md @@ -125,7 +125,7 @@ php vendor/bin/codecept run --xml ![](/images/codecept-allure.png) -[Allure](https://docs.qameta.io/allure/) is a popular open-source reporting tool. It can be paired with Codeception to get a detailed run report. Use [Allure extension](https://github.com/allure-framework/allure-codeception) to generate report which can be passed to Allure to display it. +[Allure](https://allurereport.org/docs/) is a popular open-source reporting tool. It can be paired with Codeception to get a detailed run report. Use [Allure extension](https://github.com/allure-framework/allure-codeception) to generate report which can be passed to Allure to display it. ## Custom Reporter diff --git a/docs/ReusingTestCode.md b/docs/ReusingTestCode.md index 18ef9559a..87b89090e 100644 --- a/docs/ReusingTestCode.md +++ b/docs/ReusingTestCode.md @@ -95,7 +95,7 @@ Do not hard-code complex CSS or XPath locators in your tests but rather move the Codeception can generate a PageObject class for you with command: ``` -php vendor/bin/codecept generate:pageobject acceptance Login +php vendor/bin/codecept generate:pageobject Acceptance Login ``` > It is recommended to use page objects for acceptance testing only @@ -167,8 +167,8 @@ In the case of a PageObject you should declare a class as a parameter for a test namespace Tests\Acceptance; -use \Tests\Support\AcceptanceTester; -use \Tests\Support\Page\Acceptance\Login; +use Tests\Support\AcceptanceTester; +use Tests\Support\Page\Acceptance\Login; class UserCest { @@ -197,17 +197,17 @@ We call such a classes StepObjects. Lets create an Admin StepObject with the generator: ``` -php vendor/bin/codecept generate:stepobject acceptance Admin +php vendor/bin/codecept generate:stepobject Acceptance Admin ``` You can supply optional action names. Enter one at a time, followed by a newline. End with an empty line to continue to StepObject creation. ``` -php vendor/bin/codecept generate:stepobject acceptance Admin +php vendor/bin/codecept generate:stepobject Acceptance Admin Add action to StepObject class (ENTER to exit): loginAsAdmin Add action to StepObject class (ENTER to exit): -StepObject was created in /tests/acceptance/_support/Step/Acceptance/Admin.php +StepObject was created in /tests/Acceptance/_support/Step/Acceptance/Admin.php ``` This will generate a class in `/tests/Support/Step/Acceptance/Admin.php` similar to this: diff --git a/docs/UnitTests.md b/docs/UnitTests.md index 2b0cbba24..972e26494 100644 --- a/docs/UnitTests.md +++ b/docs/UnitTests.md @@ -19,7 +19,7 @@ Create a test using `generate:test` command with a suite and test names as param php vendor/bin/codecept generate:test Unit Example ``` -It creates a new `ExampleTest` file located in the `tests/unit` directory. +It creates a new `ExampleTest` file located in the `tests/Unit` directory. As always, you can run the newly created test with this command: @@ -40,7 +40,7 @@ A test created by the `generate:test` command will look like this: namespace Tests\Unit; -use \Tests\Support\UnitTester; +use Tests\Support\UnitTester; class ExampleTest extends \Codeception\Test\Unit { @@ -76,7 +76,7 @@ A typical unit test may look like this: namespace Tests\Unit; -use \Tests\Support\UnitTester; +use Tests\Support\UnitTester; class UserTest extends \Codeception\Test\Unit { @@ -151,7 +151,8 @@ $name = $user->getName(); // 'john' [See complete reference](https://codeception.com/docs/reference/Mock) -Inside unit tests (`Codeception\Test\Unit`) it is recommended to use alternative API: +To keep compatibility with PHPUnit its verification of expectations for Mocks, +it is recommended to use alternative API in unit tests (`Codeception\Test\Unit`): ```php // create a stub with find method replaced @@ -254,7 +255,7 @@ function testSavingUser() ``` To enable the database functionality in unit tests, make sure the `Db` module is included -in the `unit.suite.yml` configuration file. +in the `Unit.suite.yml` configuration file. The database will be cleaned and populated after each test, the same way it happens for acceptance and functional tests. If that's not your required behavior, change the settings of the `Db` module for the current suite. See [Db Module](https://codeception.com/docs/modules/Db) @@ -298,19 +299,19 @@ A very similar approach can be used for all frameworks that have an ORM implemen In Yii2 and Phalcon, the methods `haveRecord`, `seeRecord`, `dontSeeRecord` work in the same way. They also should be included by specifying `part: ORM` in order to not use the functional testing actions. -If you are using Symfony with Doctrine, you don't need to enable Symfony itself but just Doctrine2: +If you are using Symfony with Doctrine, you don't need to enable Symfony itself but just Doctrine: ```yaml actor: UnitTester modules: enabled: - Asserts - - Doctrine2: + - Doctrine: depends: Symfony - \Helper\Unit ``` -In this case you can use the methods from the Doctrine2 module, while Doctrine itself uses the Symfony module +In this case you can use the methods from the Doctrine module, while Doctrine itself uses the Symfony module to establish connections to the database. In this case a test might look like: ```php @@ -320,7 +321,7 @@ function testUserNameCanBeChanged() // create a user from framework, user will be deleted after the test $id = $this->tester->haveInRepository(User::class, ['name' => 'miles']); // get entity manager by accessing module - $em = $this->getModule('Doctrine2')->em; + $em = $this->getModule('Doctrine')->em; // get real user $user = $em->find(User::class, $id); $user->setName('bill'); @@ -334,7 +335,7 @@ function testUserNameCanBeChanged() ``` In both examples you should not be worried about the data persistence between tests. -The Doctrine2 and Laravel modules will clean up the created data at the end of a test. +The Doctrine and Laravel modules will clean up the created data at the end of a test. This is done by wrapping each test in a transaction and rolling it back afterwards. ### Accessing Module @@ -343,19 +344,19 @@ Codeception allows you to access the properties and methods of all modules defin Unlike using the UnitTester class for this purpose, using a module directly grants you access to all public properties of that module. -We have already demonstrated this in a previous example where we accessed the Entity Manager from a Doctrine2 module: +We have already demonstrated this in a previous example where we accessed the Entity Manager from a Doctrine module: ```php getModule('Doctrine2')->em; +$em = $this->getModule('Doctrine')->em; ``` If you use the `Symfony` module, here is how you can access the Symfony container: ```php -/** @var Symfony\Component\DependencyInjection\Container */ -$container = $this->getModule('Symfony')->container; +/** @var Symfony\Component\DependencyInjection\ContainerInterface */ +$container = $this->getModule('Symfony')->_getContainer(); ``` The same can be done for all public properties of an enabled module. Accessible properties are listed in the module reference. @@ -402,7 +403,7 @@ For this case we have a stand-alone project [Specify](https://github.com/Codecep namespace Tests\Unit; -use \Tests\Support\UnitTester; +use Tests\Support\UnitTester; class UserTest extends \Codeception\Test\Unit { diff --git a/docs/modules/AMQP.md b/docs/modules/AMQP.md index 8528a4ffb..c53997267 100644 --- a/docs/modules/AMQP.md +++ b/docs/modules/AMQP.md @@ -10,24 +10,11 @@ title: AMQP - Codeception - Documentation # AMQP ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-amqp {% endhighlight %} -Alternatively, you can enable `AMQP` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -48,6 +35,7 @@ To use this module with Composer you need "php-amqplib/php-amqplib": "~2.4"< * cleanup: true - defined queues will be purged before running every test. * queues: [mail, twitter] - queues to cleanup * single_channel - create and use only one channel during test execution +* reconnect - reconnects before each test to drop unused open channels #### Example @@ -61,6 +49,7 @@ To use this module with Composer you need "php-amqplib/php-amqplib": "~2.4"< vhost: '/' queues: [queue1, queue2] single_channel: false + reconnect: false ### Public Properties diff --git a/docs/modules/Apc.md b/docs/modules/Apc.md index 5ab0da129..043112565 100644 --- a/docs/modules/Apc.md +++ b/docs/modules/Apc.md @@ -10,24 +10,11 @@ title: Apc - Codeception - Documentation # Apc ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-apc {% endhighlight %} -Alternatively, you can enable `Apc` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description diff --git a/docs/modules/Asserts.md b/docs/modules/Asserts.md index 506bcb477..125aa4c4b 100644 --- a/docs/modules/Asserts.md +++ b/docs/modules/Asserts.md @@ -10,24 +10,11 @@ title: Asserts - Codeception - Documentation # Asserts ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-asserts {% endhighlight %} -Alternatively, you can enable `Asserts` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -38,18 +25,20 @@ Special module for using asserts in your tests. #### assertArrayHasKey -* `param int|string` $key -* `param array|\ArrayAccess` $array +* `param string|int` $key +* `param \ArrayAccess|array` $array * `param string` $message +* `return void` Asserts that an array has a specified key. #### assertArrayNotHasKey -* `param int|string` $key -* `param array|\ArrayAccess` $array +* `param string|int` $key +* `param \ArrayAccess|array` $array * `param string` $message +* `return void` Asserts that an array does not have a specified key. @@ -57,8 +46,9 @@ Asserts that an array does not have a specified key. #### assertClassHasAttribute * `param string` $attributeName -* `param string` $className +* `param class-string` $className * `param string` $message +* `return void` Asserts that a class has a specified attribute. @@ -66,8 +56,9 @@ Asserts that a class has a specified attribute. #### assertClassHasStaticAttribute * `param string` $attributeName -* `param string` $className +* `param class-string` $className * `param string` $message +* `return void` Asserts that a class has a specified static attribute. @@ -75,8 +66,9 @@ Asserts that a class has a specified static attribute. #### assertClassNotHasAttribute * `param string` $attributeName -* `param string` $className +* `param class-string` $className * `param string` $message +* `return void` Asserts that a class does not have a specified attribute. @@ -84,8 +76,9 @@ Asserts that a class does not have a specified attribute. #### assertClassNotHasStaticAttribute * `param string` $attributeName -* `param string` $className +* `param class-string` $className * `param string` $message +* `return void` Asserts that a class does not have a specified static attribute. @@ -93,8 +86,9 @@ Asserts that a class does not have a specified static attribute. #### assertContains * `param mixed` $needle -* `param iterable` $haystack +* `param iterable` $haystack * `param string` $message +* `return void` Asserts that a haystack contains a needle. @@ -102,34 +96,228 @@ Asserts that a haystack contains a needle. #### assertContainsEquals * `param mixed` $needle -* `param iterable` $haystack +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyArray + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyBool + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyCallable + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyClosedResource + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyFloat + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyInstancesOf + +* `param class-string` $className +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyInt + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyIterable + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyNull + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyNumeric + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyObject + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyResource + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyScalar + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsNotOnlyString + +* `param iterable` $haystack * `param string` $message +* `return void` #### assertContainsOnly * `param string` $type -* `param iterable` $haystack +* `param iterable` $haystack * `param ?bool` $isNativeType * `param string` $message +* `return void` Asserts that a haystack contains only values of a given type. +#### assertContainsOnlyArray + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsOnlyBool + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsOnlyCallable + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsOnlyClosedResource + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsOnlyFloat + +* `param iterable` $haystack +* `param string` $message +* `return void` + + #### assertContainsOnlyInstancesOf -* `param string` $className -* `param iterable` $haystack +* `param class-string` $className +* `param iterable` $haystack * `param string` $message +* `return void` Asserts that a haystack contains only instances of a given class name. +#### assertContainsOnlyInt + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsOnlyIterable + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsOnlyNull + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsOnlyNumeric + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsOnlyObject + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsOnlyResource + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsOnlyScalar + +* `param iterable` $haystack +* `param string` $message +* `return void` + + +#### assertContainsOnlyString + +* `param iterable` $haystack +* `param string` $message +* `return void` + + #### assertCount * `param int` $expectedCount -* `param \Countable|iterable` $haystack +* `param \Countable|iterable` $haystack * `param string` $message +* `return void` Asserts the number of elements of an array, Countable or Traversable. @@ -138,6 +326,7 @@ Asserts the number of elements of an array, Countable or Traversable. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory does not exist. @@ -146,6 +335,7 @@ Asserts that a directory does not exist. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory exists. @@ -154,6 +344,7 @@ Asserts that a directory exists. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory exists and is not readable. @@ -162,6 +353,7 @@ Asserts that a directory exists and is not readable. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory exists and is not writable. @@ -170,6 +362,7 @@ Asserts that a directory exists and is not writable. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory exists and is readable. @@ -178,6 +371,7 @@ Asserts that a directory exists and is readable. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory exists and is writable. @@ -187,14 +381,17 @@ Asserts that a directory exists and is writable. * `param string` $pattern * `param string` $string * `param string` $message +* `return void` Asserts that a string does not match a given regular expression. #### assertEmpty +* `phpstan-assert` empty $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is empty. @@ -204,6 +401,7 @@ Asserts that a variable is empty. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are equal. @@ -213,6 +411,7 @@ Asserts that two variables are equal. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are equal (canonicalizing). @@ -222,6 +421,7 @@ Asserts that two variables are equal (canonicalizing). * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are equal (ignoring case). @@ -232,14 +432,17 @@ Asserts that two variables are equal (ignoring case). * `param mixed` $actual * `param float` $delta * `param string` $message +* `return void` Asserts that two variables are equal (with delta). #### assertFalse +* `phpstan-assert` false $condition * `param mixed` $condition * `param string` $message +* `return void` Asserts that a condition is false. @@ -248,6 +451,7 @@ Asserts that a condition is false. * `param string` $filename * `param string` $message +* `return void` Asserts that a file does not exist. @@ -257,6 +461,7 @@ Asserts that a file does not exist. * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is equal to the contents of another file. @@ -266,6 +471,7 @@ Asserts that the contents of one file is equal to the contents of another file. * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is equal to the contents of another file (canonicalizing). @@ -275,6 +481,7 @@ Asserts that the contents of one file is equal to the contents of another file ( * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is equal to the contents of another file (ignoring case). @@ -283,6 +490,7 @@ Asserts that the contents of one file is equal to the contents of another file ( * `param string` $filename * `param string` $message +* `return void` Asserts that a file exists. @@ -291,6 +499,7 @@ Asserts that a file exists. * `param string` $file * `param string` $message +* `return void` Asserts that a file exists and is not readable. @@ -299,6 +508,7 @@ Asserts that a file exists and is not readable. * `param string` $file * `param string` $message +* `return void` Asserts that a file exists and is not writable. @@ -307,6 +517,7 @@ Asserts that a file exists and is not writable. * `param string` $file * `param string` $message +* `return void` Asserts that a file exists and is readable. @@ -315,6 +526,7 @@ Asserts that a file exists and is readable. * `param string` $file * `param string` $message +* `return void` Asserts that a file exists and is writable. @@ -324,6 +536,7 @@ Asserts that a file exists and is writable. * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is not equal to the contents of another file. @@ -333,6 +546,7 @@ Asserts that the contents of one file is not equal to the contents of another fi * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is not equal to the contents of another file (canonicalizing). @@ -342,6 +556,7 @@ Asserts that the contents of one file is not equal to the contents of another fi * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is not equal to the contents of another file (ignoring case). @@ -350,6 +565,7 @@ Asserts that the contents of one file is not equal to the contents of another fi * `param string` $filename * `param string` $message +* `return void` Asserts that a file does not exist. @@ -358,6 +574,7 @@ Asserts that a file does not exist. * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is finite. @@ -367,6 +584,7 @@ Asserts that a variable is finite. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is greater than or equal to another value. @@ -376,6 +594,7 @@ Asserts that a value is greater than or equal to another value. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is greater than another value. @@ -385,6 +604,7 @@ Asserts that a value is greater than another value. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is greater than or equal to another value. @@ -393,47 +613,59 @@ Asserts that a value is greater than or equal to another value. * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is infinite. #### assertInstanceOf -* `param string` $expected +* `template` ExpectedType of object +* `phpstan-assert` =ExpectedType $actual +* `param class-string` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of a given type. #### assertIsArray +* `phpstan-assert` array $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type array. #### assertIsBool +* `phpstan-assert` bool $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type bool. #### assertIsCallable +* `phpstan-assert` callable $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type callable. #### assertIsClosedResource +* `phpstan-assert` resource $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type resource and is closed. @@ -442,102 +674,127 @@ Asserts that a variable is of type resource and is closed. * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is empty. #### assertIsFloat +* `phpstan-assert` float $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type float. #### assertIsInt +* `phpstan-assert` int $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type int. #### assertIsIterable +* `phpstan-assert` iterable $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type iterable. #### assertIsNotArray +* `phpstan-assert` !array $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type array. #### assertIsNotBool +* `phpstan-assert` !bool $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type bool. #### assertIsNotCallable +* `phpstan-assert` !callable $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type callable. #### assertIsNotClosedResource +* `phpstan-assert` !resource $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type resource. #### assertIsNotFloat +* `phpstan-assert` !float $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type float. #### assertIsNotInt +* `phpstan-assert` !int $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type int. #### assertIsNotIterable +* `phpstan-assert` !iterable $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type iterable. #### assertIsNotNumeric +* `phpstan-assert` !numeric $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type numeric. #### assertIsNotObject +* `phpstan-assert` !object $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type object. @@ -546,30 +803,37 @@ Asserts that a variable is not of type object. * `param string` $filename * `param string` $message +* `return void` Asserts that a file/dir exists and is not readable. #### assertIsNotResource +* `phpstan-assert` !resource $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type resource. #### assertIsNotScalar +* `psalm-assert` !scalar $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type scalar. #### assertIsNotString +* `phpstan-assert` !string $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type string. @@ -578,22 +842,27 @@ Asserts that a variable is not of type string. * `param string` $filename * `param string` $message +* `return void` Asserts that a file/dir exists and is not writable. #### assertIsNumeric +* `phpstan-assert` numeric $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type numeric. #### assertIsObject +* `phpstan-assert` object $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type object. @@ -602,30 +871,37 @@ Asserts that a variable is of type object. * `param string` $filename * `param string` $message +* `return void` Asserts that a file/dir is readable. #### assertIsResource +* `phpstan-assert` resource $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type resource. #### assertIsScalar +* `phpstan-assert` scalar $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type scalar. #### assertIsString +* `phpstan-assert` string $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type string. @@ -634,6 +910,7 @@ Asserts that a variable is of type string. * `param string` $filename * `param string` $message +* `return void` Asserts that a file/dir exists and is writable. @@ -642,6 +919,7 @@ Asserts that a file/dir exists and is writable. * `param string` $actualJson * `param string` $message +* `return void` Asserts that a string is a valid JSON string. @@ -651,6 +929,7 @@ Asserts that a string is a valid JSON string. * `param string` $expectedFile * `param string` $actualFile * `param string` $message +* `return void` Asserts that two JSON files are equal. @@ -660,6 +939,7 @@ Asserts that two JSON files are equal. * `param string` $expectedFile * `param string` $actualFile * `param string` $message +* `return void` Asserts that two JSON files are not equal. @@ -669,6 +949,7 @@ Asserts that two JSON files are not equal. * `param string` $expectedFile * `param string` $actualJson * `param string` $message +* `return void` Asserts that the generated JSON encoded object and the content of the given file are equal. @@ -678,6 +959,7 @@ Asserts that the generated JSON encoded object and the content of the given file * `param string` $expectedJson * `param string` $actualJson * `param string` $message +* `return void` Asserts that two given JSON encoded objects or arrays are equal. @@ -687,6 +969,7 @@ Asserts that two given JSON encoded objects or arrays are equal. * `param string` $expectedFile * `param string` $actualJson * `param string` $message +* `return void` Asserts that the generated JSON encoded object and the content of the given file are not equal. @@ -696,6 +979,7 @@ Asserts that the generated JSON encoded object and the content of the given file * `param string` $expectedJson * `param string` $actualJson * `param string` $message +* `return void` Asserts that two given JSON encoded objects or arrays are not equal. @@ -705,6 +989,7 @@ Asserts that two given JSON encoded objects or arrays are not equal. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is smaller than or equal to another value. @@ -714,6 +999,7 @@ Asserts that a value is smaller than or equal to another value. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is smaller than another value. @@ -723,6 +1009,7 @@ Asserts that a value is smaller than another value. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is smaller than or equal to another value. @@ -732,6 +1019,7 @@ Asserts that a value is smaller than or equal to another value. * `param string` $pattern * `param string` $string * `param string` $message +* `return void` Asserts that a string matches a given regular expression. @@ -740,6 +1028,7 @@ Asserts that a string matches a given regular expression. * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is nan. @@ -747,25 +1036,28 @@ Asserts that a variable is nan. #### assertNotContains * `param mixed` $needle -* `param iterable` $haystack +* `param iterable` $haystack * `param string` $message +* `return void` Asserts that a haystack does not contain a needle. #### assertNotContainsEquals -* `param ` $needle -* `param iterable` $haystack +* `param mixed` $needle +* `param iterable` $haystack * `param string` $message +* `return void` #### assertNotContainsOnly * `param string` $type -* `param iterable` $haystack +* `param iterable` $haystack * `param ?bool` $isNativeType * `param string` $message +* `return void` Asserts that a haystack does not contain only values of a given type. @@ -773,16 +1065,19 @@ Asserts that a haystack does not contain only values of a given type. #### assertNotCount * `param int` $expectedCount -* `param \Countable|iterable` $haystack +* `param \Countable|iterable` $haystack * `param string` $message +* `return void` Asserts the number of elements of an array, Countable or Traversable. #### assertNotEmpty +* `phpstan-assert` !empty $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not empty. @@ -792,6 +1087,7 @@ Asserts that a variable is not empty. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are not equal. @@ -801,6 +1097,7 @@ Asserts that two variables are not equal. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are not equal (canonicalizing). @@ -810,6 +1107,7 @@ Asserts that two variables are not equal (canonicalizing). * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are not equal (ignoring case). @@ -820,31 +1118,39 @@ Asserts that two variables are not equal (ignoring case). * `param mixed` $actual * `param float` $delta * `param string` $message +* `return void` Asserts that two variables are not equal (with delta). #### assertNotFalse +* `phpstan-assert` !false $condition * `param mixed` $condition * `param string` $message +* `return void` Asserts that a condition is not false. #### assertNotInstanceOf -* `param string` $expected +* `template` ExpectedType of object +* `phpstan-assert` !ExpectedType $actual +* `param class-string` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of a given type. #### assertNotNull +* `phpstan-assert` !null $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not null. @@ -854,6 +1160,7 @@ Asserts that a variable is not null. * `param string` $pattern * `param string` $string * `param string` $message +* `return void` Asserts that a string does not match a given regular expression. @@ -863,31 +1170,37 @@ Asserts that a string does not match a given regular expression. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables do not have the same type and value. #### assertNotSameSize -* `param \Countable|iterable` $expected -* `param \Countable|iterable` $actual +* `param \Countable|iterable` $expected +* `param \Countable|iterable` $actual * `param string` $message +* `return void` Assert that the size of two arrays (or `Countable` or `Traversable` objects) is not the same. #### assertNotTrue +* `phpstan-assert` !true $condition * `param mixed` $condition * `param string` $message +* `return void` Asserts that a condition is not true. #### assertNull +* `phpstan-assert` null $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is null. @@ -897,6 +1210,7 @@ Asserts that a variable is null. * `param string` $attributeName * `param object` $object * `param string` $message +* `return void` Asserts that an object has a specified attribute. @@ -906,6 +1220,7 @@ Asserts that an object has a specified attribute. * `param string` $attributeName * `param object` $object * `param string` $message +* `return void` Asserts that an object does not have a specified attribute. @@ -915,24 +1230,32 @@ Asserts that an object does not have a specified attribute. * `param string` $pattern * `param string` $string * `param string` $message +* `return void` Asserts that a string matches a given regular expression. #### assertSame -* `param mixed` $expected +* `template` ExpectedType +* `phpstan-assert` =ExpectedType $actual +* `param ExpectedType` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables have the same type and value. +Used on objects, it asserts that two variables reference +the same object. + #### assertSameSize -* `param \Countable|iterable` $expected -* `param \Countable|iterable` $actual +* `param \Countable|iterable` $expected +* `param \Countable|iterable` $actual * `param string` $message +* `return void` Assert that the size of two arrays (or `Countable` or `Traversable` objects) is the same. @@ -942,6 +1265,7 @@ Assert that the size of two arrays (or `Countable` or `Traversable` objects) is * `param string` $needle * `param string` $haystack * `param string` $message +* `return void` #### assertStringContainsStringIgnoringCase @@ -949,22 +1273,25 @@ Assert that the size of two arrays (or `Countable` or `Traversable` objects) is * `param string` $needle * `param string` $haystack * `param string` $message +* `return void` #### assertStringEndsNotWith -* `param string` $suffix +* `param non-empty-string` $suffix * `param string` $string * `param string` $message +* `return void` Asserts that a string ends not with a given suffix. #### assertStringEndsWith -* `param string` $suffix +* `param non-empty-string` $suffix * `param string` $string * `param string` $message +* `return void` Asserts that a string ends with a given suffix. @@ -974,6 +1301,7 @@ Asserts that a string ends with a given suffix. * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is equal to the contents of a file. @@ -983,6 +1311,7 @@ Asserts that the contents of a string is equal to the contents of a file. * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is equal to the contents of a file (canonicalizing). @@ -992,6 +1321,7 @@ Asserts that the contents of a string is equal to the contents of a file (canoni * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is equal to the contents of a file (ignoring case). @@ -1001,6 +1331,7 @@ Asserts that the contents of a string is equal to the contents of a file (ignori * `param string` $format * `param string` $string * `param string` $message +* `return void` Asserts that a string matches a given format string. @@ -1010,6 +1341,7 @@ Asserts that a string matches a given format string. * `param string` $formatFile * `param string` $string * `param string` $message +* `return void` Asserts that a string matches a given format file. @@ -1019,6 +1351,7 @@ Asserts that a string matches a given format file. * `param string` $needle * `param string` $haystack * `param string` $message +* `return void` #### assertStringNotContainsStringIgnoringCase @@ -1026,6 +1359,7 @@ Asserts that a string matches a given format file. * `param string` $needle * `param string` $haystack * `param string` $message +* `return void` #### assertStringNotEqualsFile @@ -1033,6 +1367,7 @@ Asserts that a string matches a given format file. * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is not equal to the contents of a file. @@ -1042,6 +1377,7 @@ Asserts that the contents of a string is not equal to the contents of a file. * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is not equal to the contents of a file (canonicalizing). @@ -1051,6 +1387,7 @@ Asserts that the contents of a string is not equal to the contents of a file (ca * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is not equal to the contents of a file (ignoring case). @@ -1060,6 +1397,7 @@ Asserts that the contents of a string is not equal to the contents of a file (ig * `param string` $format * `param string` $string * `param string` $message +* `return void` Asserts that a string does not match a given format string. @@ -1069,24 +1407,27 @@ Asserts that a string does not match a given format string. * `param string` $formatFile * `param string` $string * `param string` $message +* `return void` Asserts that a string does not match a given format string. #### assertStringStartsNotWith -* `param string` $prefix +* `param non-empty-string` $prefix * `param string` $string * `param string` $message +* `return void` Asserts that a string starts not with a given prefix. #### assertStringStartsWith -* `param string` $prefix +* `param non-empty-string` $prefix * `param string` $string * `param string` $message +* `return void` Asserts that a string starts with a given prefix. @@ -1096,6 +1437,7 @@ Asserts that a string starts with a given prefix. * `param mixed` $value * `param \PHPUnit\Framework\Constraint\Constraint` $constraint * `param string` $message +* `return void` Evaluates a PHPUnit\Framework\Constraint matcher object. @@ -1105,14 +1447,17 @@ Evaluates a PHPUnit\Framework\Constraint matcher object. * `param mixed` $value * `param \PHPUnit\Framework\Constraint\Constraint` $constraint * `param string` $message +* `return void` Evaluates a PHPUnit\Framework\Constraint matcher object. #### assertTrue +* `phpstan-assert` true $condition * `param mixed` $condition * `param string` $message +* `return void` Asserts that a condition is true. @@ -1122,6 +1467,7 @@ Asserts that a condition is true. * `param string` $expectedFile * `param string` $actualFile * `param string` $message +* `return void` Asserts that two XML files are equal. @@ -1131,6 +1477,7 @@ Asserts that two XML files are equal. * `param string` $expectedFile * `param string` $actualFile * `param string` $message +* `return void` Asserts that two XML files are not equal. @@ -1140,6 +1487,7 @@ Asserts that two XML files are not equal. * `param string` $expectedFile * `param \DOMDocument|string` $actualXml * `param string` $message +* `return void` Asserts that two XML documents are equal. @@ -1149,6 +1497,7 @@ Asserts that two XML documents are equal. * `param \DOMDocument|string` $expectedXml * `param \DOMDocument|string` $actualXml * `param string` $message +* `return void` Asserts that two XML documents are equal. @@ -1158,6 +1507,7 @@ Asserts that two XML documents are equal. * `param string` $expectedFile * `param \DOMDocument|string` $actualXml * `param string` $message +* `return void` Asserts that two XML documents are not equal. @@ -1167,6 +1517,7 @@ Asserts that two XML documents are not equal. * `param \DOMDocument|string` $expectedXml * `param \DOMDocument|string` $actualXml * `param string` $message +* `return void` Asserts that two XML documents are not equal. @@ -1193,6 +1544,7 @@ $I->expectThrowable(new MyException(), function() { }); {% endhighlight %} + If you want to check message or throwable code, you can pass them with throwable instance: {% highlight php %} @@ -1208,6 +1560,7 @@ $I->expectThrowable(new MyError("Don't do bad things"), function() { #### fail * `param string` $message +* `return never` Fails a test with the given message. @@ -1215,6 +1568,7 @@ Fails a test with the given message. #### markTestIncomplete * `param string` $message +* `return never` Mark the test as incomplete. @@ -1222,6 +1576,7 @@ Mark the test as incomplete. #### markTestSkipped * `param string` $message +* `return never` Mark the test as skipped. diff --git a/docs/modules/Cli.md b/docs/modules/Cli.md index 2f37ee9e2..e49d1e348 100644 --- a/docs/modules/Cli.md +++ b/docs/modules/Cli.md @@ -10,24 +10,11 @@ title: Cli - Codeception - Documentation # Cli ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-cli {% endhighlight %} -Alternatively, you can enable `Cli` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description diff --git a/docs/modules/DataFactory.md b/docs/modules/DataFactory.md index 7634b8683..b2ddf51b2 100644 --- a/docs/modules/DataFactory.md +++ b/docs/modules/DataFactory.md @@ -10,24 +10,11 @@ title: DataFactory - Codeception - Documentation # DataFactory ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-datafactory {% endhighlight %} -Alternatively, you can enable `DataFactory` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description diff --git a/docs/modules/Db.md b/docs/modules/Db.md index 8b1fa7c0d..b017c643e 100644 --- a/docs/modules/Db.md +++ b/docs/modules/Db.md @@ -10,24 +10,11 @@ title: Db - Codeception - Documentation # Db ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-db {% endhighlight %} -Alternatively, you can enable `Db` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -38,7 +25,7 @@ The most important function of this module is to clean a database before each te This module also provides actions to perform checks in a database, e.g. [seeInDatabase()](https://codeception.com/docs/modules/Db#seeInDatabase) In order to have your database populated with data you need a raw SQL dump. -Simply put the dump in the `tests/_data` directory (by default) and specify the path in the config. +Simply put the dump in the `tests/Support/Data` directory (by default) and specify the path in the config. The next time after the database is cleared, all your data will be restored from the dump. Don't forget to include `CREATE TABLE` statements in the dump. @@ -53,85 +40,80 @@ Also available: * MS SQL * Oracle -Connection is done by database Drivers, which are stored in the `Codeception\Lib\Driver` namespace. -[Check out the drivers](https://github.com/Codeception/Codeception/tree/2.4/src/Codeception/Lib/Driver) -if you run into problems loading dumps and cleaning databases. - -### Config - -* dsn *required* - PDO DSN -* user *required* - username to access database -* password *required* - password -* dump - path to database dump -* populate: false - whether the the dump should be loaded before the test suite is started -* cleanup: false - whether the dump should be reloaded before each test -* reconnect: false - whether the module should reconnect to the database before each test -* waitlock: 0 - wait lock (in seconds) that the database session should use for DDL statements -* ssl_key - path to the SSL key (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-key) -* ssl_cert - path to the SSL certificate (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-cert) -* ssl_ca - path to the SSL certificate authority (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-ca) -* ssl_verify_server_cert - disables certificate CN verification (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php) -* ssl_cipher - list of one or more permissible ciphers to use for SSL encryption (MySQL specific, @see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-cipher) -* databases - include more database configs and switch between them in tests. -* initial_queries - list of queries to be executed right after connection to the database has been initiated, i.e. creating the database if it does not exist or preparing the database collation -* skip_cleanup_if_failed - Do not perform the cleanup if the tests failed. If this is used, manual cleanup might be required when re-running -### Example - - modules: - enabled: - - Db: - dsn: 'mysql:host=localhost;dbname=testdb' - user: 'root' - password: '' - dump: 'tests/_data/dump.sql' - populate: true - cleanup: true - reconnect: true - waitlock: 10 - skip_cleanup_if_failed: true - ssl_key: '/path/to/client-key.pem' - ssl_cert: '/path/to/client-cert.pem' - ssl_ca: '/path/to/ca-cert.pem' - ssl_verify_server_cert: false - ssl_cipher: 'AES256-SHA' - initial_queries: - - 'CREATE DATABASE IF NOT EXISTS temp_db;' - - 'USE temp_db;' - - 'SET NAMES utf8;' +Connection is done by database drivers, which are stored in the `Codeception\Lib\Driver` namespace. +Check out the drivers if you run into problems loading dumps and cleaning databases. + +### Example `Functional.suite.yml` +{% highlight yaml %} + +modules: + enabled: + - Db: + dsn: 'mysql:host=localhost;dbname=testdb' + user: 'root' + password: '' + dump: 'tests/Support/Data/dump.sql' + populate: true # whether the dump should be loaded before the test suite is started + cleanup: true # whether the dump should be reloaded before each test + reconnect: true # whether the module should reconnect to the database before each test + waitlock: 10 # wait lock (in seconds) that the database session should use for DDL statements + databases: # include more database configs and switch between them in tests. + skip_cleanup_if_failed: true # Do not perform the cleanup if the tests failed. If this is used, manual cleanup might be required when re-running + ssl_key: '/path/to/client-key.pem' # path to the SSL key (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-key) + ssl_cert: '/path/to/client-cert.pem' # path to the SSL certificate (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-cert) + ssl_ca: '/path/to/ca-cert.pem' # path to the SSL certificate authority (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-ca) + ssl_verify_server_cert: false # disables certificate CN verification (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php) + ssl_cipher: 'AES256-SHA' # list of one or more permissible ciphers to use for SSL encryption (MySQL specific, see https://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-cipher) + initial_queries: # list of queries to be executed right after connection to the database has been initiated, i.e. creating the database if it does not exist or preparing the database collation + - 'CREATE DATABASE IF NOT EXISTS temp_db;' + - 'USE temp_db;' + - 'SET NAMES utf8;' + +{% endhighlight %} ### Example with multi-dumps - modules: - enabled: - - Db: - dsn: 'mysql:host=localhost;dbname=testdb' - user: 'root' - password: '' - dump: - - 'tests/_data/dump.sql' - - 'tests/_data/dump-2.sql' +{% highlight yaml %} + +modules: + enabled: + - Db: + dsn: 'mysql:host=localhost;dbname=testdb' + user: 'root' + password: '' + dump: + - 'tests/Support/Data/dump.sql' + - 'tests/Support/Data/dump-2.sql' + +{% endhighlight %} ### Example with multi-databases +{% highlight yaml %} - modules: - enabled: - - Db: - dsn: 'mysql:host=localhost;dbname=testdb' - user: 'root' - password: '' - databases: +modules: + enabled: + - Db: + dsn: 'mysql:host=localhost;dbname=testdb' + user: 'root' + password: '' + databases: db2: - dsn: 'mysql:host=localhost;dbname=testdb2' - user: 'userdb2' - password: '' + dsn: 'mysql:host=localhost;dbname=testdb2' + user: 'userdb2' + password: '' -### Example with Sqlite +{% endhighlight %} - modules: - enabled: - - Db: - dsn: 'sqlite:relative/path/to/sqlite-database.db' - user: '' - password: '' +### Example with SQLite +{% highlight yaml %} + +modules: + enabled: + - Db: + dsn: 'sqlite:relative/path/to/sqlite-database.db' + user: '' + password: '' + +{% endhighlight %} ### SQL data dump @@ -147,31 +129,32 @@ For MySQL: {% highlight yaml %} modules: - enabled: - - Db: - dsn: 'mysql:host=localhost;dbname=testdb' - user: 'root' - password: '' - dump: 'tests/_data/dump.sql' - populate: true # run populator before all tests - cleanup: true # run populator before each test - populator: 'mysql -u $user -h $host $dbname < $dump' + enabled: + - Db: + dsn: 'mysql:host=localhost;dbname=testdb' + user: 'root' + password: '' + dump: 'tests/Support/Data/dump.sql' + populate: true # run populator before all tests + cleanup: true # run populator before each test + populator: 'mysql -u $user -h $host $dbname < $dump' {% endhighlight %} -For PostgreSQL (using pg_restore) +For PostgreSQL (using `pg_restore`) {% highlight yaml %} + modules: - enabled: - - Db: - dsn: 'pgsql:host=localhost;dbname=testdb' - user: 'root' - password: '' - dump: 'tests/_data/db_backup.dump' - populate: true # run populator before all tests - cleanup: true # run populator before each test - populator: 'pg_restore -u $user -h $host -D $dbname < $dump' + enabled: + - Db: + dsn: 'pgsql:host=localhost;dbname=testdb' + user: 'root' + password: '' + dump: 'tests/Support/Data/db_backup.dump' + populate: true # run populator before all tests + cleanup: true # run populator before each test + populator: 'pg_restore -u $user -h $host -D $dbname < $dump' {% endhighlight %} @@ -347,7 +330,7 @@ Provide table name, desired column and criteria. {% highlight php %} grabColumnFromDatabase('users', 'email', array('name' => 'RebOOter')); +$mails = $I->grabColumnFromDatabase('users', 'email', ['name' => 'RebOOter']); {% endhighlight %} @@ -366,7 +349,7 @@ Provide table name and criteria. {% highlight php %} grabEntriesFromDatabase('users', array('name' => 'Davert')); +$mail = $I->grabEntriesFromDatabase('users', ['name' => 'Davert']); {% endhighlight %} Comparison expressions can be used as well: @@ -397,7 +380,7 @@ Provide table name, desired column and criteria. {% highlight php %} grabEntryFromDatabase('users', array('name' => 'Davert')); +$mail = $I->grabEntryFromDatabase('users', ['name' => 'Davert']); {% endhighlight %} Comparison expressions can be used as well: @@ -427,7 +410,7 @@ Provide table name, desired column and criteria. {% highlight php %} grabFromDatabase('users', 'email', array('name' => 'Davert')); +$mail = $I->grabFromDatabase('users', 'email', ['name' => 'Davert']); {% endhighlight %} Comparison expressions can be used as well: @@ -464,7 +447,7 @@ unless you've configured "skip_cleanup_if_failed", and the test fails. {% highlight php %} haveInDatabase('users', array('name' => 'miles', 'email' => 'miles@davis.com')); +$I->haveInDatabase('users', ['name' => 'miles', 'email' => 'miles@davis.com']); {% endhighlight %} @@ -572,7 +555,7 @@ Update an SQL record into a database. {% highlight php %} updateInDatabase('users', array('isAdmin' => true), array('email' => 'miles@davis.com')); +$I->updateInDatabase('users', ['isAdmin' => true], ['email' => 'miles@davis.com']); {% endhighlight %} diff --git a/docs/modules/Doctrine2.md b/docs/modules/Doctrine.md similarity index 89% rename from docs/modules/Doctrine2.md rename to docs/modules/Doctrine.md index 393f4ee3f..9c2a46e1a 100644 --- a/docs/modules/Doctrine2.md +++ b/docs/modules/Doctrine.md @@ -1,48 +1,40 @@ --- layout: doc -title: Doctrine2 - Codeception - Documentation +title: Doctrine - Codeception - Documentation --- - + -# Doctrine2 +# Doctrine ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} -composer require --dev codeception/module-doctrine2 +composer require --dev codeception/module-doctrine {% endhighlight %} -Alternatively, you can enable `Doctrine2` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description +Upgrading from Module "Doctrine2": +* In your `composer.json`: Replace `"codeception/module-doctrine2"` with `"codeception/module-doctrine"` +* In your `Acceptance.suite.yml`, `Functional.suite.yml`, and `Unit.suite.yml`: Replace `- Doctrine2:` with `- Doctrine:` +* In any file in `Support/Helper/`: Change `$this->getModule('Doctrine2')` to `$this->getModule('Doctrine')` + Access the database using [Doctrine ORM](https://docs.doctrine-project.org/projects/doctrine-orm/en/latest/). When used with Symfony or Zend Framework 2, Doctrine's Entity Manager is automatically retrieved from Service Locator. -Set up your `functional.suite.yml` like this: +Set up your `Functional.suite.yml` like this: {% highlight yaml %} modules: enabled: - Symfony # 'ZF2' or 'Symfony' - - Doctrine2: + - Doctrine: depends: Symfony # Tells Doctrine to fetch the Entity Manager through Symfony cleanup: true # All doctrine queries will be wrapped in a transaction, which will be rolled back at the end of each test @@ -54,7 +46,7 @@ If you don't provide a `depends` key, you need to specify a callback function to modules: enabled: - - Doctrine2: + - Doctrine: connection_callback: ['MyDb', 'createEntityManager'] # Call the static method `MyDb::createEntityManager()` to get the Entity Manager {% endhighlight %} @@ -63,7 +55,7 @@ By default, the module will wrap everything into a transaction for each test and (this is controlled by the `cleanup` setting). By doing this, tests will run much faster and will be isolated from each other. -To use the Doctrine2 Module in acceptance tests, set up your `acceptance.suite.yml` like this: +To use the Doctrine Module in acceptance tests, set up your `acceptance.suite.yml` like this: {% highlight yaml %} @@ -71,7 +63,7 @@ modules: enabled: - Symfony: part: SERVICES - - Doctrine2: + - Doctrine: depends: Symfony {% endhighlight %} @@ -85,7 +77,7 @@ are using to purge the database tables: modules: enabled: - - Doctrine2: + - Doctrine: purge_mode: 1 # 1: DELETE (=default), 2: TRUNCATE {% endhighlight %} @@ -367,7 +359,7 @@ Note that `$em->persist()`, `$em->refresh()`, and `$em->flush()` are called ever * `throws ModuleRequireException` * `return void` -Loads fixtures. Fixture can be specified as a fully qualified class name, +Loads fixtures. The fixture class can be specified as a fully qualified class name, an instance, or an array of class names/instances. {% highlight php %} @@ -440,4 +432,4 @@ $I->seeInRepository(Client::class, ['User' => ['Company' => ['name' => 'Codegyre Fails if record for given criteria can\'t be found, -

     

    Module reference is taken from the source code. Help us to improve documentation. Edit module reference
    +

     

    Module reference is taken from the source code. Help us to improve documentation. Edit module reference
    diff --git a/docs/modules/FTP.md b/docs/modules/FTP.md index e8463b01b..ffc8f25e6 100644 --- a/docs/modules/FTP.md +++ b/docs/modules/FTP.md @@ -10,24 +10,11 @@ title: FTP - Codeception - Documentation # FTP ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-ftp {% endhighlight %} -Alternatively, you can enable `FTP` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description diff --git a/docs/modules/Filesystem.md b/docs/modules/Filesystem.md index 72a905126..b769c5afd 100644 --- a/docs/modules/Filesystem.md +++ b/docs/modules/Filesystem.md @@ -10,24 +10,11 @@ title: Filesystem - Codeception - Documentation # Filesystem ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-filesystem {% endhighlight %} -Alternatively, you can enable `Filesystem` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description diff --git a/docs/modules/Laminas.md b/docs/modules/Laminas.md index db7a29a0e..2dbbfcb12 100644 --- a/docs/modules/Laminas.md +++ b/docs/modules/Laminas.md @@ -10,24 +10,11 @@ title: Laminas - Codeception - Documentation # Laminas ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-laminas {% endhighlight %} -Alternatively, you can enable `Laminas` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -341,24 +328,10 @@ $I->click(['link' => 'Login']); #### deleteHeader -* `param string` $name the name of the header to delete. +@deprecated +* `param string` $name * `return void` -Deletes the header with the passed name. Subsequent requests -will not have the deleted header in its request. - -Example: -{% highlight php %} - -haveHttpHeader('X-Requested-With', 'Codeception'); -$I->amOnPage('test-headers.php'); -// ... -$I->deleteHeader('X-Requested-With'); -$I->amOnPage('some-other-page.php'); - -{% endhighlight %} - #### dontSee @@ -427,7 +400,7 @@ You can set additional cookie params like `domain`, `path` as array passed in la * `param string` $uri * `return void` -Checks that the current URL doesn't equal the given string. +Checks that the current URL (path) doesn't equal the given string. Unlike `dontSeeInCurrentUrl`, this only matches the full URL. @@ -445,13 +418,13 @@ $I->dontSeeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that current url doesn't match the given regular expression. +Checks that current URL (path) doesn't match the given regular expression. {% highlight php %} dontSeeCurrentUrlMatches('~^/users/(\d+)~'); +$I->dontSeeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -482,7 +455,7 @@ $I->dontSeeElement('input', ['value' => '123456']); * `param string` $uri * `return void` -Checks that the current URI doesn't contain the given string. +Checks that the current URI (path) doesn't contain the given string. {% highlight php %} @@ -676,9 +649,9 @@ $I->followRedirect(); * `param string` $attribute * `return mixed` -Grabs the value of the given attribute value from the given element. +Returns the value of the given attribute value from the given HTML element. For some attributes, the string `true` is returned instead of their literal value (e.g. `disabled="disabled"` or `required="required"`). -Fails if element is not found. +Fails if the element is not found. Returns `null` if the attribute is not present on the element. {% highlight php %} @@ -749,7 +722,7 @@ $aLinks = $I->grabMultiple('a', 'href'); #### grabPageSource -* `throws ModuleException` if no page was opened. +* `throws \Codeception\Exception\ModuleException` if no page was opened. * `return string` Current page source code. Grabs current page source code. @@ -989,14 +962,12 @@ $I->seeCurrentRouteIs('posts.show', ['id' => 8])); * `param string` $uri * `return void` -Checks that the current URL is equal to the given string. - -Unlike `seeInCurrentUrl`, this only matches the full URL. +Checks that the current URL (path) is equal to the given string. {% highlight php %} seeCurrentUrlEquals('/'); {% endhighlight %} @@ -1007,13 +978,12 @@ $I->seeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that the current URL matches the given regular expression. +Checks that the current URL (path) matches the given regular expression. {% highlight php %} seeCurrentUrlMatches('~^/users/(\d+)~'); +$I->seeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -1145,9 +1115,9 @@ $form = [ 'checkbox1' => true, // ... ]; -$I->submitForm('//form[@id=my-form]', string $form, 'submitButton'); +$I->submitForm('//form[@id=my-form]', $form, 'submitButton'); // $I->amOnPage('/path/to/form-page') may be needed -$I->seeInFormFields('//form[@id=my-form]', string $form); +$I->seeInFormFields('//form[@id=my-form]', $form); {% endhighlight %} @@ -1319,7 +1289,7 @@ Provide an array for the second argument to select multiple options: {% highlight php %} selectOption('Which OS do you use?', array('Windows','Linux')); +$I->selectOption('Which OS do you use?', ['Windows', 'Linux']); {% endhighlight %} @@ -1328,8 +1298,8 @@ Or provide an associative array for the second argument to specifically define w {% highlight php %} selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' -$I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' +$I->selectOption('Which OS do you use?', ['text' => 'Windows']); // Only search by text 'Windows' +$I->selectOption('Which OS do you use?', ['value' => 'windows']); // Only search by value 'windows' {% endhighlight %} @@ -1705,4 +1675,25 @@ $I->uncheckOption('#notify'); {% endhighlight %} + +#### unsetHttpHeader + +* `param string` $name the name of the header to unset. +* `return void` + +Unsets a HTTP header (that was originally added by [haveHttpHeader()](#haveHttpHeader)), +so that subsequent requests will not send it anymore. + +Example: +{% highlight php %} + +haveHttpHeader('X-Requested-With', 'Codeception'); +$I->amOnPage('test-headers.php'); +// ... +$I->unsetHeader('X-Requested-With'); +$I->amOnPage('some-other-page.php'); + +{% endhighlight %} +

     

    Module reference is taken from the source code. Help us to improve documentation. Edit module reference
    diff --git a/docs/modules/Laravel.md b/docs/modules/Laravel.md index e09bf89e2..91f91e54e 100644 --- a/docs/modules/Laravel.md +++ b/docs/modules/Laravel.md @@ -10,24 +10,11 @@ title: Laravel - Codeception - Documentation # Laravel ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-laravel {% endhighlight %} -Alternatively, you can enable `Laravel` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -526,24 +513,10 @@ $I->click(['link' => 'Login']); #### deleteHeader -* `param string` $name the name of the header to delete. +@deprecated +* `param string` $name * `return void` -Deletes the header with the passed name. Subsequent requests -will not have the deleted header in its request. - -Example: -{% highlight php %} - -haveHttpHeader('X-Requested-With', 'Codeception'); -$I->amOnPage('test-headers.php'); -// ... -$I->deleteHeader('X-Requested-With'); -$I->amOnPage('some-other-page.php'); - -{% endhighlight %} - #### disableEvents @@ -687,7 +660,7 @@ You can set additional cookie params like `domain`, `path` as array passed in la * `param string` $uri * `return void` -Checks that the current URL doesn't equal the given string. +Checks that the current URL (path) doesn't equal the given string. Unlike `dontSeeInCurrentUrl`, this only matches the full URL. @@ -705,13 +678,13 @@ $I->dontSeeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that current url doesn't match the given regular expression. +Checks that current URL (path) doesn't match the given regular expression. {% highlight php %} dontSeeCurrentUrlMatches('~^/users/(\d+)~'); +$I->dontSeeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -773,7 +746,7 @@ $I->dontSeeFormErrors(); * `param string` $uri * `return void` -Checks that the current URI doesn't contain the given string. +Checks that the current URI (path) doesn't contain the given string. {% highlight php %} @@ -1078,9 +1051,9 @@ $app = $I->getApplication(); * `param string` $attribute * `return mixed` -Grabs the value of the given attribute value from the given element. +Returns the value of the given attribute value from the given HTML element. For some attributes, the string `true` is returned instead of their literal value (e.g. `disabled="disabled"` or `required="required"`). -Fails if element is not found. +Fails if the element is not found. Returns `null` if the attribute is not present on the element. {% highlight php %} @@ -1170,7 +1143,7 @@ $I->grabNumRecords('App\Models\User', ['name' => 'Davert']); #### grabPageSource -* `throws ModuleException` if no page was opened. +* `throws \Codeception\Exception\ModuleException` if no page was opened. * `return string` Current page source code. Grabs current page source code. @@ -1706,14 +1679,12 @@ $I->seeCurrentRouteIs('posts.index'); * `param string` $uri * `return void` -Checks that the current URL is equal to the given string. - -Unlike `seeInCurrentUrl`, this only matches the full URL. +Checks that the current URL (path) is equal to the given string. {% highlight php %} seeCurrentUrlEquals('/'); {% endhighlight %} @@ -1724,13 +1695,12 @@ $I->seeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that the current URL matches the given regular expression. +Checks that the current URL (path) matches the given regular expression. {% highlight php %} seeCurrentUrlMatches('~^/users/(\d+)~'); +$I->seeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -1953,9 +1923,9 @@ $form = [ 'checkbox1' => true, // ... ]; -$I->submitForm('//form[@id=my-form]', string $form, 'submitButton'); +$I->submitForm('//form[@id=my-form]', $form, 'submitButton'); // $I->amOnPage('/path/to/form-page') may be needed -$I->seeInFormFields('//form[@id=my-form]', string $form); +$I->seeInFormFields('//form[@id=my-form]', $form); {% endhighlight %} @@ -2210,7 +2180,7 @@ Provide an array for the second argument to select multiple options: {% highlight php %} selectOption('Which OS do you use?', array('Windows','Linux')); +$I->selectOption('Which OS do you use?', ['Windows', 'Linux']); {% endhighlight %} @@ -2219,8 +2189,8 @@ Or provide an associative array for the second argument to specifically define w {% highlight php %} selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' -$I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' +$I->selectOption('Which OS do you use?', ['text' => 'Windows']); // Only search by text 'Windows' +$I->selectOption('Which OS do you use?', ['value' => 'windows']); // Only search by value 'windows' {% endhighlight %} @@ -2602,4 +2572,25 @@ $I->uncheckOption('#notify'); {% endhighlight %} + +#### unsetHttpHeader + +* `param string` $name the name of the header to unset. +* `return void` + +Unsets a HTTP header (that was originally added by [haveHttpHeader()](#haveHttpHeader)), +so that subsequent requests will not send it anymore. + +Example: +{% highlight php %} + +haveHttpHeader('X-Requested-With', 'Codeception'); +$I->amOnPage('test-headers.php'); +// ... +$I->unsetHeader('X-Requested-With'); +$I->amOnPage('some-other-page.php'); + +{% endhighlight %} +

     

    Module reference is taken from the source code. Help us to improve documentation. Edit module reference
    diff --git a/docs/modules/Lumen.md b/docs/modules/Lumen.md index 3ac68bbcc..89315a443 100644 --- a/docs/modules/Lumen.md +++ b/docs/modules/Lumen.md @@ -10,24 +10,11 @@ title: Lumen - Codeception - Documentation # Lumen ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-lumen {% endhighlight %} -Alternatively, you can enable `Lumen` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -343,24 +330,10 @@ $I->click(['link' => 'Login']); #### deleteHeader -* `param string` $name the name of the header to delete. +@deprecated +* `param string` $name * `return void` -Deletes the header with the passed name. Subsequent requests -will not have the deleted header in its request. - -Example: -{% highlight php %} - -haveHttpHeader('X-Requested-With', 'Codeception'); -$I->amOnPage('test-headers.php'); -// ... -$I->deleteHeader('X-Requested-With'); -$I->amOnPage('some-other-page.php'); - -{% endhighlight %} - #### dontSee @@ -436,7 +409,7 @@ You can set additional cookie params like `domain`, `path` as array passed in la * `param string` $uri * `return void` -Checks that the current URL doesn't equal the given string. +Checks that the current URL (path) doesn't equal the given string. Unlike `dontSeeInCurrentUrl`, this only matches the full URL. @@ -454,13 +427,13 @@ $I->dontSeeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that current url doesn't match the given regular expression. +Checks that current URL (path) doesn't match the given regular expression. {% highlight php %} dontSeeCurrentUrlMatches('~^/users/(\d+)~'); +$I->dontSeeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -491,7 +464,7 @@ $I->dontSeeElement('input', ['value' => '123456']); * `param string` $uri * `return void` -Checks that the current URI doesn't contain the given string. +Checks that the current URI (path) doesn't contain the given string. {% highlight php %} @@ -712,9 +685,9 @@ Provides access the Lumen application object. * `param string` $attribute * `return mixed` -Grabs the value of the given attribute value from the given element. +Returns the value of the given attribute value from the given HTML element. For some attributes, the string `true` is returned instead of their literal value (e.g. `disabled="disabled"` or `required="required"`). -Fails if element is not found. +Fails if the element is not found. Returns `null` if the attribute is not present on the element. {% highlight php %} @@ -785,7 +758,7 @@ $aLinks = $I->grabMultiple('a', 'href'); #### grabPageSource -* `throws ModuleException` if no page was opened. +* `throws \Codeception\Exception\ModuleException` if no page was opened. * `return string` Current page source code. Grabs current page source code. @@ -1248,14 +1221,12 @@ $I->seeCookie('PHPSESSID'); * `param string` $uri * `return void` -Checks that the current URL is equal to the given string. - -Unlike `seeInCurrentUrl`, this only matches the full URL. +Checks that the current URL (path) is equal to the given string. {% highlight php %} seeCurrentUrlEquals('/'); {% endhighlight %} @@ -1266,13 +1237,12 @@ $I->seeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that the current URL matches the given regular expression. +Checks that the current URL (path) matches the given regular expression. {% highlight php %} seeCurrentUrlMatches('~^/users/(\d+)~'); +$I->seeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -1404,9 +1374,9 @@ $form = [ 'checkbox1' => true, // ... ]; -$I->submitForm('//form[@id=my-form]', string $form, 'submitButton'); +$I->submitForm('//form[@id=my-form]', $form, 'submitButton'); // $I->amOnPage('/path/to/form-page') may be needed -$I->seeInFormFields('//form[@id=my-form]', string $form); +$I->seeInFormFields('//form[@id=my-form]', $form); {% endhighlight %} @@ -1599,7 +1569,7 @@ Provide an array for the second argument to select multiple options: {% highlight php %} selectOption('Which OS do you use?', array('Windows','Linux')); +$I->selectOption('Which OS do you use?', ['Windows', 'Linux']); {% endhighlight %} @@ -1608,8 +1578,8 @@ Or provide an associative array for the second argument to specifically define w {% highlight php %} selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' -$I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' +$I->selectOption('Which OS do you use?', ['text' => 'Windows']); // Only search by text 'Windows' +$I->selectOption('Which OS do you use?', ['value' => 'windows']); // Only search by value 'windows' {% endhighlight %} @@ -1991,4 +1961,25 @@ $I->uncheckOption('#notify'); {% endhighlight %} + +#### unsetHttpHeader + +* `param string` $name the name of the header to unset. +* `return void` + +Unsets a HTTP header (that was originally added by [haveHttpHeader()](#haveHttpHeader)), +so that subsequent requests will not send it anymore. + +Example: +{% highlight php %} + +haveHttpHeader('X-Requested-With', 'Codeception'); +$I->amOnPage('test-headers.php'); +// ... +$I->unsetHeader('X-Requested-With'); +$I->amOnPage('some-other-page.php'); + +{% endhighlight %} +

     

    Module reference is taken from the source code. Help us to improve documentation. Edit module reference
    diff --git a/docs/modules/Memcache.md b/docs/modules/Memcache.md index 4a474c5c7..a0fc65cd2 100644 --- a/docs/modules/Memcache.md +++ b/docs/modules/Memcache.md @@ -10,24 +10,11 @@ title: Memcache - Codeception - Documentation # Memcache ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-memcache {% endhighlight %} -Alternatively, you can enable `Memcache` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description diff --git a/docs/modules/Mezzio.md b/docs/modules/Mezzio.md index 08b6ea914..9bb626c5d 100644 --- a/docs/modules/Mezzio.md +++ b/docs/modules/Mezzio.md @@ -10,24 +10,11 @@ title: Mezzio - Codeception - Documentation # Mezzio ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-mezzio {% endhighlight %} -Alternatively, you can enable `Mezzio` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -287,24 +274,10 @@ $I->click(['link' => 'Login']); #### deleteHeader -* `param string` $name the name of the header to delete. +@deprecated +* `param string` $name * `return void` -Deletes the header with the passed name. Subsequent requests -will not have the deleted header in its request. - -Example: -{% highlight php %} - -haveHttpHeader('X-Requested-With', 'Codeception'); -$I->amOnPage('test-headers.php'); -// ... -$I->deleteHeader('X-Requested-With'); -$I->amOnPage('some-other-page.php'); - -{% endhighlight %} - #### dontSee @@ -373,7 +346,7 @@ You can set additional cookie params like `domain`, `path` as array passed in la * `param string` $uri * `return void` -Checks that the current URL doesn't equal the given string. +Checks that the current URL (path) doesn't equal the given string. Unlike `dontSeeInCurrentUrl`, this only matches the full URL. @@ -391,13 +364,13 @@ $I->dontSeeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that current url doesn't match the given regular expression. +Checks that current URL (path) doesn't match the given regular expression. {% highlight php %} dontSeeCurrentUrlMatches('~^/users/(\d+)~'); +$I->dontSeeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -428,7 +401,7 @@ $I->dontSeeElement('input', ['value' => '123456']); * `param string` $uri * `return void` -Checks that the current URI doesn't contain the given string. +Checks that the current URI (path) doesn't contain the given string. {% highlight php %} @@ -622,9 +595,9 @@ $I->followRedirect(); * `param string` $attribute * `return mixed` -Grabs the value of the given attribute value from the given element. +Returns the value of the given attribute value from the given HTML element. For some attributes, the string `true` is returned instead of their literal value (e.g. `disabled="disabled"` or `required="required"`). -Fails if element is not found. +Fails if the element is not found. Returns `null` if the attribute is not present on the element. {% highlight php %} @@ -695,7 +668,7 @@ $aLinks = $I->grabMultiple('a', 'href'); #### grabPageSource -* `throws ModuleException` if no page was opened. +* `throws \Codeception\Exception\ModuleException` if no page was opened. * `return string` Current page source code. Grabs current page source code. @@ -901,14 +874,12 @@ $I->seeCookie('PHPSESSID'); * `param string` $uri * `return void` -Checks that the current URL is equal to the given string. - -Unlike `seeInCurrentUrl`, this only matches the full URL. +Checks that the current URL (path) is equal to the given string. {% highlight php %} seeCurrentUrlEquals('/'); {% endhighlight %} @@ -919,13 +890,12 @@ $I->seeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that the current URL matches the given regular expression. +Checks that the current URL (path) matches the given regular expression. {% highlight php %} seeCurrentUrlMatches('~^/users/(\d+)~'); +$I->seeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -1057,9 +1027,9 @@ $form = [ 'checkbox1' => true, // ... ]; -$I->submitForm('//form[@id=my-form]', string $form, 'submitButton'); +$I->submitForm('//form[@id=my-form]', $form, 'submitButton'); // $I->amOnPage('/path/to/form-page') may be needed -$I->seeInFormFields('//form[@id=my-form]', string $form); +$I->seeInFormFields('//form[@id=my-form]', $form); {% endhighlight %} @@ -1231,7 +1201,7 @@ Provide an array for the second argument to select multiple options: {% highlight php %} selectOption('Which OS do you use?', array('Windows','Linux')); +$I->selectOption('Which OS do you use?', ['Windows', 'Linux']); {% endhighlight %} @@ -1240,8 +1210,8 @@ Or provide an associative array for the second argument to specifically define w {% highlight php %} selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' -$I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' +$I->selectOption('Which OS do you use?', ['text' => 'Windows']); // Only search by text 'Windows' +$I->selectOption('Which OS do you use?', ['value' => 'windows']); // Only search by value 'windows' {% endhighlight %} @@ -1617,4 +1587,25 @@ $I->uncheckOption('#notify'); {% endhighlight %} + +#### unsetHttpHeader + +* `param string` $name the name of the header to unset. +* `return void` + +Unsets a HTTP header (that was originally added by [haveHttpHeader()](#haveHttpHeader)), +so that subsequent requests will not send it anymore. + +Example: +{% highlight php %} + +haveHttpHeader('X-Requested-With', 'Codeception'); +$I->amOnPage('test-headers.php'); +// ... +$I->unsetHeader('X-Requested-With'); +$I->amOnPage('some-other-page.php'); + +{% endhighlight %} +

     

    Module reference is taken from the source code. Help us to improve documentation. Edit module reference
    diff --git a/docs/modules/MongoDb.md b/docs/modules/MongoDb.md index 58ba50c1c..e982e5dd4 100644 --- a/docs/modules/MongoDb.md +++ b/docs/modules/MongoDb.md @@ -10,24 +10,11 @@ title: MongoDb - Codeception - Documentation # MongoDb ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-mongodb {% endhighlight %} -Alternatively, you can enable `MongoDb` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description diff --git a/docs/modules/PhpBrowser.md b/docs/modules/PhpBrowser.md index d58bf3989..e7733db84 100644 --- a/docs/modules/PhpBrowser.md +++ b/docs/modules/PhpBrowser.md @@ -10,24 +10,11 @@ title: PhpBrowser - Codeception - Documentation # PhpBrowser ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-phpbrowser {% endhighlight %} -Alternatively, you can enable `PhpBrowser` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -39,13 +26,6 @@ Use to perform web acceptance tests with non-javascript browser. If test fails stores last shown page in 'output' dir. -### Status - -* Maintainer: **davert** -* Stability: **stable** -* Contact: codeception@codeception.com - - ### Configuration * url *required* - start url of your app @@ -59,28 +39,31 @@ If test fails stores last shown page in 'output' dir. * .. those and other [Guzzle Request options](https://docs.guzzlephp.org/en/latest/request-options.html) -#### Example (`acceptance.suite.yml`) - - modules: - enabled: - - PhpBrowser: - url: 'http://localhost' - auth: ['admin', '123345'] - curl: - CURLOPT_RETURNTRANSFER: true - cookies: - cookie-1: - Name: userName - Value: john.doe - cookie-2: - Name: authToken - Value: 1abcd2345 - Domain: subdomain.domain.com - Path: /admin/ - Expires: 1292177455 - Secure: true - HttpOnly: false +#### Example (`Acceptance.suite.yml`) +{% highlight yaml %} + +modules: + enabled: + - PhpBrowser: + url: 'http://localhost' # Internationalized domain names (IDN) need to be passed in punycode + auth: ['admin', '123345'] + curl: + CURLOPT_RETURNTRANSFER: true + cookies: + cookie-1: + Name: userName + Value: john.doe + cookie-2: + Name: authToken + Value: 1abcd2345 + Domain: subdomain.domain.com + Path: /admin/ + Expires: 1292177455 + Secure: true + HttpOnly: false + +{% endhighlight %} All SSL certification checks are disabled by default. Use Guzzle request options to configure certifications and others. @@ -233,8 +216,8 @@ $this->getModule('PhpBrowser')->_savePageSource(codecept_output_dir().'page.html #### amHttpAuthenticated -* `param ` $username -* `param ` $password +* `param string` $username +* `param string` $password * `return void` Authenticates user for HTTP_AUTH @@ -260,7 +243,7 @@ $I->amOnPage('/register'); #### amOnSubdomain -* `param ` $subdomain +* `param string` $subdomain * `return void` Changes the subdomain for the 'url' configuration parameter. @@ -283,7 +266,7 @@ $I->amOnPage('/'); #### amOnUrl -* `param ` $url +* `param string` $url * `return void` Open web page at the given absolute URL and sets its hostname as the base host. @@ -367,24 +350,10 @@ $I->click(['link' => 'Login']); #### deleteHeader -* `param string` $name the name of the header to delete. +@deprecated +* `param string` $name * `return void` -Deletes the header with the passed name. Subsequent requests -will not have the deleted header in its request. - -Example: -{% highlight php %} - -haveHttpHeader('X-Requested-With', 'Codeception'); -$I->amOnPage('test-headers.php'); -// ... -$I->deleteHeader('X-Requested-With'); -$I->amOnPage('some-other-page.php'); - -{% endhighlight %} - #### dontSee @@ -453,7 +422,7 @@ You can set additional cookie params like `domain`, `path` as array passed in la * `param string` $uri * `return void` -Checks that the current URL doesn't equal the given string. +Checks that the current URL (path) doesn't equal the given string. Unlike `dontSeeInCurrentUrl`, this only matches the full URL. @@ -471,13 +440,13 @@ $I->dontSeeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that current url doesn't match the given regular expression. +Checks that current URL (path) doesn't match the given regular expression. {% highlight php %} dontSeeCurrentUrlMatches('~^/users/(\d+)~'); +$I->dontSeeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -508,7 +477,7 @@ $I->dontSeeElement('input', ['value' => '123456']); * `param string` $uri * `return void` -Checks that the current URI doesn't contain the given string. +Checks that the current URI (path) doesn't contain the given string. {% highlight php %} @@ -726,9 +695,9 @@ $I->followRedirect(); * `param string` $attribute * `return mixed` -Grabs the value of the given attribute value from the given element. +Returns the value of the given attribute value from the given HTML element. For some attributes, the string `true` is returned instead of their literal value (e.g. `disabled="disabled"` or `required="required"`). -Fails if element is not found. +Fails if the element is not found. Returns `null` if the attribute is not present on the element. {% highlight php %} @@ -799,7 +768,7 @@ $aLinks = $I->grabMultiple('a', 'href'); #### grabPageSource -* `throws ModuleException` if no page was opened. +* `throws \Codeception\Exception\ModuleException` if no page was opened. * `return string` Current page source code. Grabs current page source code. @@ -1005,14 +974,12 @@ $I->seeCookie('PHPSESSID'); * `param string` $uri * `return void` -Checks that the current URL is equal to the given string. - -Unlike `seeInCurrentUrl`, this only matches the full URL. +Checks that the current URL (path) is equal to the given string. {% highlight php %} seeCurrentUrlEquals('/'); {% endhighlight %} @@ -1023,13 +990,12 @@ $I->seeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that the current URL matches the given regular expression. +Checks that the current URL (path) matches the given regular expression. {% highlight php %} seeCurrentUrlMatches('~^/users/(\d+)~'); +$I->seeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -1161,9 +1127,9 @@ $form = [ 'checkbox1' => true, // ... ]; -$I->submitForm('//form[@id=my-form]', string $form, 'submitButton'); +$I->submitForm('//form[@id=my-form]', $form, 'submitButton'); // $I->amOnPage('/path/to/form-page') may be needed -$I->seeInFormFields('//form[@id=my-form]', string $form); +$I->seeInFormFields('//form[@id=my-form]', $form); {% endhighlight %} @@ -1335,7 +1301,7 @@ Provide an array for the second argument to select multiple options: {% highlight php %} selectOption('Which OS do you use?', array('Windows','Linux')); +$I->selectOption('Which OS do you use?', ['Windows', 'Linux']); {% endhighlight %} @@ -1344,8 +1310,8 @@ Or provide an associative array for the second argument to specifically define w {% highlight php %} selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' -$I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' +$I->selectOption('Which OS do you use?', ['text' => 'Windows']); // Only search by text 'Windows' +$I->selectOption('Which OS do you use?', ['value' => 'windows']); // Only search by value 'windows' {% endhighlight %} @@ -1730,4 +1696,25 @@ $I->uncheckOption('#notify'); {% endhighlight %} + +#### unsetHttpHeader + +* `param string` $name the name of the header to unset. +* `return void` + +Unsets a HTTP header (that was originally added by [haveHttpHeader()](#haveHttpHeader)), +so that subsequent requests will not send it anymore. + +Example: +{% highlight php %} + +haveHttpHeader('X-Requested-With', 'Codeception'); +$I->amOnPage('test-headers.php'); +// ... +$I->unsetHeader('X-Requested-With'); +$I->amOnPage('some-other-page.php'); + +{% endhighlight %} +

     

    Module reference is taken from the source code. Help us to improve documentation. Edit module reference
    diff --git a/docs/modules/Queue.md b/docs/modules/Queue.md index 20314e90d..29497c507 100644 --- a/docs/modules/Queue.md +++ b/docs/modules/Queue.md @@ -10,24 +10,11 @@ title: Queue - Codeception - Documentation # Queue ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-queue {% endhighlight %} -Alternatively, you can enable `Queue` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description diff --git a/docs/modules/REST.md b/docs/modules/REST.md index 3a918e7c9..572f8c814 100644 --- a/docs/modules/REST.md +++ b/docs/modules/REST.md @@ -10,24 +10,11 @@ title: REST - Codeception - Documentation # REST ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-rest {% endhighlight %} -Alternatively, you can enable `REST` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -99,7 +86,7 @@ Conflicts with SOAP module #### amAWSAuthenticated * `param array` $additionalAWSConfig -* `throws ConfigurationException` +* `throws \Codeception\Exception\ConfigurationException` * `return void` Allows to send REST request using AWS Authorization @@ -165,7 +152,7 @@ Adds HTTP authentication via username/password. * `part` xml * `param string` $username * `param string` $password -* `throws ModuleException` +* `throws \Codeception\Exception\ModuleException` * `return void` Adds NTLM authentication via username/password. @@ -184,26 +171,10 @@ $I->amNTLMAuthenticated('jon_snow', 'targaryen'); #### deleteHeader -* `part` json -* `part` xml -* `param string` $name the name of the header to delete. +@deprecated +* `param string` $name * `return void` -Deletes a HTTP header (that was originally added by [haveHttpHeader()](#haveHttpHeader)), -so that subsequent requests will not send it anymore. - -Example: -{% highlight php %} - -haveHttpHeader('X-Requested-With', 'Codeception'); -$I->sendGet('test-headers.php'); -// ... -$I->deleteHeader('X-Requested-With'); -$I->sendPost('some-other-page.php'); - -{% endhighlight %} - #### dontSeeBinaryResponseEquals @@ -218,7 +189,7 @@ Checks if the hash of a binary response is not the same as provided. {% highlight php %} dontSeeBinaryResponseEquals("8c90748342f19b195b9c6b4eff742ded"); +$I->dontSeeBinaryResponseEquals('8c90748342f19b195b9c6b4eff742ded'); {% endhighlight %} Opposite to `seeBinaryResponseEquals` @@ -373,7 +344,7 @@ Element is matched by either CSS or XPath * `part` json * `param string` $jsonPath -* `throws Exception` +* `throws \Exception` * `return array` Array of matching items See [#jsonpath](#jsonpath) for general info on JSONPath. @@ -440,7 +411,7 @@ Element is matched by either CSS or XPath * `param string` $value * `return void` -Sets a HTTP header to be used for all subsequent requests. Use [`deleteHeader`](#deleteHeader) to unset it. +Sets a HTTP header to be used for all subsequent requests. Use [`unsetHttpHeader`](#unsetHttpHeader) to unset it. {% highlight php %} @@ -484,7 +455,7 @@ Example: Using sha1 hash key {% highlight php %} seeBinaryResponseEquals("df589122eac0f6a7bd8795436e692e3675cadc3b"); +$I->seeBinaryResponseEquals('df589122eac0f6a7bd8795436e692e3675cadc3b'); {% endhighlight %} @@ -493,7 +464,7 @@ Example: Using sha1 for a file contents {% highlight php %} seeBinaryResponseEquals(md5($fileData)); {% endhighlight %} @@ -503,7 +474,7 @@ Example: Using sha256 hash seeBinaryResponseEquals(hash("sha256", base64_decode($fileData)), 'sha256'); +$I->seeBinaryResponseEquals(hash('sha256', base64_decode($fileData)), 'sha256'); {% endhighlight %} @@ -685,10 +656,10 @@ $I->seeResponseIsValidOnJsonSchemaString('{"type": "object"}'); // response {"name": "john", "age": 20} $schema = [ - "properties" => [ - "age" => [ - "type" => "integer", - "minimum" => 18 + 'properties' => [ + 'age' => [ + 'type' => 'integer', + 'minimum' => 18 ] ] ]; @@ -910,6 +881,7 @@ or after another filter if you need more than one. Here is the list of possible filters: +* `array:empty` - check that value is an empty array * `integer:>{val}` - checks that integer is greater than {val} (works with float and string types too). * `integer:<{val}` - checks that integer is lower than {val} (works with float and string types too). * `string:url` - checks that value is valid url. @@ -968,7 +940,7 @@ Example: {% highlight php %} seeXmlResponseIncludes("1"); +$I->seeXmlResponseIncludes('1'); {% endhighlight %} @@ -995,7 +967,7 @@ $I->seeXmlResponseMatchesXpath('//root/user[@id=1]'); * `part` xml * `param string` $method * `param string` $url -* `param array|string|JsonSerializable` $params +* `param array|string|\JsonSerializable` $params * `param array` $files Sends a HTTP request. @@ -1078,7 +1050,7 @@ Sends an OPTIONS request to given uri. * `part` json * `part` xml * `param string` $url -* `param array|string|JsonSerializable` $params +* `param array|string|\JsonSerializable` $params * `param array` $files Sends PATCH request to given uri. @@ -1098,7 +1070,7 @@ $response = $I->sendPatch('/message/1', ['subject' => 'Read this!']); * `see` https://php.net/manual/en/features.file-upload.post-method.php * `see` codecept_data_dir() * `param string` $url -* `param array|string|JsonSerializable` $params +* `param array|string|\JsonSerializable` $params * `param array` $files A list of filenames or "mocks" of $_FILES (each entry being an array with the following keys: name, type, error, size, tmp_name (pointing to the real file path). Each key works as the "name" attribute of a file input field. @@ -1138,7 +1110,7 @@ $I->sendPost('/add-task', ['form' => [ * `part` json * `part` xml * `param string` $url -* `param array|string|JsonSerializable` $params +* `param array|string|\JsonSerializable` $params * `param array` $files Sends PUT request to given uri. @@ -1211,4 +1183,27 @@ $I->stopFollowingRedirects(); {% endhighlight %} + +#### unsetHttpHeader + +* `part` json +* `part` xml +* `param string` $name the name of the header to unset. +* `return void` + +Unsets a HTTP header (that was originally added by [haveHttpHeader()](#haveHttpHeader)), +so that subsequent requests will not send it anymore. + +Example: +{% highlight php %} + +haveHttpHeader('X-Requested-With', 'Codeception'); +$I->sendGet('test-headers.php'); +// ... +$I->unsetHttpHeader('X-Requested-With'); +$I->sendPost('some-other-page.php'); + +{% endhighlight %} +

     

    Module reference is taken from the source code. Help us to improve documentation. Edit module reference
    diff --git a/docs/modules/Redis.md b/docs/modules/Redis.md index ea78c6067..3c4505eb2 100644 --- a/docs/modules/Redis.md +++ b/docs/modules/Redis.md @@ -10,24 +10,11 @@ title: Redis - Codeception - Documentation # Redis ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-redis {% endhighlight %} -Alternatively, you can enable `Redis` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description diff --git a/docs/modules/SOAP.md b/docs/modules/SOAP.md index 1d179cca2..df106f035 100644 --- a/docs/modules/SOAP.md +++ b/docs/modules/SOAP.md @@ -10,24 +10,11 @@ title: SOAP - Codeception - Documentation # SOAP ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-soap {% endhighlight %} -Alternatively, you can enable `SOAP` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description diff --git a/docs/modules/Sequence.md b/docs/modules/Sequence.md index 69b2b3b3c..033920271 100644 --- a/docs/modules/Sequence.md +++ b/docs/modules/Sequence.md @@ -10,24 +10,11 @@ title: Sequence - Codeception - Documentation # Sequence ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-sequence {% endhighlight %} -Alternatively, you can enable `Sequence` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description diff --git a/docs/modules/Symfony.md b/docs/modules/Symfony.md index 34d6eb12b..78666b6fe 100644 --- a/docs/modules/Symfony.md +++ b/docs/modules/Symfony.md @@ -10,24 +10,11 @@ title: Symfony - Codeception - Documentation # Symfony ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-symfony {% endhighlight %} -Alternatively, you can enable `Symfony` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -36,7 +23,7 @@ This module uses [Symfony's DomCrawler](https://symfony.com/doc/current/componen and [HttpKernel Component](https://symfony.com/doc/current/components/http_kernel.html) to emulate requests and test response. * Access Symfony services through the dependency injection container: [`$I->grabService(...)`](#grabService) -* Use Doctrine to test against the database: `$I->seeInRepository(...)` - see [Doctrine Module](https://codeception.com/docs/modules/Doctrine2) +* Use Doctrine to test against the database: `$I->seeInRepository(...)` - see [Doctrine Module](https://codeception.com/docs/modules/Doctrine) * Assert that emails would have been sent: [`$I->seeEmailIsSent()`](#seeEmailIsSent) * Tests are wrapped into Doctrine transaction to speed them up. * Symfony Router can be cached between requests to speed up testing. @@ -47,19 +34,20 @@ and [HttpKernel Component](https://symfony.com/doc/current/components/http_kerne ### Config -#### Symfony 5.x or 4.4 +#### Symfony 5.4 or higher -* app_path: 'src' - Specify custom path to your app dir, where the kernel interface is located. -* environment: 'local' - Environment used for load kernel -* kernel_class: 'App\Kernel' - Kernel class name -* em_service: 'doctrine.orm.entity_manager' - Use the stated EntityManager to pair with Doctrine Module. -* debug: true - Turn on/off debug mode -* cache_router: 'false' - Enable router caching between tests in order to [increase performance](http://lakion.com/blog/how-did-we-speed-up-sylius-behat-suite-with-blackfire) -* rebootable_client: 'true' - Reboot client's kernel before each request -* guard: 'false' - Enable custom authentication system with guard (only for 4.x and 5.x versions of the symfony) -* authenticator: 'false' - Reboot client's kernel before each request (only for 6.x versions of the symfony) +* `app_path`: 'src' - Specify custom path to your app dir, where the kernel interface is located. +* `environment`: 'local' - Environment used for load kernel +* `kernel_class`: 'App\Kernel' - Kernel class name +* `em_service`: 'doctrine.orm.entity_manager' - Use the stated EntityManager to pair with Doctrine Module. +* `debug`: true - Turn on/off [debug mode](https://codeception.com/docs/Debugging) +* `cache_router`: 'false' - Enable router caching between tests in order to [increase performance](http://lakion.com/blog/how-did-we-speed-up-sylius-behat-suite-with-blackfire) (can have an impact on ajax requests sending via '$I->sendAjaxPostRequest()') +* `rebootable_client`: 'true' - Reboot client's kernel before each request +* `guard`: 'false' - Enable custom authentication system with guard (only for Symfony 5.4) +* `bootstrap`: 'false' - Enable the test environment setup with the tests/bootstrap.php file if it exists or with Symfony DotEnv otherwise. If false, it does nothing. +* `authenticator`: 'false' - Reboot client's kernel before each request (only for Symfony 6.0 or higher) -##### Example (`functional.suite.yml`) - Symfony 4 Directory Structure +##### Sample `Functional.suite.yml` modules: enabled: @@ -93,7 +81,7 @@ modules: enabled: - Symfony: part: services - - Doctrine2: + - Doctrine: depends: Symfony - WebDriver: url: http://example.com @@ -101,10 +89,9 @@ modules: {% endhighlight %} -If you're using Symfony with Eloquent ORM (instead of Doctrine), you can load the [`ORM` part of Laravel module](https://codeception.com/docs/modules/Laravel5#Parts) +If you're using Symfony with Eloquent ORM (instead of Doctrine), you can load the [`ORM` part of Laravel module](https://codeception.com/docs/modules/Laravel#Parts) in addition to Symfony module. - ### Actions #### _findElements @@ -252,9 +239,9 @@ Authenticates user for HTTP_AUTH #### amLoggedInAs -* `param UserInterface` $user +* `param \Symfony\Component\Security\Core\User\UserInterface` $user * `param string` $firewallName -* `param null` $firewallContext +* `param ?string` $firewallContext * `return void` Login with the given user object. @@ -273,6 +260,14 @@ $I->amLoggedInAs($user); {% endhighlight %} +#### amLoggedInWithToken + +* `param \Symfony\Component\Security\Core\Authentication\Token\TokenInterface` $token +* `param string` $firewallName +* `param ?string` $firewallContext +* `return void` + + #### amOnAction * `param string` $action @@ -326,6 +321,97 @@ $I->amOnRoute('posts.show', ['id' => 34]); {% endhighlight %} +#### assertBrowserCookieValueSame + +* `param string` $name +* `param string` $expectedValue +* `param bool` $raw +* `param string` $path +* `param ?string` $domain +* `param string` $message +* `return void` + +Asserts that the given cookie in the test client is set to the expected value. + +{% highlight php %} + +assertBrowserCookieValueSame('cookie_name', 'expected_value'); + +{% endhighlight %} + + +#### assertBrowserHasCookie + +* `param string` $name +* `param string` $path +* `param ?string` $domain +* `param string` $message +* `return void` + +Asserts that the test client has the specified cookie set. + +This indicates that the cookie was set by any response during the test. + +{% highlight yaml %} +assertBrowserHasCookie('cookie_name'); + +{% endhighlight %} + + +#### assertBrowserNotHasCookie + +* `param string` $name +* `param string` $path +* `param ?string` $domain +* `param string` $message +* `return void` + +Asserts that the test client does not have the specified cookie set. + +This indicates that the cookie was not set by any response during the test. + +{% highlight php %} + +assertBrowserNotHasCookie('cookie_name'); + +{% endhighlight %} + + +#### assertCheckboxChecked + +* `param string` $fieldName +* `param string` $message +* `return void` + +Asserts that the checkbox with the given name is checked. + +{% highlight php %} + +assertCheckboxChecked('agree_terms'); + +{% endhighlight %} + + +#### assertCheckboxNotChecked + +* `param string` $fieldName +* `param string` $message +* `return void` + +Asserts that the checkbox with the given name is not checked. + +{% highlight php %} + +assertCheckboxNotChecked('subscribe'); + +{% endhighlight %} + + #### assertEmailAddressContains * `param string` $headerName @@ -364,6 +450,23 @@ $I->assertEmailAttachmentCount(1); {% endhighlight %} +#### assertEmailCount + +* `param int` $count +* `param ?string` $transport +* `param string` $message +* `return void` + +Asserts that the expected number of emails was sent. + +{% highlight php %} + +assertEmailCount(2, 'smtp'); + +{% endhighlight %} + + #### assertEmailHasHeader * `param string` $headerName @@ -458,6 +561,44 @@ $I->assertEmailHtmlBodyNotContains('userpassword'); {% endhighlight %} +#### assertEmailIsNotQueued + +* `param \Symfony\Component\Mailer\Event\MessageEvent` $event +* `param string` $message +* `return void` + +Asserts that the given mailer event is not queued. + +Use `getMailerEvent(int $index = 0, ?string $transport = null)` to retrieve a mailer event by index. + +{% highlight php %} + +getMailerEvent(); +$I->assertEmailIsNotQueued($event); + +{% endhighlight %} + + +#### assertEmailIsQueued + +* `param \Symfony\Component\Mailer\Event\MessageEvent` $event +* `param string` $message +* `return void` + +Asserts that the given mailer event is queued. + +Use `getMailerEvent(int $index = 0, ?string $transport = null)` to retrieve a mailer event by index. + +{% highlight php %} + +getMailerEvent(); +$I->assertEmailIsQueued($event); + +{% endhighlight %} + + #### assertEmailNotHasHeader * `param string` $headerName @@ -512,250 +653,973 @@ $I->assertEmailTextBodyNotContains('My secret text body'); {% endhighlight %} -#### attachFile +#### assertFormValue -* `param ` $field -* `param string` $filename +* `param string` $formSelector +* `param string` $fieldName +* `param string` $value +* `param string` $message * `return void` -Attaches a file relative to the Codeception `_data` directory to the given file upload field. +Asserts that value of the field of the first form matching the given selector does equal the expected value. {% highlight php %} attachFile('input[@type="file"]', 'prices.xls'); +$I->assertFormValue('#loginForm', 'username', 'john_doe'); {% endhighlight %} -#### checkOption +#### assertHttpClientRequest -* `param ` $option +* `param string` $expectedUrl +* `param string` $expectedMethod +* `param string|array|null` $expectedBody +* `param array` $expectedHeaders +* `param string` $httpClientId * `return void` -Ticks a checkbox. For radio buttons, use the `selectOption` method instead. +Asserts that the given URL has been called using, if specified, the given method, body and/or headers. + +By default, it will inspect the default Symfony HttpClient; you may check a different one by passing its +service-id in $httpClientId. +It succeeds even if the request was executed multiple times. {% highlight php %} checkOption('#agree'); +$I->assertHttpClientRequest( + 'https://example.com/api', + 'POST', + '{"data": "value"}', + ['Authorization' => 'Bearer token'] +); {% endhighlight %} -#### click +#### assertHttpClientRequestCount -* `param string|array` $link -* `param ` $context +* `param int` $count +* `param string` $httpClientId * `return void` -Perform a click on a link or a button, given by a locator. +Asserts that exactly $count requests have been executed by the given HttpClient. -If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. -For buttons, the "value" attribute, "name" attribute, and inner text are searched. -For links, the link text is searched. -For images, the "alt" attribute and inner text of any parent links are searched. +By default, it will inspect the default Symfony HttpClient; you may check a different one by passing its +service-id in $httpClientId. -The second parameter is a context (CSS or XPath locator) to narrow the search. +{% highlight php %} + +$I->assertHttpClientRequestCount(3); + +{% endhighlight %} -Note that if the locator matches a button of type `submit`, the form will be submitted. + +#### assertInputValueNotSame + +* `param string` $fieldName +* `param string` $expectedValue +* `param string` $message +* `return void` + +Asserts that the value of the form input with the given name does not equal the expected value. {% highlight php %} click('Logout'); -// button of form -$I->click('Submit'); -// CSS button -$I->click('#form input[type=submit]'); -// XPath -$I->click('//form/*[@type="submit"]'); -// link in context -$I->click('Logout', '#nav'); -// using strict locator -$I->click(['link' => 'Login']); +$I->assertInputValueNotSame('username', 'admin'); {% endhighlight %} -#### deleteHeader +#### assertInputValueSame -* `param string` $name the name of the header to delete. +* `param string` $fieldName +* `param string` $expectedValue +* `param string` $message * `return void` -Deletes the header with the passed name. Subsequent requests -will not have the deleted header in its request. +Asserts that the value of the form input with the given name equals the expected value. -Example: {% highlight php %} haveHttpHeader('X-Requested-With', 'Codeception'); -$I->amOnPage('test-headers.php'); -// ... -$I->deleteHeader('X-Requested-With'); -$I->amOnPage('some-other-page.php'); +$I->assertInputValueSame('username', 'johndoe'); {% endhighlight %} -#### dontSee +#### assertNoFormValue -* `param string` $text -* `param array|string` $selector optional +* `param string` $formSelector +* `param string` $fieldName +* `param string` $message * `return void` -Checks that the current page doesn't contain the text specified (case insensitive). - -Give a locator as the second parameter to match a specific region. +Asserts that the field of the first form matching the given selector does not have a value. {% highlight php %} dontSee('Login'); // I can suppose user is already logged in -$I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page -$I->dontSee('Sign Up','//body/h1'); // with XPath -$I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator +$I->assertNoFormValue('#registrationForm', 'middle_name'); {% endhighlight %} -Note that the search is done after stripping all HTML tags from the body, -so `$I->dontSee('strong')` will fail on strings like: - - `

    I am Stronger than thou

    ` - - `` +#### assertNotHttpClientRequest -But will ignore strings like: +* `param string` $unexpectedUrl +* `param string` $unexpectedMethod +* `param string` $httpClientId +* `return void` - - `Home` - - `
    Home` - - `` +Asserts that the given URL *has not* been requested with the supplied HTTP method. -For checking the raw source code, use `seeInSource()`. +By default, it will inspect the default Symfony HttpClient; you may check a different one by passing its +service-id in $httpClientId. +{% highlight php %} +$I->assertNotHttpClientRequest('https://example.com/unexpected', 'GET'); + +{% endhighlight %} -#### dontSeeAuthentication +#### assertNotificationCount + +* `param int` $count +* `param ?string` $transportName +* `param string` $message * `return void` -Check that user is not authenticated. +Asserts that the expected number of notifications was sent. {% highlight php %} dontSeeAuthentication(); +$I->assertNotificationCount(2, 'smtp'); {% endhighlight %} -#### dontSeeCheckboxIsChecked +#### assertNotificationIsNotQueued -* `param ` $checkbox +* `param \Symfony\Component\Notifier\Event\MessageEvent` $event +* `param string` $message * `return void` -Check that the specified checkbox is unchecked. +Asserts that the given notifier event is not queued. + +Use `getNotifierEvent(int $index = 0, ?string $transportName = null)` to retrieve a notifier event by index. {% highlight php %} dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms -$I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. +$event = $I->getNotifierEvent(); +$I->asserNotificationIsNotQueued($event); {% endhighlight %} -#### dontSeeCookie +#### assertNotificationIsQueued -* `param ` $cookie -* `param ` $params -* `return mixed|void` +* `param \Symfony\Component\Notifier\Event\MessageEvent` $event +* `param string` $message +* `return void` -Checks that there isn't a cookie with the given name. +Asserts that the given notifier event is queued. -You can set additional cookie params like `domain`, `path` as array passed in last argument. +Use `getNotifierEvent(int $index = 0, ?string $transportName = null)` to retrieve a notifier event by index. +{% highlight php %} -#### dontSeeCurrentUrlEquals +getNotifierEvent(); +$I->assertNotificationlIsQueued($event); -* `param string` $uri +{% endhighlight %} + + +#### assertNotificationSubjectContains + +* `param \Symfony\Component\Notifier\Message\MessageInterface` $notification +* `param string` $text +* `param string` $message * `return void` -Checks that the current URL doesn't equal the given string. +Asserts that the given notification contains given subject. -Unlike `dontSeeInCurrentUrl`, this only matches the full URL. +Use `getNotifierMessage(int $index = 0, ?string $transportName = null)` to retrieve a notification by index. {% highlight php %} dontSeeCurrentUrlEquals('/'); +$notification = $I->getNotifierMessage(); +$I->assertNotificationSubjectContains($notification, 'Subject'); {% endhighlight %} -#### dontSeeCurrentUrlMatches +#### assertNotificationSubjectNotContains -* `param string` $uri +* `param \Symfony\Component\Notifier\Message\MessageInterface` $notification +* `param string` $text +* `param string` $message * `return void` -Checks that current url doesn't match the given regular expression. +Asserts that the given notification does not contain given subject. + +Use `getNotifierMessage(int $index = 0, ?string $transportName = null)` to retrieve a notification by index. {% highlight php %} dontSeeCurrentUrlMatches('~^/users/(\d+)~'); +$notification = $I->getNotifierMessage(); +$I->assertNotificationSubjectNotContains($notification, 'Subject'); {% endhighlight %} -#### dontSeeElement +#### assertNotificationTransportIsEqual -* `param ` $selector -* `param array` $attributes +* `param \Symfony\Component\Notifier\Message\MessageInterface` $notification +* `param ?string` $transportName +* `param string` $message * `return void` -Checks that the given element is invisible or not present on the page. +Asserts that the given notification uses given transport. -You can also specify expected attributes of this element. +Use `getNotifierMessage(int $index = 0, ?string $transportName = null)` to retrieve a notification by index. {% highlight php %} dontSeeElement('.error'); -$I->dontSeeElement('//form/input[1]'); -$I->dontSeeElement('input', ['name' => 'login']); -$I->dontSeeElement('input', ['value' => '123456']); +$notification = $I->getNotifierMessage(); +$I->assertNotificationTransportIsEqual($notification, 'chat'); {% endhighlight %} -#### dontSeeEmailIsSent +#### assertNotificationTransportIsNotEqual +* `param \Symfony\Component\Notifier\Message\MessageInterface` $notification +* `param ?string` $transportName +* `param string` $message * `return void` -Checks that no email was sent. +Asserts that the given notification does not use given transport. -The check is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means: -If your app performs a HTTP redirect, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first; otherwise this check will *always* pass. -Starting with version 2.0.0, `codeception/module-symfony` requires your app to use [Symfony Mailer](https://symfony.com/doc/current/mailer.html). If your app still uses [Swift Mailer](https://symfony.com/doc/current/email.html), set your version constraint to `^1.6`. +Use `getNotifierMessage(int $index = 0, ?string $transportName = null)` to retrieve a notification by index. +{% highlight php %} + +getNotifierMessage(); +$I->assertNotificationTransportIsNotEqual($notification, 'transport'); + +{% endhighlight %} -#### dontSeeEventTriggered -* `param object|string|string[]` $expected +#### assertPageTitleContains + +* `param string` $expectedTitle +* `param string` $message * `return void` -Verifies that one or more event listeners were not called during the test. +Asserts that the `` element contains the given title. + +{% highlight php %} + +<?php +$I->assertPageTitleContains('Welcome'); + +{% endhighlight %} + + +#### assertPageTitleSame + +* `param string` $expectedTitle +* `param string` $message +* `return void` + +Asserts that the `<title>` element equals the given title. + +{% highlight php %} + +<?php +$I->assertPageTitleSame('Home Page'); + +{% endhighlight %} + + +#### assertQueuedEmailCount + +* `param int` $count +* `param ?string` $transport +* `param string` $message +* `return void` + +Asserts that the expected number of emails was queued (e.g. using the Messenger component). + +{% highlight php %} + +<?php +$I->assertQueuedEmailCount(1, 'smtp'); + +{% endhighlight %} + + +#### assertQueuedNotificationCount + +* `param int` $count +* `param ?string` $transportName +* `param string` $message +* `return void` + +Asserts that the expected number of notifications was queued (e.g. using the Notifier component). + +{% highlight php %} + +<?php +$I->assertQueuedNotificationCount(1, 'smtp'); + +{% endhighlight %} + + +#### assertRequestAttributeValueSame + +* `param string` $name +* `param string` $expectedValue +* `param string` $message +* `return void` + +Asserts that the specified request attribute matches the expected value. + +{% highlight php %} + +<?php +$I->assertRequestAttributeValueSame('attribute_name', 'expected_value'); + +{% endhighlight %} + + +#### assertResponseCookieValueSame + +* `param string` $name +* `param string` $expectedValue +* `param string` $path +* `param ?string` $domain +* `param string` $message +* `return void` + +Asserts that the specified response cookie is present and matches the expected value. + +{% highlight php %} + +<?php +$I->assertResponseCookieValueSame('cookie_name', 'expected_value'); + +{% endhighlight %} + + +#### assertResponseFormatSame + +* `param ?string` $expectedFormat +* `param string` $message +* `return void` + +Asserts that the response format matches the expected format. This checks the format returned by the `Response::getFormat()` method. + +{% highlight php %} + +<?php +$I->assertResponseFormatSame('json'); + +{% endhighlight %} + + +#### assertResponseHasCookie + +* `param string` $name +* `param string` $path +* `param ?string` $domain +* `param string` $message +* `return void` + +Asserts that the specified cookie is present in the response. Optionally, it can check for a specific cookie path or domain. + +{% highlight php %} + +<?php +$I->assertResponseHasCookie('cookie_name'); + +{% endhighlight %} + + +#### assertResponseHasHeader + +* `param string` $headerName +* `param string` $message +* `return void` + +Asserts that the specified header is available in the response. + +For example, use `assertResponseHasHeader('content-type');`. + +{% highlight php %} + +<?php +$I->assertResponseHasHeader('content-type'); + +{% endhighlight %} + + +#### assertResponseHeaderNotSame + +* `param string` $headerName +* `param string` $expectedValue +* `param string` $message +* `return void` + +Asserts that the specified header does not contain the expected value in the response. + +For example, use `assertResponseHeaderNotSame('content-type', 'application/octet-stream');`. + +{% highlight php %} + +<?php +$I->assertResponseHeaderNotSame('content-type', 'application/json'); + +{% endhighlight %} + + +#### assertResponseHeaderSame + +* `param string` $headerName +* `param string` $expectedValue +* `param string` $message +* `return void` + +Asserts that the specified header contains the expected value in the response. + +For example, use `assertResponseHeaderSame('content-type', 'application/octet-stream');`. + +{% highlight php %} + +<?php +$I->assertResponseHeaderSame('content-type', 'application/json'); + +{% endhighlight %} + + +#### assertResponseIsSuccessful + +* `param string` $message +* `param bool` $verbose +* `return void` + +Asserts that the response was successful (HTTP status code is in the 2xx range). + +{% highlight php %} + +<?php +$I->assertResponseIsSuccessful(); + +{% endhighlight %} + + +#### assertResponseIsUnprocessable + +* `param string` $message +* `param bool` $verbose +* `return void` + +Asserts that the response is unprocessable (HTTP status code is 422). + +{% highlight php %} + +<?php +$I->assertResponseIsUnprocessable(); + +{% endhighlight %} + + +#### assertResponseNotHasCookie + +* `param string` $name +* `param string` $path +* `param ?string` $domain +* `param string` $message +* `return void` + +Asserts that the specified cookie is not present in the response. Optionally, it can check for a specific cookie path or domain. + +{% highlight php %} + +<?php +$I->assertResponseNotHasCookie('cookie_name'); + +{% endhighlight %} + + +#### assertResponseNotHasHeader + +* `param string` $headerName +* `param string` $message +* `return void` + +Asserts that the specified header is not available in the response. + +{% highlight php %} + +<?php +$I->assertResponseNotHasHeader('content-type'); + +{% endhighlight %} + + +#### assertResponseRedirects + +* `param ?string` $expectedLocation +* `param ?int` $expectedCode +* `param string` $message +* `param bool` $verbose +* `return void` + +Asserts that the response is a redirect. Optionally, you can check the target location and status code. + +The expected location can be either an absolute or a relative path. + +{% highlight php %} + +<?php +// Check that '/admin' redirects to '/login' with status code 302 +$I->assertResponseRedirects('/login', 302); + +{% endhighlight %} + + +#### assertResponseStatusCodeSame + +* `param int` $expectedCode +* `param string` $message +* `param bool` $verbose +* `return void` + +Asserts that the response status code matches the expected code. + +{% highlight php %} + +<?php +$I->assertResponseStatusCodeSame(200); + +{% endhighlight %} + + +#### assertRouteSame + +* `param string` $expectedRoute +* `param array` $parameters +* `param string` $message +* `return void` + +Asserts the request matches the given route and optionally route parameters. + +{% highlight php %} + +<?php +$I->assertRouteSame('profile', ['id' => 123]); + +{% endhighlight %} + + +#### assertSelectorExists + +* `param string` $selector +* `param string` $message +* `return void` + +Asserts that the given selector matches at least one element in the response. + +{% highlight php %} + +<?php +$I->assertSelectorExists('.main-content'); + +{% endhighlight %} + + +#### assertSelectorNotExists + +* `param string` $selector +* `param string` $message +* `return void` + +Asserts that the given selector does not match at least one element in the response. + +{% highlight php %} + +<?php +$I->assertSelectorNotExists('.error'); + +{% endhighlight %} + + +#### assertSelectorTextContains + +* `param string` $selector +* `param string` $text +* `param string` $message +* `return void` + +Asserts that the first element matching the given selector contains the expected text. + +{% highlight php %} + +<?php +$I->assertSelectorTextContains('h1', 'Dashboard'); + +{% endhighlight %} + + +#### assertSelectorTextNotContains + +* `param string` $selector +* `param string` $text +* `param string` $message +* `return void` + +Asserts that the first element matching the given selector does not contain the expected text. + +{% highlight php %} + +<?php +$I->assertSelectorTextNotContains('p', 'error'); + +{% endhighlight %} + + +#### assertSelectorTextSame + +* `param string` $selector +* `param string` $text +* `param string` $message +* `return void` + +Asserts that the text of the first element matching the given selector equals the expected text. + +{% highlight php %} + +<?php +$I->assertSelectorTextSame('h1', 'Dashboard'); + +{% endhighlight %} + + +#### attachFile + +* `param ` $field +* `param string` $filename +* `return void` + +Attaches a file relative to the Codeception `_data` directory to the given file upload field. + +{% highlight php %} + +<?php +// file is stored in 'tests/_data/prices.xls' +$I->attachFile('input[@type="file"]', 'prices.xls'); + +{% endhighlight %} + + +#### checkOption + +* `param ` $option +* `return void` + +Ticks a checkbox. For radio buttons, use the `selectOption` method instead. + +{% highlight php %} + +<?php +$I->checkOption('#agree'); + +{% endhighlight %} + + +#### click + +* `param string|array` $link +* `param ` $context +* `return void` + +Perform a click on a link or a button, given by a locator. + +If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. +For buttons, the "value" attribute, "name" attribute, and inner text are searched. +For links, the link text is searched. +For images, the "alt" attribute and inner text of any parent links are searched. + +The second parameter is a context (CSS or XPath locator) to narrow the search. + +Note that if the locator matches a button of type `submit`, the form will be submitted. + +{% highlight php %} + +<?php +// simple link +$I->click('Logout'); +// button of form +$I->click('Submit'); +// CSS button +$I->click('#form input[type=submit]'); +// XPath +$I->click('//form/*[@type="submit"]'); +// link in context +$I->click('Logout', '#nav'); +// using strict locator +$I->click(['link' => 'Login']); + +{% endhighlight %} + + +#### deleteHeader + +@deprecated +* `param string` $name +* `return void` + + +#### dontSee + +* `param string` $text +* `param array|string` $selector optional +* `return void` + +Checks that the current page doesn't contain the text specified (case insensitive). + +Give a locator as the second parameter to match a specific region. + +{% highlight php %} + +<?php +$I->dontSee('Login'); // I can suppose user is already logged in +$I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page +$I->dontSee('Sign Up','//body/h1'); // with XPath +$I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator + +{% endhighlight %} + +Note that the search is done after stripping all HTML tags from the body, +so `$I->dontSee('strong')` will fail on strings like: + + - `<p>I am Stronger than thou</p>` + - `<script>document.createElement('strong');</script>` + +But will ignore strings like: + + - `<strong>Home</strong>` + - `<div class="strong">Home</strong>` + - `<!-- strong -->` + +For checking the raw source code, use `seeInSource()`. + + +#### dontSeeAuthentication + +* `return void` + +Check that user is not authenticated. + +{% highlight php %} + +<?php +$I->dontSeeAuthentication(); + +{% endhighlight %} + + +#### dontSeeCheckboxIsChecked + +* `param ` $checkbox +* `return void` + +Check that the specified checkbox is unchecked. + +{% highlight php %} + +<?php +$I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms +$I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. + +{% endhighlight %} + + +#### dontSeeCookie + +* `param ` $cookie +* `param ` $params +* `return mixed|void` + +Checks that there isn't a cookie with the given name. + +You can set additional cookie params like `domain`, `path` as array passed in last argument. + + +#### dontSeeCurrentUrlEquals + +* `param string` $uri +* `return void` + +Checks that the current URL (path) doesn't equal the given string. + +Unlike `dontSeeInCurrentUrl`, this only matches the full URL. + +{% highlight php %} + +<?php +// current url is not root +$I->dontSeeCurrentUrlEquals('/'); + +{% endhighlight %} + + +#### dontSeeCurrentUrlMatches + +* `param string` $uri +* `return void` + +Checks that current URL (path) doesn't match the given regular expression. + +{% highlight php %} + +<?php +// to match root url +$I->dontSeeCurrentUrlMatches('~^/users/\d+$~'); + +{% endhighlight %} + + +#### dontSeeDeprecations + +* `param string` $message Optional custom failure message. +* `return void` + +Asserts that there are no deprecation messages in Symfony's log. + +{% highlight php %} + +<?php +$I->amOnPage('/home'); +$I->dontSeeDeprecations(); + +{% endhighlight %} + + +#### dontSeeElement + +* `param ` $selector +* `param array` $attributes +* `return void` + +Checks that the given element is invisible or not present on the page. + +You can also specify expected attributes of this element. + +{% highlight php %} + +<?php +$I->dontSeeElement('.error'); +$I->dontSeeElement('//form/input[1]'); +$I->dontSeeElement('input', ['name' => 'login']); +$I->dontSeeElement('input', ['value' => '123456']); + +{% endhighlight %} + + +#### dontSeeEmailIsSent + +* `return void` + +Checks that no email was sent. + +The check is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means: +If your app performs an HTTP redirect, you need to suppress it using [stopFollowingRedirects()](#stopFollowingRedirects) first; otherwise this check will *always* pass. + +{% highlight php %} + +<?php +$I->dontSeeEmailIsSent(); + +{% endhighlight %} + + +#### dontSeeEvent + +* `param class-string|list<class-string>|null` $expected Fully-qualified event class(es) that must **not** appear. +* `return void` + +Verifies that **no** events (regular **or** orphan) were dispatched during the test. + +{% highlight php %} + +<?php +$I->dontSeeEvent(); +$I->dontSeeEvent('App\MyEvent'); +$I->dontSeeEvent(['App\MyEvent', 'App\MyOtherEvent']); + +{% endhighlight %} + + +#### dontSeeEventListenerIsCalled + +* `param class-string|object|list<class-string|object>` $expected Listeners (class-strings or object instances). +* `param string|list<string>` $events Event name(s) (empty = any). +* `return void` + +Verifies that one or more **listeners** were **not** called during the test. + +{% highlight php %} + +<?php +$I->dontSeeEventListenerIsCalled('App\MyEventListener'); +$I->dontSeeEventListenerIsCalled(['App\MyEventListener', 'App\MyOtherEventListener']); +$I->dontSeeEventListenerIsCalled('App\MyEventListener', 'my.event'); +$I->dontSeeEventListenerIsCalled('App\MyEventListener', ['my.event', 'my.other.event']); + +{% endhighlight %} + + +#### dontSeeEventTriggered + +@deprecated +* `param class-string|object|list<class-string|object>` $expected +* `return void` + +Verifies that one or more event listeners were not called during the test. + +{% highlight php %} + +<?php +$I->dontSeeEventTriggered('App\MyEvent'); +$I->dontSeeEventTriggered(new App\Events\MyEvent()); +$I->dontSeeEventTriggered(['App\MyEvent', 'App\MyOtherEvent']); + +{% endhighlight %} + + +#### dontSeeFallbackTranslations + +* `return void` + +Asserts that no fallback translations were found. {% highlight php %} <?php -$I->dontSeeEventTriggered('App\MyEvent'); -$I->dontSeeEventTriggered(new App\Events\MyEvent()); -$I->dontSeeEventTriggered(['App\MyEvent', 'App\MyOtherEvent']); +$I->dontSeeFallbackTranslations(); {% endhighlight %} @@ -779,7 +1643,7 @@ $I->dontSeeFormErrors(); * `param string` $uri * `return void` -Checks that the current URI doesn't contain the given string. +Checks that the current URI (path) doesn't contain the given string. {% highlight php %} @@ -919,6 +1783,37 @@ $I->dontSeeLink('Checkout now', '/store/cart.php'); {% endhighlight %} +#### dontSeeMissingTranslations + +* `return void` + +Asserts that no missing translations were found. + +{% highlight php %} + +<?php +$I->dontSeeMissingTranslations(); + +{% endhighlight %} + + +#### dontSeeNotificationIsSent + +* `return void` + +Checks that no notification was sent. + +The check is based on `\Symfony\Component\Notifier\EventListener\NotificationLoggerListener`, which means: +If your app performs an HTTP redirect, you need to suppress it using [stopFollowingRedirects()](#stopFollowingRedirects) first; otherwise this check will *always* pass. + +{% highlight php %} + +<?php +$I->dontSeeNotificationIsSent(); + +{% endhighlight %} + + #### dontSeeOptionIsSelected * `param ` $selector @@ -937,21 +1832,20 @@ $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); #### dontSeeOrphanEvent -* `param object|string|string[]` $expected +* `param class-string|list<class-string>|null` $expected Event class(es) that must **not** appear as orphan. * `return void` Verifies that there were no orphan events during the test. An orphan event is an event that was triggered by manually executing the -[`dispatch()`](https://symfony.com/doc/current/components/event_dispatcher.html#dispatch-the-event) method -of the EventDispatcher but was not handled by any listener after it was dispatched. +{@link https://symfony.com/doc/current/components/event_dispatcher.html#dispatch-the-event dispatch()} +method of the EventDispatcher but was not handled by any listener after it was dispatched. {% highlight php %} <?php $I->dontSeeOrphanEvent(); $I->dontSeeOrphanEvent('App\MyEvent'); -$I->dontSeeOrphanEvent(new App\Events\MyEvent()); $I->dontSeeOrphanEvent(['App\MyEvent', 'App\MyOtherEvent']); {% endhighlight %} @@ -1004,6 +1898,27 @@ $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK); {% endhighlight %} +#### dontSeeViolatedConstraint + +* `param object` $subject +* `param ?string` $propertyPath +* `param ?string` $constraint +* `return void` + +Asserts that the given subject fails validation. + +This assertion does not concern the exact number of violations. + +{% highlight php %} + +<?php +$I->dontSeeViolatedConstraint($subject); +$I->dontSeeViolatedConstraint($subject, 'propertyName'); +$I->dontSeeViolatedConstraint($subject, 'propertyName', 'Symfony\Validator\ConstraintClass'); + +{% endhighlight %} + + #### fillField * `param ` $field @@ -1035,6 +1950,66 @@ $I->followRedirect(); {% endhighlight %} +#### getMailerEvent + +* `param int` $index +* `param ?string` $transport +* `return ?\Symfony\Component\Mailer\Event\MessageEvent` + +Returns the mailer event at the specified index. + +{% highlight php %} + +<?php +$event = $I->getMailerEvent(); + +{% endhighlight %} + + +#### getNotifierEvent + +* `param int` $index +* `param ?string` $transportName +* `return ?\Symfony\Component\Notifier\Event\MessageEvent` + +Returns the notifier event at the specified index. + +{% highlight php %} + +<?php +$event = $I->getNotifierEvent(); + +{% endhighlight %} + + +#### getNotifierEvents + +* `param ?string` $transportName +* `return MessageEvent[]` + + +#### getNotifierMessage + +* `param int` $index +* `param ?string` $transportName +* `return ?\Symfony\Component\Notifier\Message\MessageInterface` + +Returns the notifier message at the specified index. + +{% highlight php %} + +<?php +$message = $I->getNotifierMessage(); + +{% endhighlight %} + + +#### getNotifierMessages + +* `param ?string` $transportName +* `return MessageInterface[]` + + #### goToLogoutPath * `return void` @@ -1052,9 +2027,9 @@ See the Symfony documentation on ['Logging Out'](https://symfony.com/doc/current * `param string` $attribute * `return mixed` -Grabs the value of the given attribute value from the given element. +Returns the value of the given attribute value from the given HTML element. For some attributes, the string `true` is returned instead of their literal value (e.g. `disabled="disabled"` or `required="required"`). -Fails if element is not found. +Fails if the element is not found. Returns `null` if the attribute is not present on the element. {% highlight php %} @@ -1076,6 +2051,20 @@ You can set additional cookie params like `domain`, `path` in array passed as la If the cookie is set by an ajax request (XMLHttpRequest), there might be some delay caused by the browser, so try `$I->wait(0.1)`. +#### grabDefinedTranslationsCount + +* `return int` The count of defined translations. + +Grabs the count of defined translations. + +{% highlight php %} + +<?php +$count = $I->grabDefinedTranslations(); + +{% endhighlight %} + + #### grabFromCurrentUrl * `param ?string` $uri @@ -1101,8 +2090,7 @@ $uri = $I->grabFromCurrentUrl(); Returns the last sent email. The function is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means: -If your app performs a HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first. -Starting with version 2.0.0, `codeception/module-symfony` requires your app to use [Symfony Mailer](https://symfony.com/doc/current/mailer.html). If your app still uses [Swift Mailer](https://symfony.com/doc/current/email.html), set your version constraint to `^1.6`. +If your app performs an HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](#stopFollowingRedirects) first. See also: [grabSentEmails()](https://codeception.com/docs/modules/Symfony#grabSentEmails) {% highlight php %} @@ -1115,6 +2103,25 @@ $I->assertSame('john_doe@example.com', $address->getAddress()); {% endhighlight %} +#### grabLastSentNotification + +* `return ?\Symfony\Component\Notifier\Message\MessageInterface` + +Returns the last sent notification. + +The check is based on `\Symfony\Component\Notifier\EventListener\NotificationLoggerListener`, which means: +If your app performs an HTTP redirect after sending the notification, you need to suppress it using [stopFollowingRedirects()](#stopFollowingRedirects) first. +See also: [grabSentNotifications()](https://codeception.com/docs/modules/Symfony#grabSentNotifications) + +{% highlight php %} + +<?php +$message = $I->grabLastSentNotification(); +$I->assertSame('Subject', $message->getSubject()); + +{% endhighlight %} + + #### grabMultiple * `param ` $cssOrXpath @@ -1146,24 +2153,24 @@ $aLinks = $I->grabMultiple('a', 'href'); #### grabNumRecords -* `param string` $entityClass The entity class -* `param array` $criteria Optional query criteria +* `param class-string<object>` $entityClass Fully-qualified entity class name +* `param array` $criteria * `return int` -Retrieves number of records from database -'id' is the default search parameter. +Returns the number of rows that match the given criteria for the +specified Doctrine entity. {% highlight php %} <?php -$I->grabNumRecords('User::class', ['name' => 'davert']); +$I->grabNumRecords(User::class, ['status' => 'active']); {% endhighlight %} #### grabPageSource -* `throws ModuleException` if no page was opened. +* `throws \Codeception\Exception\ModuleException` if no page was opened. * `return string` Current page source code. Grabs current page source code. @@ -1171,8 +2178,8 @@ Grabs current page source code. #### grabParameter -* `param string` $name -* `return array|bool|float|int|string|null` +* `param string` $parameterName +* `return array<array-key,` mixed>|bool|string|int|float|UnitEnum|null Grabs a Symfony parameter @@ -1182,37 +2189,36 @@ Grabs a Symfony parameter $I->grabParameter('app.business_name'); {% endhighlight %} +This only works for explicitly set parameters (just using `bind` for Symfony's dependency injection is not enough). #### grabRepository -* `param object|string` $mixed -* `return ?\Doctrine\ORM\EntityRepository` - -Grab a Doctrine entity repository. +* `param object|class-string` $mixed +* `return EntityRepository<object>` -Works with objects, entities, repositories, and repository interfaces. +Obtains the Doctrine entity repository {@see EntityRepository} +for a given entity, repository class or interface. {% highlight php %} <?php -$I->grabRepository($user); -$I->grabRepository(User::class); -$I->grabRepository(UserRepository::class); -$I->grabRepository(UserRepositoryInterface::class); +$I->grabRepository($user); // entity object +$I->grabRepository(User::class); // entity class +$I->grabRepository(UserRepository::class); // concrete repo +$I->grabRepository(UserRepositoryInterface::class); // interface {% endhighlight %} #### grabSentEmails -* `return \Symfony\Component\Mime\Email[]` +* `return \Symfony\Component\Mime\RawMessage[]` Returns an array of all sent emails. The function is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means: -If your app performs a HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first. -Starting with version 2.0.0, `codeception/module-symfony` requires your app to use [Symfony Mailer](https://symfony.com/doc/current/mailer.html). If your app still uses [Swift Mailer](https://symfony.com/doc/current/email.html), set your version constraint to `^1.6`. +If your app performs an HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](#stopFollowingRedirects) first. See also: [grabLastSentEmail()](https://codeception.com/docs/modules/Symfony#grabLastSentEmail) {% highlight php %} @@ -1223,17 +2229,35 @@ $emails = $I->grabSentEmails(); {% endhighlight %} +#### grabSentNotifications + +* `return MessageInterface[]` + +Returns an array of all sent notifications. + +The check is based on `\Symfony\Component\Notifier\EventListener\NotificationLoggerListener`, which means: +If your app performs an HTTP redirect after sending the notification, you need to suppress it using [stopFollowingRedirects()](#stopFollowingRedirects) first. +See also: [grabLastSentNotification()](https://codeception.com/docs/modules/Symfony#grabLastSentNotification) + +{% highlight php %} + +<?php +$notifications = $I->grabSentNotifications(); + +{% endhighlight %} + + #### grabService * `part` services -* `param string` $serviceId +* `param non-empty-string` $serviceId * `return object` Grabs a service from the Symfony dependency injection container (DIC). -In "test" environment, Symfony uses a special `test.service_container`. +In the "test" environment, Symfony uses a special `test.service_container`. See the "[Public Versus Private Services](https://symfony.com/doc/current/service_container/alias_private.html#marking-services-as-public-private)" documentation. -Services that aren't injected somewhere into your app, need to be defined as `public` to be accessible by Codeception. +Services that aren't injected anywhere in your app, need to be defined as `public` to be accessible by Codeception. {% highlight php %} @@ -1396,7 +2420,7 @@ Moves back in history. #### persistPermanentService * `part` services -* `param string` $serviceName +* `param non-empty-string` $serviceName * `return void` Get service $serviceName and add it to the lists of persistent services, @@ -1406,7 +2430,7 @@ making that service persistent between tests. #### persistService * `part` services -* `param string` $serviceName +* `param non-empty-string` $serviceName * `return void` Get service $serviceName and add it to the lists of persistent services. @@ -1416,9 +2440,9 @@ Get service $serviceName and add it to the lists of persistent services. * `return void` -Reboot client's kernel. +Reboots the client's kernel. -Can be used to manually reboot kernel when 'rebootable_client' => false +Can be used to manually reboot the kernel when 'rebootable_client' is set to false. {% highlight php %} @@ -1447,11 +2471,11 @@ You can set additional cookie params like `domain`, `path` in array passed as la #### runSymfonyConsoleCommand -* `param string` $command The console command to execute -* `param array` $parameters Parameters (arguments and options) to pass to the command -* `param array` $consoleInputs Console inputs (e.g. used for interactive questions) -* `param int` $expectedExitCode The expected exit code of the command -* `return string` Returns the console output of the command +* `param string` $command The console command to execute. +* `param array` $parameters +* `param list<string>` $consoleInputs Inputs for interactive questions. +* `param int` $expectedExitCode Expected exit code. +* `return string` Console output (stdout). Run Symfony console command, grab response and return as string. @@ -1501,6 +2525,20 @@ But will *not* be true for strings like: For checking the raw source code, use `seeInSource()`. +#### seeAllTranslationsDefined + +* `return void` + +Asserts that there are no missing translations and no fallback translations. + +{% highlight php %} + +<?php +$I->seeAllTranslationsDefined(); + +{% endhighlight %} + + #### seeAuthentication * `return void` @@ -1603,14 +2641,12 @@ $I->seeCurrentTemplateIs('home.html.twig'); * `param string` $uri * `return void` -Checks that the current URL is equal to the given string. - -Unlike `seeInCurrentUrl`, this only matches the full URL. +Checks that the current URL (path) is equal to the given string. {% highlight php %} <?php -// to match root url +// to match the home page $I->seeCurrentUrlEquals('/'); {% endhighlight %} @@ -1621,13 +2657,27 @@ $I->seeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that the current URL matches the given regular expression. +Checks that the current URL (path) matches the given regular expression. {% highlight php %} <?php -// to match root url -$I->seeCurrentUrlMatches('~^/users/(\d+)~'); +$I->seeCurrentUrlMatches('~^/users/\d+$~'); + +{% endhighlight %} + + +#### seeDefaultLocaleIs + +* `param string` $expectedLocale The expected default locale +* `return void` + +Asserts that the default locale is the expected one. + +{% highlight php %} + +<?php +$I->seeDefaultLocaleIs('en'); {% endhighlight %} @@ -1665,8 +2715,12 @@ $I->seeElement(['css' => 'form input'], ['name' => 'login']); Checks if the given number of emails was sent (default `$expectedCount`: 1). The check is based on `\Symfony\Component\Mailer\EventListener\MessageLoggerListener`, which means: -If your app performs a HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first. -Starting with version 2.0.0, `codeception/module-symfony` requires your app to use [Symfony Mailer](https://symfony.com/doc/current/mailer.html). If your app still uses [Swift Mailer](https://symfony.com/doc/current/email.html), set your version constraint to `^1.6`. +If your app performs an HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](#stopFollowingRedirects) first. + +Limitation: +If your mail is sent in a Symfony console command and you start that command in your test with [$I->runShellCommand()](https://codeception.com/docs/modules/Cli#runShellCommand), +Codeception will not notice it. +As a more professional alternative, we recommend Mailpit (see [Addons](https://codeception.com/addons)), which also lets you test the content of the mail. {% highlight php %} @@ -1676,9 +2730,45 @@ $I->seeEmailIsSent(2); {% endhighlight %} +#### seeEvent + +* `param class-string|list<class-string>` $expected Fully-qualified class-name(s) of the expected event(s). +* `return void` + +Verifies that at least one of the given events **was** dispatched (regular **or** orphan). + +{% highlight php %} + +<?php +$I->seeEvent('App\MyEvent'); +$I->seeEvent(['App\MyEvent', 'App\MyOtherEvent']); + +{% endhighlight %} + + +#### seeEventListenerIsCalled + +* `param class-string|object|list<class-string|object>` $expected Listeners (class-strings or object instances). +* `param string|list<string>` $events Event name(s) (empty = any). +* `return void` + +Verifies that one or more **listeners** were called during the test. + +{% highlight php %} + +<?php +$I->seeEventListenerIsCalled('App\MyEventListener'); +$I->seeEventListenerIsCalled(['App\MyEventListener', 'App\MyOtherEventListener']); +$I->seeEventListenerIsCalled('App\MyEventListener', 'my.event'); +$I->seeEventListenerIsCalled('App\MyEventListener', ['my.event', 'my.other.event']); + +{% endhighlight %} + + #### seeEventTriggered -* `param object|string|string[]` $expected +@deprecated +* `param class-string|object|list<class-string|object>` $expected * `return void` Verifies that one or more event listeners were called during the test. @@ -1693,10 +2783,40 @@ $I->seeEventTriggered(['App\MyEvent', 'App\MyOtherEvent']); {% endhighlight %} +#### seeFallbackLocalesAre + +* `param string[]` $expectedLocales The expected fallback locales +* `return void` + +Asserts that the fallback locales match the expected ones. + +{% highlight php %} + +<?php +$I->seeFallbackLocalesAre(['es', 'fr']); + +{% endhighlight %} + + +#### seeFallbackTranslationsCountLessThan + +* `param int` $limit Maximum count of fallback translations +* `return void` + +Asserts that the count of fallback translations is less than the given limit. + +{% highlight php %} + +<?php +$I->seeFallbackTranslationsCountLessThan(10); + +{% endhighlight %} + + #### seeFormErrorMessage * `param string` $field -* `param string|null` $message +* `param ?string` $message * `return void` Verifies that a form field has an error. @@ -1714,7 +2834,7 @@ $I->seeFormErrorMessage('username', 'Username is empty'); #### seeFormErrorMessages -* `param string[]` $expectedErrors +* `param array` $expectedErrors * `return void` Verifies that multiple fields on a form have errors. @@ -1732,7 +2852,6 @@ $I->seeFormErrorMessages(['telephone', 'address']); If you want to specify the error messages, you can do so by sending an associative array instead, with the key being the name of the field and the error message the value. - This method will validate that the expected error message is contained in the actual error message, that is, you can specify either the entire error message or just a part of it: @@ -1741,7 +2860,7 @@ you can specify either the entire error message or just a part of it: <?php $I->seeFormErrorMessages([ - 'address' => 'The address is too long' + 'address' => 'The address is too long', 'telephone' => 'too short', // the full error message is 'The telephone is too short' ]); @@ -1785,7 +2904,7 @@ $I->seeFormHasErrors(); Checks that current url matches route. -Unlike seeCurrentRouteIs, this can matches without exact route parameters +Unlike seeCurrentRouteIs, this can match without exact route parameters {% highlight php %} @@ -1897,9 +3016,9 @@ $form = [ 'checkbox1' => true, // ... ]; -$I->submitForm('//form[@id=my-form]', string $form, 'submitButton'); +$I->submitForm('//form[@id=my-form]', $form, 'submitButton'); // $I->amOnPage('/path/to/form-page') may be needed -$I->seeInFormFields('//form[@id=my-form]', string $form); +$I->seeInFormFields('//form[@id=my-form]', $form); {% endhighlight %} @@ -1971,14 +3090,47 @@ $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a> {% endhighlight %} +#### seeMissingTranslationsCountLessThan + +* `param int` $limit Maximum count of missing translations +* `return void` + +Asserts that the count of missing translations is less than the given limit. + +{% highlight php %} + +<?php +$I->seeMissingTranslationsCountLessThan(5); + +{% endhighlight %} + + +#### seeNotificationIsSent + +* `param int` $expectedCount The expected number of notifications sent +* `return void` + +Checks if the given number of notifications was sent (default `$expectedCount`: 1). + +The check is based on `\Symfony\Component\Notifier\EventListener\NotificationLoggerListener`, which means: +If your app performs an HTTP redirect after sending the notification, you need to suppress it using [stopFollowingRedirects()](#stopFollowingRedirects) first. + +{% highlight php %} + +<?php +$I->seeNotificatoinIsSent(2); + +{% endhighlight %} + + #### seeNumRecords -* `param int` $expectedNum Expected number of records -* `param string` $className A doctrine entity -* `param array` $criteria Optional query criteria +* `param int` $expectedNum Expected count +* `param class-string<object>` $className Entity class +* `param array` $criteria * `return void` -Checks that number of given records were found in database. +Asserts that a given number of records exists for the entity. 'id' is the default search parameter. @@ -2026,20 +3178,19 @@ $I->seeOptionIsSelected('#form input[name=payment]', 'Visa'); #### seeOrphanEvent -* `param object|string|string[]` $expected +* `param class-string|list<class-string>` $expected Event class-name(s) expected to be orphan. * `return void` -Verifies that one or more orphan events were dispatched during the test. +Verifies that one or more orphan events **were** dispatched during the test. An orphan event is an event that was triggered by manually executing the -[`dispatch()`](https://symfony.com/doc/current/components/event_dispatcher.html#dispatch-the-event) method -of the EventDispatcher but was not handled by any listener after it was dispatched. +{@link https://symfony.com/doc/current/components/event_dispatcher.html#dispatch-the-event dispatch()} +method of the EventDispatcher but was not handled by any listener after it was dispatched. {% highlight php %} <?php $I->seeOrphanEvent('App\MyEvent'); -$I->seeOrphanEvent(new App\Events\MyEvent()); $I->seeOrphanEvent(['App\MyEvent', 'App\MyOtherEvent']); {% endhighlight %} @@ -2047,12 +3198,12 @@ $I->seeOrphanEvent(['App\MyEvent', 'App\MyOtherEvent']); #### seePageIsAvailable -* `param string|null` $url +* `param string|null` $url The URL of the page to check. If null, the current page is checked. * `return void` Verifies that a page is available. -By default it checks the current page, specify the `$url` parameter to change it. +By default, it checks the current page. Specify the `$url` parameter to change the page being checked. {% highlight php %} @@ -2078,7 +3229,7 @@ Asserts that current page has 404 response status code. * `param string` $redirectsTo * `return void` -Goes to a page and check that it redirects to another. +Navigates to a page and verifies that it redirects to another page. {% highlight php %} @@ -2127,7 +3278,7 @@ $I->seeRenderedTemplate('layout.html.twig'); Asserts that the time a request lasted is less than expected. -If the page performed a HTTP redirect, only the time of the last request will be taken into account. +If the page performed an HTTP redirect, only the time of the last request will be taken into account. You can modify this behavior using [stopFollowingRedirects()](https://codeception.com/docs/modules/Symfony#stopFollowingRedirects) first. Also, note that using code coverage can significantly increase the time it takes to resolve a request, @@ -2245,7 +3396,7 @@ $I->seeUserHasRoles(['ROLE_USER', 'ROLE_ADMIN']); Checks that the user's password would not benefit from rehashing. -If the user is not provided it is taken from the current session. +If the user is not provided, it is taken from the current session. You might use this function after performing tasks like registering a user or submitting a password update form. @@ -2258,6 +3409,63 @@ $I->seeUserPasswordDoesNotNeedRehash($user); {% endhighlight %} +#### seeViolatedConstraint + +* `param object` $subject +* `param ?string` $propertyPath +* `param ?string` $constraint +* `return void` + +Asserts that the given subject passes validation. + +This assertion does not concern the exact number of violations. + +{% highlight php %} + +<?php +$I->seeViolatedConstraint($subject); +$I->seeViolatedConstraint($subject, 'propertyName'); +$I->seeViolatedConstraint($subject, 'propertyName', 'Symfony\Validator\ConstraintClass'); + +{% endhighlight %} + + +#### seeViolatedConstraintMessage + +* `param string` $expected +* `param object` $subject +* `param string` $propertyPath +* `return void` + +Asserts that a constraint violation message or a part of it is present in the subject's violations. + +{% highlight php %} + +<?php +$I->seeViolatedConstraintMessage('too short', $user, 'address'); + +{% endhighlight %} + + +#### seeViolatedConstraintsCount + +* `param int` $expected +* `param object` $subject +* `param ?string` $propertyPath +* `param ?string` $constraint +* `return void` + +Asserts the exact number of violations for the given subject. + +{% highlight php %} + +<?php +$I->seeViolatedConstraintsCount(3, $subject); +$I->seeViolatedConstraintsCount(2, $subject, 'propertyName'); + +{% endhighlight %} + + #### selectOption * `param ` $select @@ -2280,7 +3488,7 @@ Provide an array for the second argument to select multiple options: {% highlight php %} <?php -$I->selectOption('Which OS do you use?', array('Windows','Linux')); +$I->selectOption('Which OS do you use?', ['Windows', 'Linux']); {% endhighlight %} @@ -2289,8 +3497,8 @@ Or provide an associative array for the second argument to specifically define w {% highlight php %} <?php -$I->selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' -$I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' +$I->selectOption('Which OS do you use?', ['text' => 'Windows']); // Only search by text 'Windows' +$I->selectOption('Which OS do you use?', ['value' => 'windows']); // Only search by value 'windows' {% endhighlight %} @@ -2631,14 +3839,14 @@ $I->submitForm('#my-form', [ #### submitSymfonyForm -* `param string` $name The `name` attribute of the `<form>` (you cannot use an array as selector here) -* `param string[]` $fields +* `param string` $name The `name` attribute of the `<form>`. You cannot use an array as a selector here. +* `param array` $fields * `return void` -Submit a form specifying the form name only once. +Submits a form by specifying the form name only once. Use this function instead of [`$I->submitForm()`](#submitForm) to avoid repeating the form name in the field selectors. -If you customized the names of the field selectors use `$I->submitForm()` for full control. +If you have customized the names of the field selectors, use `$I->submitForm()` for full control. {% highlight php %} @@ -2697,4 +3905,25 @@ $I->uncheckOption('#notify'); Remove service $serviceName from the lists of persistent services. + +#### unsetHttpHeader + +* `param string` $name the name of the header to unset. +* `return void` + +Unsets a HTTP header (that was originally added by [haveHttpHeader()](#haveHttpHeader)), +so that subsequent requests will not send it anymore. + +Example: +{% highlight php %} + +<?php +$I->haveHttpHeader('X-Requested-With', 'Codeception'); +$I->amOnPage('test-headers.php'); +// ... +$I->unsetHeader('X-Requested-With'); +$I->amOnPage('some-other-page.php'); + +{% endhighlight %} + <p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/module-symfony/tree/master/src/Codeception/Module/Symfony.php">Help us to improve documentation. Edit module reference</a></div> diff --git a/docs/modules/WebDriver.md b/docs/modules/WebDriver.md index 9b8f3f6f5..1641febfd 100644 --- a/docs/modules/WebDriver.md +++ b/docs/modules/WebDriver.md @@ -10,24 +10,11 @@ title: WebDriver - Codeception - Documentation # WebDriver ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-webdriver {% endhighlight %} -Alternatively, you can enable `WebDriver` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -49,7 +36,7 @@ selenium-standalone start {% endhighlight %} -Update configuration in `acceptance.suite.yml`: +Update configuration in `Acceptance.suite.yml`: {% highlight yaml %} @@ -63,7 +50,7 @@ modules: ### Headless Chrome Browser -To enable headless mode (launch tests without showing a window) for Chrome browser using Selenium use this config in `acceptance.suite.yml`: +To enable headless mode (launch tests without showing a window) for Chrome browser using Selenium use this config in `Acceptance.suite.yml`: {% highlight yaml %} @@ -73,8 +60,8 @@ modules: url: 'http://localhost/' browser: chrome capabilities: - chromeOptions: - args: ["--headless", "--disable-gpu"] + goog:chromeOptions: + args: ["--headless"] {% endhighlight %} @@ -96,10 +83,10 @@ Tests can be executed directly through ChromeDriver or GeckoDriver (for Firefox) #### ChromeDriver -* Download and install [ChromeDriver](https://sites.google.com/chromium.org/driver/downloads?authuser=0) +* Download and install [ChromeDriver](https://sites.google.com/chromium.org/driver/downloads) * Launch ChromeDriver in a separate console window: `chromedriver --url-base=/wd/hub`. -Configuration in `acceptance.suite.yml`: +Configuration in `Acceptance.suite.yml`: {% highlight yaml %} @@ -111,13 +98,13 @@ modules: window_size: 2000x1000 port: 9515 capabilities: - chromeOptions: - args: ["--headless", "--disable-gpu"] # Run Chrome in headless mode + goog:chromeOptions: + args: ["--headless"] # Run Chrome in headless mode prefs: download.default_directory: "..." {% endhighlight %} -See here for additional [Chrome options](https://sites.google.com/a/chromium.org/chromedriver/capabilities) +See here for additional [Chrome options](https://sites.google.com/chromium.org/driver/capabilities) #### GeckoDriver @@ -125,7 +112,7 @@ See here for additional [Chrome options](https://sites.google.com/a/chromium.org * [GeckoDriver](https://github.com/mozilla/geckodriver/releases) must be installed * Start GeckoDriver in a separate console window: `geckodriver`. -Configuration in `acceptance.suite.yml`: +Configuration in `Acceptance.suite.yml`: {% highlight yaml %} @@ -156,7 +143,7 @@ you should use a tunnel application provided by a service. 1. Create an account at [SauceLabs.com](https://saucelabs.com/) to get your username and access key 2. In the module configuration use the format `username`:`access_key`@ondemand.saucelabs.com' for `host` -3. Configure `platform` under `capabilities` to define the [Operating System](https://docs.saucelabs.com/basics/platform-configurator/) +3. Configure `platformName` under `capabilities` to define the [Operating System](https://docs.saucelabs.com/basics/platform-configurator/) 4. run a tunnel app if your site can't be accessed from Internet {% highlight yaml %} @@ -169,7 +156,7 @@ you should use a tunnel application provided by a service. port: 80 browser: chrome capabilities: - platform: 'Windows 10' + platformName: 'Windows 10' {% endhighlight %} @@ -182,17 +169,18 @@ you should use a tunnel application provided by a service. {% highlight yaml %} - modules: - enabled: - - WebDriver: + modules: + enabled: + - WebDriver: url: http://mysite.com host: '<username>:<access key>@hub.browserstack.com' port: 80 browser: chrome capabilities: - os: Windows - os_version: 10 - browserstack.local: true # for local testing + bstack:options: + os: Windows + osVersion: 10 + local: true # for local testing {% endhighlight %} @@ -205,19 +193,19 @@ you should use a tunnel application provided by a service. {% highlight yaml %} - modules: - enabled: - - WebDriver: - url: "https://openclassrooms.com" - host: 'hub.lambdatest.com' - port: 80 - browser: 'Chrome' - capabilities: - LT:Options: - platformName: 'Windows 10' - browserVersion: 'latest-5' - browserName: 'Chrome' - tunnel: true #for Local testing + modules: + enabled: + - WebDriver: + url: "https://openclassrooms.com" + host: 'hub.lambdatest.com' + port: 80 + browser: 'Chrome' + capabilities: + LT:Options: + platformName: 'Windows 10' + browserVersion: 'latest-5' + browserName: 'Chrome' + tunnel: true #for Local testing {% endhighlight %} @@ -225,20 +213,20 @@ you should use a tunnel application provided by a service. 1. Create an account at [TestingBot](https://testingbot.com/) to get your key and secret 2. In the module configuration use the format `key`:`secret`@hub.testingbot.com' for `host` -3. Configure `platform` under `capabilities` to define the [Operating System](https://testingbot.com/support/getting-started/browsers.html) +3. Configure `platformName` under `capabilities` to define the [Operating System](https://testingbot.com/support/getting-started/browsers.html) 4. Run [TestingBot Tunnel](https://testingbot.com/support/other/tunnel) if your site can't be accessed from Internet {% highlight yaml %} - modules: - enabled: - - WebDriver: - url: http://mysite.com - host: '<key>:<secret>@hub.testingbot.com' - port: 80 - browser: chrome - capabilities: - platform: Windows 10 +modules: + enabled: + - WebDriver: + url: http://mysite.com + host: '<key>:<secret>@hub.testingbot.com' + port: 80 + browser: chrome + capabilities: + platformName: Windows 10 {% endhighlight %} @@ -262,23 +250,24 @@ you should use a tunnel application provided by a service. * `ssl_proxy` - sets ssl(https) proxy server url for testing a remote server. * `ssl_proxy_port` - sets ssl(https) proxy server port * `debug_log_entries` - how many selenium entries to print with `debugWebDriverLogs` or on fail (0 by default). -* `log_js_errors` - Set to true to include possible JavaScript to HTML report, or set to false (default) to deactivate. +* `log_js_errors` - Set to true to include possible JavaScript to HTML report, or set to false (default) to deactivate. This will only work if `debug_log_entries` is set and its value is > 0. Also this will display JS errors as comments only if test fails. * `webdriver_proxy` - sets http proxy to tunnel requests to the remote Selenium WebDriver through * `webdriver_proxy_port` - sets http proxy server port to tunnel requests to the remote Selenium WebDriver through -Example (`acceptance.suite.yml`) +Example (`Acceptance.suite.yml`) {% highlight yaml %} - modules: - enabled: - - WebDriver: - url: 'http://localhost/' - browser: firefox - window_size: 1024x768 - capabilities: - unexpectedAlertBehaviour: 'accept' - firefox_profile: '~/firefox-profiles/codeception-profile.zip.b64' +modules: + enabled: + - WebDriver: + url: 'http://localhost/' + browser: firefox + window_size: 1024x768 + capabilities: + unhandledPromptBehaviour: 'accept' + moz:firefoxOptions: + profile: '~/firefox-profiles/codeception-profile.zip.b64' {% endhighlight %} @@ -352,7 +341,8 @@ If speed is a concern, it's recommended you stick with explicitly specifying the You can inject `\Codeception\Scenario` into your test to get information about the current configuration: {% highlight php %} -use Codeception\Scenario +use Codeception\Scenario; + public function myTest(AcceptanceTester $I, Scenario $scenario) { if ('firefox' === $scenario->current('browser')) { @@ -429,7 +419,8 @@ This is how it can be done via `_capabilities` method from `Helper\Acceptance`: {% highlight php %} -<?php // inside Helper\Acceptance +<?php +// inside Helper\Acceptance public function _before(TestInterface $test) { $name = $test->getMetadata()->getName(); @@ -951,7 +942,7 @@ You can set additional cookie params like `domain`, `path` as array passed in la * `param string` $uri * `return void` -Checks that the current URL doesn't equal the given string. +Checks that the current URL (path) doesn't equal the given string. Unlike `dontSeeInCurrentUrl`, this only matches the full URL. @@ -969,13 +960,13 @@ $I->dontSeeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that current url doesn't match the given regular expression. +Checks that current URL (path) doesn't match the given regular expression. {% highlight php %} <?php // to match root url -$I->dontSeeCurrentUrlMatches('~^/users/(\d+)~'); +$I->dontSeeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -1015,7 +1006,7 @@ Opposite of `seeElementInDOM`. * `param string` $uri * `return void` -Checks that the current URI doesn't contain the given string. +Checks that the current URI (path) doesn't contain the given string. {% highlight php %} @@ -1249,17 +1240,14 @@ If Codeception lacks a feature you need, please implement it and submit a patch. * `param array` $arguments * `return mixed` -Executes custom JavaScript. - -This example uses jQuery to get a value and assigns that value to a PHP variable: +Executes JavaScript commands. {% highlight php %} <?php -$myVar = $I->executeJS('return $("#myField").val()'); +$myVar = $I->executeJS('return document.getElementById("myField").value'); -// additional arguments can be passed as array -// Example shows `Hello World` alert: +// Additional arguments can be passed as array. E.g. this will alert `Hello World`: $I->executeJS("window.alert(arguments[0])", ['Hello world']); {% endhighlight %} @@ -1288,9 +1276,9 @@ $I->fillField(['name' => 'email'], 'jon@example.com'); * `param ` $attribute * `return ?string` -Grabs the value of the given attribute value from the given element. +Returns the value of the given attribute value from the given HTML element. For some attributes, the string `true` is returned instead of their literal value (e.g. `disabled="disabled"` or `required="required"`). -Fails if element is not found. +Fails if the element is not found. Returns `null` if the attribute is not present on the element. {% highlight php %} @@ -1543,7 +1531,7 @@ The tab is opened with JavaScript's `window.open()`, which means: #### performOn * `param string|array|WebDriverBy` $element -* `param callable|array|ActionSequence` $actions +* `param callable|array|\Codeception\Util\ActionSequence` $actions * `param int` $timeout * `return void` @@ -1596,25 +1584,25 @@ In 3rd argument you can set number a seconds to wait for element to appear #### pressKey * `param string|array|WebDriverBy` $element -* `param ` $chars +* `param string|list<string>` $chars Can be char or array with modifier. You can provide several chars. * `throws ElementNotFound` * `return void` Presses the given key on the given element. -To specify a character and modifier (e.g. <kbd>Ctrl</kbd>, Alt, Shift, Meta), pass an array for `$char` with +To specify a character and modifier (e.g. <kbd>Ctrl</kbd>, <kbd>Alt</kbd>, <kbd>Shift</kbd>, <kbd>Meta</kbd>), pass an array for `$char` with the modifier as the first element and the character as the second. -For special keys, use the constants from [`Facebook\WebDriver\WebDriverKeys`](https://github.com/php-webdriver/php-webdriver/blob/main/lib/WebDriverKeys.php). +For special keys, use the constants from [Facebook\WebDriver\WebDriverKeys](https://github.com/php-webdriver/php-webdriver/blob/main/lib/WebDriverKeys.php). {% highlight php %} <?php -// <input id="page" value="old" /> -$I->pressKey('#page','a'); // => olda -$I->pressKey('#page',array('ctrl','a'),'new'); //=> new -$I->pressKey('#page',array('shift','111'),'1','x'); //=> old!!!1x -$I->pressKey('descendant-or-self::*[@id='page']','u'); //=> oldu -$I->pressKey('#name', array('ctrl', 'a'), \Facebook\WebDriver\WebDriverKeys::DELETE); //=>'' +// <input id="page" value="old"> +$I->pressKey('#page', 'a'); // => olda +$I->pressKey('#page', ['ctrl', 'a'],'new'); // => new +$I->pressKey('#page', ['shift', '111'], '1', 'x'); // => old!!!1x +$I->pressKey('descendant-or-self::*[@id='page']', 'u'); // => oldu +$I->pressKey('#name', ['ctrl', 'a'], \Facebook\WebDriver\WebDriverKeys::DELETE); // =>'' {% endhighlight %} @@ -1623,7 +1611,7 @@ $I->pressKey('#name', array('ctrl', 'a'), \Facebook\WebDriver\WebDriverKeys::DEL * `return void` -Reloads the current page. +Reloads the current page. All forms will be reset, so the outcome is as if the user would press <kbd>Ctrl</kbd>+<kbd>F5</kbd>. #### resetCookie @@ -1786,14 +1774,12 @@ $I->seeCookie('PHPSESSID'); * `param string` $uri * `return void` -Checks that the current URL is equal to the given string. - -Unlike `seeInCurrentUrl`, this only matches the full URL. +Checks that the current URL (path) is equal to the given string. {% highlight php %} <?php -// to match root url +// to match the home page $I->seeCurrentUrlEquals('/'); {% endhighlight %} @@ -1804,13 +1790,12 @@ $I->seeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that the current URL matches the given regular expression. +Checks that the current URL (path) matches the given regular expression. {% highlight php %} <?php -// to match root url -$I->seeCurrentUrlMatches('~^/users/(\d+)~'); +$I->seeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -1958,9 +1943,9 @@ $form = [ 'checkbox1' => true, // ... ]; -$I->submitForm('//form[@id=my-form]', string $form, 'submitButton'); +$I->submitForm('//form[@id=my-form]', $form, 'submitButton'); // $I->amOnPage('/path/to/form-page') may be needed -$I->seeInFormFields('//form[@id=my-form]', string $form); +$I->seeInFormFields('//form[@id=my-form]', $form); {% endhighlight %} @@ -2117,7 +2102,7 @@ Provide an array for the second argument to select multiple options: {% highlight php %} <?php -$I->selectOption('Which OS do you use?', array('Windows','Linux')); +$I->selectOption('Which OS do you use?', ['Windows', 'Linux']); {% endhighlight %} @@ -2126,8 +2111,8 @@ Or provide an associative array for the second argument to specifically define w {% highlight php %} <?php -$I->selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' -$I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' +$I->selectOption('Which OS do you use?', ['text' => 'Windows']); // Only search by text 'Windows' +$I->selectOption('Which OS do you use?', ['value' => 'windows']); // Only search by value 'windows' {% endhighlight %} @@ -2196,17 +2181,17 @@ For example, given this sample "Sign Up" form: <form action="/sign_up"> Login: - <input type="text" name="user[login]" /><br/> + <input type="text" name="user[login]"><br> Password: - <input type="password" name="user[password]" /><br/> + <input type="password" name="user[password]"><br> Do you agree to our terms? - <input type="checkbox" name="user[agree]" /><br/> + <input type="checkbox" name="user[agree]"><br> Select pricing plan: <select name="plan"> <option value="1">Free</option> <option value="2" selected="selected">Paid</option> </select> - <input type="submit" name="submitButton" value="Submit" /> + <input type="submit" name="submitButton" value="Submit"> </form> {% endhighlight %} @@ -2320,7 +2305,7 @@ For example, given the following HTML: {% highlight html %} -<input type="submit" name="submitButton" value="Submit" /> +<input type="submit" name="submitButton" value="Submit"> {% endhighlight %} @@ -2569,7 +2554,7 @@ $I->click('#agree_button'); * `throws ElementNotFound` * `return void` -Waits up to $timeout seconds for the given element to change. +Waits up to `$timeout` seconds for the given element to change. Element "change" is determined by a callback function which is called repeatedly until the return value evaluates to true. @@ -2577,10 +2562,11 @@ until the return value evaluates to true. {% highlight php %} <?php -use \Facebook\WebDriver\WebDriverElement -$I->waitForElementChange('#menu', function(WebDriverElement $el) { - return $el->isDisplayed(); -}, 100); +use Facebook\WebDriver\WebDriverElement; + +$I->waitForElementChange('#menu', function(WebDriverElement $element) { + return $element->isDisplayed(); +}, 5); {% endhighlight %} diff --git a/docs/modules/Yii2.md b/docs/modules/Yii2.md index 66b2818e8..b2a0daea7 100644 --- a/docs/modules/Yii2.md +++ b/docs/modules/Yii2.md @@ -10,24 +10,11 @@ title: Yii2 - Codeception - Documentation # Yii2 ### Installation -If you use Codeception installed using composer, install this module with the following command: - {% highlight yaml %} composer require --dev codeception/module-yii2 {% endhighlight %} -Alternatively, you can enable `Yii2` module in suite configuration file and run - -{% highlight yaml %} -codecept init upgrade4 - -{% endhighlight %} - -This module was bundled with Codeception 2 and 3, but since version 4 it is necessary to install it separately. -Some modules are bundled with PHAR files. -Warning. Using PHAR file and composer in the same project can cause unexpected errors. - ### Description @@ -173,8 +160,8 @@ commands that expect a URL: {% highlight php %} <?php -$I->amOnPage('index-test.php?site/index'); -$I->amOnPage('http://localhost/index-test.php?site/index'); +$I->amOnPage('index-test.php?r=site/index'); +$I->amOnPage('http://localhost/index-test.php?r=site/index'); $I->sendAjaxPostRequest(['/user/update', 'id' => 1], ['UserForm[name]' => 'G.Hopper']); {% endhighlight %} @@ -184,7 +171,6 @@ $I->sendAjaxPostRequest(['/user/update', 'id' => 1], ['UserForm[name]' => 'G.Hop Maintainer: **samdark** Stability: **stable** -@property \Codeception\Lib\Connector\Yii2 $client ### Actions @@ -333,8 +319,9 @@ Authenticates user for HTTP_AUTH #### amLoggedInAs -* `param ` $user +* `param \yii\web\IdentityInterface|string|int` $user * `throws \Codeception\Exception\ModuleException` +* `return void` Authenticates a user on a site without submitting a login form. @@ -356,10 +343,10 @@ Requires the `user` component to be enabled and configured. #### amOnPage -* `param string|array` $page the URI or route in array format +* `param string` $page * `return void` -Opens the page for the given relative URI or route. +Opens the page for the given relative URI. {% highlight php %} @@ -464,24 +451,10 @@ Creates the CSRF Cookie. #### deleteHeader -* `param string` $name the name of the header to delete. +@deprecated +* `param string` $name * `return void` -Deletes the header with the passed name. Subsequent requests -will not have the deleted header in its request. - -Example: -{% highlight php %} - -<?php -$I->haveHttpHeader('X-Requested-With', 'Codeception'); -$I->amOnPage('test-headers.php'); -// ... -$I->deleteHeader('X-Requested-With'); -$I->amOnPage('some-other-page.php'); - -{% endhighlight %} - #### dontSee @@ -550,7 +523,7 @@ You can set additional cookie params like `domain`, `path` as array passed in la * `param string` $uri * `return void` -Checks that the current URL doesn't equal the given string. +Checks that the current URL (path) doesn't equal the given string. Unlike `dontSeeInCurrentUrl`, this only matches the full URL. @@ -568,13 +541,13 @@ $I->dontSeeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that current url doesn't match the given regular expression. +Checks that current URL (path) doesn't match the given regular expression. {% highlight php %} <?php // to match root url -$I->dontSeeCurrentUrlMatches('~^/users/(\d+)~'); +$I->dontSeeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -613,7 +586,7 @@ Checks that no email was sent * `param string` $uri * `return void` -Checks that the current URI doesn't contain the given string. +Checks that the current URI (path) doesn't contain the given string. {% highlight php %} @@ -755,7 +728,7 @@ $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); #### dontSeeRecord * `part` orm -* `param ` $model +* `param class-string<\yii\db\ActiveRecord>` $model * `param array` $attributes * `return void` @@ -830,9 +803,9 @@ Returns a list of regex patterns for recognized domain names * `param string` $attribute * `return mixed` -Grabs the value of the given attribute value from the given element. +Returns the value of the given attribute value from the given HTML element. For some attributes, the string `true` is returned instead of their literal value (e.g. `disabled="disabled"` or `required="required"`). -Fails if element is not found. +Fails if the element is not found. Returns `null` if the attribute is not present on the element. {% highlight php %} @@ -845,9 +818,9 @@ $I->grabAttributeFrom('#tooltip', 'title'); #### grabComponent @deprecated -* `param ` $component +* `param string` $component * `throws \Codeception\Exception\ModuleException` -* `return mixed` +* `return ?object` Gets a component from the Yii container. Throws an exception if the component is not available @@ -975,7 +948,7 @@ $aLinks = $I->grabMultiple('a', 'href'); #### grabPageSource -* `throws ModuleException` if no page was opened. +* `throws \Codeception\Exception\ModuleException` if no page was opened. * `return string` Current page source code. Grabs current page source code. @@ -984,9 +957,9 @@ Grabs current page source code. #### grabRecord * `part` orm -* `param ` $model +* `param class-string<\yii\db\ActiveRecord>` $model * `param array` $attributes -* `return mixed` +* `return \yii\db\ActiveRecord|array|null` Retrieves a record from the database @@ -1062,6 +1035,7 @@ $name = $I->grabValueFrom(['name' => 'username']); * `part` fixtures * `param ` $fixtures +* `return void` Creates and loads fixtures from a config. @@ -1135,9 +1109,10 @@ $I->haveHttpHeader('Client_Id', 'Codeception'); #### haveRecord +* `template` T of \yii\db\ActiveRecord * `part` orm -* `param ` $model -* `param array` $attributes +* `param class-string<T>` $model +* `param ` $attributes * `return mixed` Inserts a record into the database. @@ -1279,14 +1254,12 @@ $I->seeCookie('PHPSESSID'); * `param string` $uri * `return void` -Checks that the current URL is equal to the given string. - -Unlike `seeInCurrentUrl`, this only matches the full URL. +Checks that the current URL (path) is equal to the given string. {% highlight php %} <?php -// to match root url +// to match the home page $I->seeCurrentUrlEquals('/'); {% endhighlight %} @@ -1297,13 +1270,12 @@ $I->seeCurrentUrlEquals('/'); * `param string` $uri * `return void` -Checks that the current URL matches the given regular expression. +Checks that the current URL (path) matches the given regular expression. {% highlight php %} <?php -// to match root url -$I->seeCurrentUrlMatches('~^/users/(\d+)~'); +$I->seeCurrentUrlMatches('~^/users/\d+$~'); {% endhighlight %} @@ -1336,7 +1308,7 @@ $I->seeElement(['css' => 'form input'], ['name' => 'login']); #### seeEmailIsSent * `part` email -* `param int` $num +* `param int|null` $num * `throws \Codeception\Exception\ModuleException` * `return void` @@ -1456,9 +1428,9 @@ $form = [ 'checkbox1' => true, // ... ]; -$I->submitForm('//form[@id=my-form]', string $form, 'submitButton'); +$I->submitForm('//form[@id=my-form]', $form, 'submitButton'); // $I->amOnPage('/path/to/form-page') may be needed -$I->seeInFormFields('//form[@id=my-form]', string $form); +$I->seeInFormFields('//form[@id=my-form]', $form); {% endhighlight %} @@ -1556,7 +1528,7 @@ Asserts that current page has 404 response status code. #### seeRecord * `part` orm -* `param ` $model +* `param class-string<\yii\db\ActiveRecord>` $model * `param array` $attributes * `return void` @@ -1646,7 +1618,7 @@ Provide an array for the second argument to select multiple options: {% highlight php %} <?php -$I->selectOption('Which OS do you use?', array('Windows','Linux')); +$I->selectOption('Which OS do you use?', ['Windows', 'Linux']); {% endhighlight %} @@ -1655,8 +1627,8 @@ Or provide an associative array for the second argument to specifically define w {% highlight php %} <?php -$I->selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' -$I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' +$I->selectOption('Which OS do you use?', ['text' => 'Windows']); // Only search by text 'Windows' +$I->selectOption('Which OS do you use?', ['value' => 'windows']); // Only search by value 'windows' {% endhighlight %} @@ -2022,4 +1994,25 @@ $I->uncheckOption('#notify'); {% endhighlight %} + +#### unsetHttpHeader + +* `param string` $name the name of the header to unset. +* `return void` + +Unsets a HTTP header (that was originally added by [haveHttpHeader()](#haveHttpHeader)), +so that subsequent requests will not send it anymore. + +Example: +{% highlight php %} + +<?php +$I->haveHttpHeader('X-Requested-With', 'Codeception'); +$I->amOnPage('test-headers.php'); +// ... +$I->unsetHeader('X-Requested-With'); +$I->amOnPage('some-other-page.php'); + +{% endhighlight %} + <p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/module-yii2/tree/master/src/Codeception/Module/Yii2.php">Help us to improve documentation. Edit module reference</a></div> diff --git a/docs/reference/Autoload.md b/docs/reference/Autoload.md index d9b36665c..3eb14f02a 100644 --- a/docs/reference/Autoload.md +++ b/docs/reference/Autoload.md @@ -40,7 +40,7 @@ Autoload::addNamespace('app\Codeception', '/path/to/controllers'); {% endhighlight %} -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Util/Autoload.php#L53) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Util/Autoload.php#L57) #### load() @@ -50,6 +50,6 @@ Autoload::addNamespace('app\Codeception', '/path/to/controllers'); * `param string` $class * `return string|false` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Util/Autoload.php#L80) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Util/Autoload.php#L75) -<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Util/Autoload.php">Help us to improve documentation. Edit module reference</a></div> +<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/main/src/Codeception/Util/Autoload.php">Help us to improve documentation. Edit module reference</a></div> diff --git a/docs/reference/Commands.md b/docs/reference/Commands.md index cb7925b01..5960d3e42 100644 --- a/docs/reference/Commands.md +++ b/docs/reference/Commands.md @@ -5,6 +5,25 @@ title: Commands - Codeception - Documentation # Console Commands +## 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` + + + + +## 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. + + + ## GherkinSnippets Generates code snippets for matched feature files in a suite. @@ -12,10 +31,22 @@ 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 +* `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 + + + +## GenerateSnapshot + +Generates Snapshot. +Snapshot can be used to test dynamical data. +If suite name is provided, an actor class will be included into placeholder + +* `codecept g:snapshot UserEmails` +* `codecept g:snapshot Products` +* `codecept g:snapshot Acceptance UserEmails` @@ -30,86 +61,70 @@ Generates Feature file (in Gherkin): -## GenerateEnvironment - -Generates empty environment configuration file into envs dir: - - * `codecept g:env firefox` - -Required to have `envs` path to be specified in `codeception.yml` +## GherkinSteps +Prints all steps from all Gherkin contexts for a specific suite +{% highlight yaml %} +codecept gherkin:steps Acceptance -## GenerateTest +{% endhighlight %} -Generates skeleton for Unit Test that extends `Codeception\TestCase\Test`. -* `codecept g:test unit User` -* `codecept g:test unit "App\User"` +## CompletionFallback -## GenerateSnapshot -Generates Snapshot. -Snapshot can be used to test dynamical data. -If suite name is provided, an actor class will be included into placeholder - -* `codecept g:snapshot UserEmails` -* `codecept g:snapshot Products` -* `codecept g:snapshot acceptance UserEmails` +## 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 -## Init -## ConfigValidate +## GenerateHelper -Validates and prints Codeception config. -Use it do debug Yaml configs +Creates empty Helper class. -Check config: +* `codecept g:helper MyHelper` +* `codecept g:helper "My\Helper"` -* `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) +## GenerateEnvironment -* `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 +Generates empty environment configuration file into envs dir: + * `codecept g:env firefox` +Required to have `envs` path to be specified in `codeception.yml` -## Bootstrap -Creates default config, tests directory and sample suites for current project. -Use this command to start building a test suite. +## DryRun -By default it will create 3 suites **acceptance**, **functional**, and **unit**. +Shows step-by-step execution process for scenario driven tests without actually running them. -* `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 +* `codecept dry-run Acceptance` +* `codecept dry-run Acceptance MyCest` +* `codecept dry-run Acceptance checkout.feature` +* `codecept dry-run tests/Acceptance/MyCest.php` -## GenerateGroup +## GenerateScenarios -Creates empty GroupObject - extension which handles all group events. +Generates user-friendly text scenarios from scenario-driven tests (Cest). -* `codecept g:group Admin` +* `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 @@ -119,16 +134,16 @@ Executes tests. Usage: -* `codecept run acceptance`: run all acceptance tests -* `codecept run tests/acceptance/MyCest.php`: run only MyCest -* `codecept run acceptance MyCest`: same as above -* `codecept run acceptance MyCest:myTestInIt`: run one test from a Cest -* `codecept run acceptance MyCest:myTestInIt#1`: run one example or data provider item by number -* `codecept run acceptance MyCest:myTestInIt#1-3`: run a range of examples or data provider items -* `codecept run acceptance MyCest:myTestInIt@name.*`: run data provider items with matching names -* `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 +* `codecept run Acceptance`: run all acceptance tests +* `codecept run tests/Acceptance/MyCest.php`: run only MyCest +* `codecept run Acceptance MyCest`: same as above +* `codecept run Acceptance MyCest:myTestInIt`: run one test from a Cest +* `codecept run Acceptance MyCest:myTestInIt#1`: run one example or data provider item by number +* `codecept run Acceptance MyCest:myTestInIt#1-3`: run a range of examples or data provider items +* `codecept run Acceptance MyCest:myTestInIt@name.*`: run data provider items with matching names +* `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: @@ -154,6 +169,10 @@ Run with specific extension * `codecept run --ext DotReporter` run with DotReporter printer * `codecept run --ext "My\Custom\Extension"` run with an extension loaded by class name +Re-Run failed tests + +* `codecept run -g failed` + Full reference: {% highlight yaml %} Arguments: @@ -162,65 +181,66 @@ Arguments: 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") - --phpunit-xml Generate PhpUnit XML Log (default: "phpunit-report.xml") - --no-redirect Do not redirect to Composer-installed version in vendor/codeception - --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. Almost the same as `--quiet` - --steps Show steps in output - --debug (-d) Alias for `-vv` - --bootstrap Execute bootstrap script before the test - --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") - --coverage-cobertura Generate CodeCoverage Cobertura report in file (default: "coverage-cobertura") - --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 nth failure (defaults to 1) - --no-rebuild Do not rebuild actor classes on start - --help (-h) Display this help message. - --quiet (-q) Do not output any message. Almost the same as `--silent` - --verbose (-v|vv|vvv) Increase the verbosity of messages: `v` for normal output, `vv` for steps and debug, `vvv` for Codeception-internal 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. - --seed Use the given seed for shuffling tests + --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") + --phpunit-xml Generate PhpUnit XML Log (default: "phpunit-report.xml") + --no-redirect Do not redirect to Composer-installed version in vendor/codeception + --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. Almost the same as `--quiet` + --steps Show steps in output + --debug (-d) Alias for `-vv` + --bootstrap Execute bootstrap script before the test + --coverage Run with code coverage (default: "coverage.serialized") + --disable-coverage-php Don't generate CodeCoverage report in raw PHP serialized format + --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") + --coverage-cobertura Generate CodeCoverage Cobertura report in file (default: "coverage-cobertura") + --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 nth failure (defaults to 1) + --no-rebuild Do not rebuild actor classes on start + --help (-h) Display this help message. + --quiet (-q) Do not output any message. Almost the same as `--silent` + --verbose (-v|vv|vvv) Increase the verbosity of messages: `v` for normal output, `vv` for steps and debug, `vvv` for Codeception-internal 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. + --seed Use the given seed for shuffling tests {% endhighlight %} -## GenerateSuite - -Create new test suite. Requires suite name and actor name +## ConfigValidate -* `` -* `codecept g:suite api` -> api + ApiTester -* `codecept g:suite integration Code` -> integration + CodeTester -* `codecept g:suite frontend Front` -> frontend + FrontTester +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: -## GenerateCest +* `codecept config:validate -c path/to/another/config`: from another dir +* `codecept config:validate -c another_config.yml`: from another config file -Generates Cest (scenario-driven object-oriented test) file: +Check overriding config values (like in `run` command) -* `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"` +* `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 @@ -232,35 +252,35 @@ If PageObject is generated globally it will act as UIMap, without any logic in i * `codecept g:page Login` * `codecept g:page Registration` -* `codecept g:page acceptance Login` - +* `codecept g:page Acceptance Login` -## Clean - -Recursively cleans `output` directory and generated code. - -* `codecept clean` +## GenerateGroup +Creates empty GroupObject - extension which handles all group events. +* `codecept g:group Admin` -## 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 -## 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. +## Init @@ -274,61 +294,44 @@ Auto-updates phar archive from official site: 'https://codeception.com/codecept. -## CompletionFallback - - - -## 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` - - - - -## DryRun - -Shows step by step execution process for scenario driven tests without actually running them. +## GenerateTest -* `codecept dry-run acceptance` -* `codecept dry-run acceptance MyCest` -* `codecept dry-run acceptance checkout.feature` -* `codecept dry-run tests/acceptance/MyCest.php` +Generates skeleton for Unit Test that extends `Codeception\TestCase\Test`. +* `codecept g:test Unit User` +* `codecept g:test Unit "App\User"` -## GenerateScenarios +## GenerateCest -Generates user-friendly text scenarios from scenario-driven tests (Cest). +Generates Cest (scenario-driven object-oriented test) file: -* `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 +* `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"` -## GenerateStepObject -Generates StepObject class. You will be asked for steps you want to implement. +## GenerateSuite -* `codecept g:stepobject acceptance AdminSteps` -* `codecept g:stepobject acceptance UserSteps --silent` - skip action questions +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 -## GherkinSteps -Prints all steps from all Gherkin contexts for a specific suite +## Clean -{% highlight yaml %} -codecept gherkin:steps acceptance +Recursively cleans `output` directory and generated code. -{% endhighlight %} +* `codecept clean` diff --git a/docs/reference/Configuration.md b/docs/reference/Configuration.md index ce366e19f..109cbd98f 100644 --- a/docs/reference/Configuration.md +++ b/docs/reference/Configuration.md @@ -48,7 +48,7 @@ modules: dsn: '' user: '' password: '' - dump: tests/_data/dump.sql + dump: tests/Support/Data/dump.sql {% endhighlight %} ### `namespace` @@ -65,11 +65,11 @@ Directories used by Codeception. Default values: {% highlight yaml %} paths: - tests : tests # where the tests stored - data : tests/_data # directory for fixture data - support: tests/_support # directory for support code - output : tests/_output # directory for output - envs : tests/_envs # directory for environment configuration + tests : tests # where the tests stored + data : tests/Support/Data # directory for fixture data + support: tests/Support # directory for support code + output : tests/_output # directory for output + envs : tests/_envs # directory for environment configuration {% endhighlight %} ### `reporters` @@ -105,7 +105,7 @@ Possible settings: * `shuffle: true`: Randomize test order * `strict_xml: false`: Generate XML JUnit report using strict schema. Avoid putting additional report fields like steps or scenario names to it. Required for XML reports on Jenkins CI -## Suite Configuration: `unit.suite.yml`, `functional.suite.yml` etc. +## Suite Configuration: `Unit.suite.yml`, `Functional.suite.yml` etc. Each suite has its own configuration inside the directory set by `paths: tests: ` in `codeception.yml`. Alphabetical list of options: @@ -178,12 +178,12 @@ Default namespace for new tests of this suite (ignores `namespace` option) 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. +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` +3. `Acceptance.suite.dist.yml` +4. `Acceptance.suite.yml` 5. environment config diff --git a/docs/reference/Fixtures.md b/docs/reference/Fixtures.md index 3f935dc9b..ceae62404 100644 --- a/docs/reference/Fixtures.md +++ b/docs/reference/Fixtures.md @@ -29,7 +29,7 @@ Fixtures::exists('user1'); * `param ` $data * `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Util/Fixtures.php#L23) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Util/Fixtures.php#L23) #### cleanup() @@ -39,7 +39,7 @@ Fixtures::exists('user1'); * `param string` $name * `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Util/Fixtures.php#L37) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Util/Fixtures.php#L37) #### exists() @@ -49,7 +49,7 @@ Fixtures::exists('user1'); * `param string` $name * `return bool` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Util/Fixtures.php#L47) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Util/Fixtures.php#L47) #### get() @@ -58,6 +58,6 @@ Fixtures::exists('user1'); * `param string` $name -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Util/Fixtures.php#L28) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Util/Fixtures.php#L28) -<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Util/Fixtures.php">Help us to improve documentation. Edit module reference</a></div> +<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/main/src/Codeception/Util/Fixtures.php">Help us to improve documentation. Edit module reference</a></div> diff --git a/docs/reference/Functions.md b/docs/reference/Functions.md index 490311c68..c0b212b2c 100644 --- a/docs/reference/Functions.md +++ b/docs/reference/Functions.md @@ -21,4 +21,4 @@ Returns absolute path to the root directory (where `codeception.yml` is located) #### codecept_data_dir() -Returns absolute path to data directory (`tests/_data`) \ No newline at end of file +Returns absolute path to data directory (`tests/Support/Data`) \ No newline at end of file diff --git a/docs/reference/HttpCode.md b/docs/reference/HttpCode.md index e015c371a..337b1aefb 100644 --- a/docs/reference/HttpCode.md +++ b/docs/reference/HttpCode.md @@ -16,7 +16,7 @@ Usage: {% highlight php %} <?php -use \Codeception\Util\HttpCode; +use Codeception\Util\HttpCode; // using REST, PhpBrowser, or any Framework module $I->seeResponseCodeIs(HttpCode::OK); diff --git a/docs/reference/InitTemplate.md b/docs/reference/InitTemplate.md index 3f68aad7e..2b813a9bc 100644 --- a/docs/reference/InitTemplate.md +++ b/docs/reference/InitTemplate.md @@ -38,7 +38,7 @@ This class provides various helper methods for building customized setup * `param \Symfony\Component\Console\Input\InputInterface` $input * `param \Symfony\Component\Console\Output\OutputInterface` $output -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L60) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L57) #### addModulesToComposer() @@ -48,7 +48,7 @@ This class provides various helper methods for building customized setup * `param array` $modules * `return ?int` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L237) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L227) #### addStyles() @@ -58,7 +58,7 @@ This class provides various helper methods for building customized setup * `param \Symfony\Component\Console\Output\OutputInterface` $output * `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L12) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L12) #### ask() @@ -83,7 +83,7 @@ $this->ask('do you want to proceed (y/n)', true); {% endhighlight %} -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L100) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L97) #### breakParts() @@ -93,7 +93,7 @@ $this->ask('do you want to proceed (y/n)', true); * `param string` $class * `return string[]` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L19) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L19) #### checkInstalled() @@ -103,7 +103,7 @@ $this->ask('do you want to proceed (y/n)', true); * `param string` $dir * `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L198) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L195) #### completeSuffix() @@ -114,7 +114,7 @@ $this->ask('do you want to proceed (y/n)', true); * `param string` $suffix * `return string` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L37) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L37) #### createActor() @@ -123,14 +123,14 @@ $this->ask('do you want to proceed (y/n)', true); * `param string` $name * `param string` $directory -* `param array` $suiteConfig +* `param array<string,mixed>` $suiteConfig * `return void` Create an Actor class and generate actions for it. Requires a suite config as array in 3rd parameter. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L210) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L207) #### createDirectoryFor() @@ -141,7 +141,7 @@ Requires a suite config as array in 3rd parameter. * `param string` $className * `return string` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L22) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L22) #### createEmptyDirectory() @@ -153,7 +153,7 @@ Requires a suite config as array in 3rd parameter. Create an empty directory and add a placeholder file into it -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L187) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L181) #### createFile() @@ -166,7 +166,7 @@ Create an empty directory and add a placeholder file into it * `param int` $flags * `return bool` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L58) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L58) #### createHelper() @@ -180,7 +180,7 @@ Create an empty directory and add a placeholder file into it Create a helper class inside a directory -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L166) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L167) #### getNamespaceHeader() @@ -190,7 +190,7 @@ Create a helper class inside a directory * `param string` $class * `return string` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L38) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L36) #### getNamespaceString() @@ -200,7 +200,7 @@ Create a helper class inside a directory * `param string` $class * `return string` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L32) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L31) #### getNamespaces() @@ -210,7 +210,7 @@ Create a helper class inside a directory * `param string` $class * `return array` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L47) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L42) #### getShortClassName() @@ -220,7 +220,7 @@ Create a helper class inside a directory * `param string` $class * `return string` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L26) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L25) #### gitIgnore() @@ -230,7 +230,7 @@ Create a helper class inside a directory * `param string` $path * `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L193) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L187) #### initDir() @@ -242,7 +242,7 @@ Create a helper class inside a directory Change the directory where Codeception should be installed. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L69) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L66) #### removeSuffix() @@ -253,7 +253,7 @@ Change the directory where Codeception should be installed. * `param string` $suffix * `return string` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L52) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L52) #### say() @@ -272,7 +272,7 @@ $this->say('Welcome to Setup'); {% endhighlight %} -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L126) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L127) #### sayError() @@ -284,7 +284,7 @@ $this->say('Welcome to Setup'); Print error message -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L142) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L143) #### sayInfo() @@ -296,7 +296,7 @@ Print error message Print info message -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L158) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L159) #### saySuccess() @@ -308,7 +308,7 @@ Print info message Print a successful message -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L134) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L135) #### sayWarning() @@ -320,7 +320,7 @@ Print a successful message Print warning message -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L150) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L151) #### setup() @@ -331,7 +331,7 @@ Print warning message Override this class to create customized setup. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L83) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L80) #### updateComposerClassMap() @@ -341,6 +341,6 @@ Override this class to create customized setup. * `param string` $vendorDir * `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php#L309) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php#L304) -<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/InitTemplate.php">Help us to improve documentation. Edit module reference</a></div> +<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/main/src/Codeception/InitTemplate.php">Help us to improve documentation. Edit module reference</a></div> diff --git a/docs/reference/JsonType.md b/docs/reference/JsonType.md index dbd30b99a..a5bac0039 100644 --- a/docs/reference/JsonType.md +++ b/docs/reference/JsonType.md @@ -18,10 +18,11 @@ Usage example: {% highlight php %} <?php -$jsonType = new JsonType(['name' => 'davert', 'id' => 1]); +$jsonType = new JsonType(['name' => 'davert', 'id' => 1, 'data' => []]); $jsonType->matches([ 'name' => 'string:!empty', 'id' => 'integer:>0|string:>0', + 'data' => 'array:empty', ]); // => true $jsonType->matches([ @@ -46,7 +47,7 @@ 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. -[See source](https://github.com/Codeception/module-rest/blob/master/src/Codeception/Util/JsonType.php#L47) +[See source](https://github.com/Codeception/module-rest/blob/master/src/Codeception/Util/JsonType.php#L48) #### addCustomFilter() @@ -80,7 +81,7 @@ JsonType::addCustomFilter('/len\((.*?)\)/', function($value, $len) { {% endhighlight %} -[See source](https://github.com/Codeception/module-rest/blob/master/src/Codeception/Util/JsonType.php#L77) +[See source](https://github.com/Codeception/module-rest/blob/master/src/Codeception/Util/JsonType.php#L78) #### cleanCustomFilters() @@ -91,7 +92,7 @@ JsonType::addCustomFilter('/len\((.*?)\)/', function($value, $len) { Removes all custom filters -[See source](https://github.com/Codeception/module-rest/blob/master/src/Codeception/Util/JsonType.php#L85) +[See source](https://github.com/Codeception/module-rest/blob/master/src/Codeception/Util/JsonType.php#L86) #### matches() @@ -106,6 +107,6 @@ Checks data against passed JsonType. If matching fails function returns a string with a message describing failure. On success returns `true`. -[See source](https://github.com/Codeception/module-rest/blob/master/src/Codeception/Util/JsonType.php#L95) +[See source](https://github.com/Codeception/module-rest/blob/master/src/Codeception/Util/JsonType.php#L96) <p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/module-rest/blob/master/src/Codeception/Util/JsonType.php">Help us to improve documentation. Edit module reference</a></div> diff --git a/docs/reference/Locator.md b/docs/reference/Locator.md index 453285b58..b3f2c34e3 100644 --- a/docs/reference/Locator.md +++ b/docs/reference/Locator.md @@ -31,7 +31,7 @@ You can mix up CSS and XPath selectors here. {% highlight php %} <?php -use \Codeception\Util\Locator; +use Codeception\Util\Locator; $I->see('Title', Locator::combine('h1','h2','h3')); @@ -43,7 +43,7 @@ You can also combine CSS selector with XPath locator: {% highlight php %} <?php -use \Codeception\Util\Locator; +use Codeception\Util\Locator; $I->fillField(Locator::combine('form input[type=text]','//form/textarea[2]'), 'qwerty'); @@ -121,7 +121,7 @@ Finds element by it's attribute(s) {% highlight php %} <?php -use \Codeception\Util\Locator; +use Codeception\Util\Locator; $I->seeElement(Locator::find('img', ['title' => 'diagram'])); @@ -167,7 +167,7 @@ Matches the *a* element with given URL {% highlight php %} <?php -use \Codeception\Util\Locator; +use Codeception\Util\Locator; $I->see('Log In', Locator::href('/login.php')); @@ -342,7 +342,7 @@ You could try to match elements by their tab position using `tabIndex` method of {% highlight php %} <?php -use \Codeception\Util\Locator; +use Codeception\Util\Locator; $I->fillField(Locator::tabIndex(1), 'davert'); $I->fillField(Locator::tabIndex(2) , 'qwerty'); diff --git a/docs/reference/Mock.md b/docs/reference/Mock.md index e7e7b7d5b..cc45cb3b9 100644 --- a/docs/reference/Mock.md +++ b/docs/reference/Mock.md @@ -292,7 +292,7 @@ exception. {% highlight php %} <?php -use \Codeception\Stub\Expected; +use Codeception\Stub\Expected; $user = $this->make('User', [ 'getName' => Expected::never(), @@ -316,7 +316,7 @@ exception. {% highlight php %} <?php -use \Codeception\Stub\Expected; +use Codeception\Stub\Expected; $user = $this->make( 'User', @@ -351,7 +351,7 @@ If the number of invocations is 0 it will throw an exception in verify. {% highlight php %} <?php -use \Codeception\Stub\Expected; +use Codeception\Stub\Expected; $user = $this->make( 'User', @@ -392,8 +392,8 @@ exception. {% highlight php %} <?php -use \Codeception\Stub; -use \Codeception\Stub\Expected; +use Codeception\Stub; +use Codeception\Stub\Expected; $user = $this->make( 'User', diff --git a/docs/reference/Module.md b/docs/reference/Module.md index 835268ed3..8e1fb1ecd 100644 --- a/docs/reference/Module.md +++ b/docs/reference/Module.md @@ -56,7 +56,7 @@ Module constructor. Requires module container (to provide access between modules of suite) and config. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L60) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L59) #### _after() @@ -67,7 +67,7 @@ Requires module container (to provide access between modules of suite) and confi **HOOK** executed after test -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L223) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L221) #### _afterStep() @@ -78,7 +78,7 @@ Requires module container (to provide access between modules of suite) and confi **HOOK** executed after step -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L209) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L207) #### _afterSuite() @@ -87,7 +87,7 @@ Requires module container (to provide access between modules of suite) and confi **HOOK** executed after suite -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L195) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L193) #### _before() @@ -98,7 +98,7 @@ Requires module container (to provide access between modules of suite) and confi **HOOK** executed before test -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L216) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L214) #### _beforeStep() @@ -109,7 +109,7 @@ Requires module container (to provide access between modules of suite) and confi **HOOK** executed before step -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L202) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L200) #### _beforeSuite() @@ -120,7 +120,7 @@ Requires module container (to provide access between modules of suite) and confi **HOOK** executed before suite -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L188) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L186) #### _failed() @@ -132,7 +132,7 @@ Requires module container (to provide access between modules of suite) and confi **HOOK** executed when test fails but before `_after` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L230) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L228) #### _getConfig() @@ -144,7 +144,7 @@ Requires module container (to provide access between modules of suite) and confi Get config values or specific config item. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L301) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L299) #### _getName() @@ -155,7 +155,7 @@ Get config values or specific config item. Returns a module name for a Module, a class name for Helper -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L159) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L159) #### _hasRequiredFields() @@ -166,7 +166,7 @@ Returns a module name for a Module, a class name for Helper Checks if a module has required fields -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L173) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L171) #### _initialize() @@ -175,7 +175,7 @@ Checks if a module has required fields **HOOK** triggered after module is created and configuration is loaded -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L181) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L179) #### _reconfigure() @@ -202,7 +202,7 @@ public function _before(Test $test) { {% endhighlight %} -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L104) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L103) #### _resetConfig() @@ -213,7 +213,7 @@ public function _before(Test $test) { Reverts config changed by `_reconfigure` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L122) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L121) #### _setConfig() @@ -237,7 +237,7 @@ public function _beforeSuite($settings = []) { {% endhighlight %} -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L81) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L80) #### assert() @@ -246,34 +246,37 @@ public function _beforeSuite($settings = []) { * `param array` $arguments * `param bool` $not +* `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L16) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L19) #### assertArrayHasKey() *protected* assertArrayHasKey($key, $array, $message = '') -* `param int|string` $key -* `param array|\ArrayAccess` $array +* `param string|int` $key +* `param \ArrayAccess|array` $array * `param string` $message +* `return void` Asserts that an array has a specified key. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L19) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L21) #### assertArrayNotHasKey() *protected* assertArrayNotHasKey($key, $array, $message = '') -* `param int|string` $key -* `param array|\ArrayAccess` $array +* `param string|int` $key +* `param \ArrayAccess|array` $array * `param string` $message +* `return void` Asserts that an array does not have a specified key. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L30) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L30) #### assertClassHasAttribute() @@ -281,12 +284,13 @@ Asserts that an array does not have a specified key. * `param string` $attributeName -* `param string` $className +* `param class-string` $className * `param string` $message +* `return void` Asserts that a class has a specified attribute. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L38) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L39) #### assertClassHasStaticAttribute() @@ -294,12 +298,13 @@ Asserts that a class has a specified attribute. * `param string` $attributeName -* `param string` $className +* `param class-string` $className * `param string` $message +* `return void` Asserts that a class has a specified static attribute. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L52) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L49) #### assertClassNotHasAttribute() @@ -307,12 +312,13 @@ Asserts that a class has a specified static attribute. * `param string` $attributeName -* `param string` $className +* `param class-string` $className * `param string` $message +* `return void` Asserts that a class does not have a specified attribute. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L60) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L60) #### assertClassNotHasStaticAttribute() @@ -320,12 +326,13 @@ Asserts that a class does not have a specified attribute. * `param string` $attributeName -* `param string` $className +* `param class-string` $className * `param string` $message +* `return void` Asserts that a class does not have a specified static attribute. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L74) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L70) #### assertContains() @@ -333,12 +340,13 @@ Asserts that a class does not have a specified static attribute. * `param mixed` $needle -* `param iterable` $haystack +* `param iterable<mixed>` $haystack * `param string` $message +* `return void` Asserts that a haystack contains a needle. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L86) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L81) #### assertContainsEquals() @@ -346,10 +354,166 @@ Asserts that a haystack contains a needle. * `param mixed` $needle -* `param iterable` $haystack +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L89) + +#### assertContainsNotOnlyArray() + + *protected* assertContainsNotOnlyArray($haystack, $message = '') + + +* `param iterable<mixed>` $haystack * `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L105) -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L94) +#### assertContainsNotOnlyBool() + + *protected* assertContainsNotOnlyBool($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L113) + +#### assertContainsNotOnlyCallable() + + *protected* assertContainsNotOnlyCallable($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L121) + +#### assertContainsNotOnlyClosedResource() + + *protected* assertContainsNotOnlyClosedResource($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L194) + +#### assertContainsNotOnlyFloat() + + *protected* assertContainsNotOnlyFloat($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L129) + +#### assertContainsNotOnlyInstancesOf() + + *protected* assertContainsNotOnlyInstancesOf($className, $haystack, $message = '') + + +* `param class-string` $className +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L138) + +#### assertContainsNotOnlyInt() + + *protected* assertContainsNotOnlyInt($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L146) + +#### assertContainsNotOnlyIterable() + + *protected* assertContainsNotOnlyIterable($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L154) + +#### assertContainsNotOnlyNull() + + *protected* assertContainsNotOnlyNull($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L162) + +#### assertContainsNotOnlyNumeric() + + *protected* assertContainsNotOnlyNumeric($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L170) + +#### assertContainsNotOnlyObject() + + *protected* assertContainsNotOnlyObject($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L178) + +#### assertContainsNotOnlyResource() + + *protected* assertContainsNotOnlyResource($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L186) + +#### assertContainsNotOnlyScalar() + + *protected* assertContainsNotOnlyScalar($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L202) + +#### assertContainsNotOnlyString() + + *protected* assertContainsNotOnlyString($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L210) #### assertContainsOnly() @@ -357,26 +521,171 @@ Asserts that a haystack contains a needle. * `param string` $type -* `param iterable` $haystack +* `param iterable<mixed>` $haystack * `param ?bool` $isNativeType * `param string` $message +* `return void` Asserts that a haystack contains only values of a given type. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L102) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L220) + +#### assertContainsOnlyArray() + + *protected* assertContainsOnlyArray($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L278) + +#### assertContainsOnlyBool() + + *protected* assertContainsOnlyBool($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L286) + +#### assertContainsOnlyCallable() + + *protected* assertContainsOnlyCallable($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L294) + +#### assertContainsOnlyClosedResource() + + *protected* assertContainsOnlyClosedResource($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L358) + +#### assertContainsOnlyFloat() + + *protected* assertContainsOnlyFloat($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L302) #### assertContainsOnlyInstancesOf() *protected* assertContainsOnlyInstancesOf($className, $haystack, $message = '') -* `param string` $className -* `param iterable` $haystack +* `param class-string` $className +* `param iterable<mixed>` $haystack * `param string` $message +* `return void` Asserts that a haystack contains only instances of a given class name. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L110) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L270) + +#### assertContainsOnlyInt() + + *protected* assertContainsOnlyInt($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L310) + +#### assertContainsOnlyIterable() + + *protected* assertContainsOnlyIterable($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L318) + +#### assertContainsOnlyNull() + + *protected* assertContainsOnlyNull($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L326) + +#### assertContainsOnlyNumeric() + + *protected* assertContainsOnlyNumeric($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L334) + +#### assertContainsOnlyObject() + + *protected* assertContainsOnlyObject($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L342) + +#### assertContainsOnlyResource() + + *protected* assertContainsOnlyResource($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L350) + +#### assertContainsOnlyScalar() + + *protected* assertContainsOnlyScalar($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L366) + +#### assertContainsOnlyString() + + *protected* assertContainsOnlyString($haystack, $message = '') + + +* `param iterable<mixed>` $haystack +* `param string` $message +* `return void` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L374) #### assertCount() @@ -384,12 +693,13 @@ Asserts that a haystack contains only instances of a given class name. * `param int` $expectedCount -* `param \Countable|iterable` $haystack +* `param \Countable|iterable<mixed>` $haystack * `param string` $message +* `return void` Asserts the number of elements of an array, Countable or Traversable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L120) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L384) #### assertDirectoryDoesNotExist() @@ -398,10 +708,11 @@ Asserts the number of elements of an array, Countable or Traversable. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory does not exist. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L128) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L392) #### assertDirectoryExists() @@ -410,10 +721,11 @@ Asserts that a directory does not exist. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory exists. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L136) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L400) #### assertDirectoryIsNotReadable() @@ -422,10 +734,11 @@ Asserts that a directory exists. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory exists and is not readable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L144) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L408) #### assertDirectoryIsNotWritable() @@ -434,10 +747,11 @@ Asserts that a directory exists and is not readable. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory exists and is not writable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L152) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L416) #### assertDirectoryIsReadable() @@ -446,10 +760,11 @@ Asserts that a directory exists and is not writable. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory exists and is readable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L160) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L424) #### assertDirectoryIsWritable() @@ -458,10 +773,11 @@ Asserts that a directory exists and is readable. * `param string` $directory * `param string` $message +* `return void` Asserts that a directory exists and is writable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L168) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L432) #### assertDoesNotMatchRegularExpression() @@ -471,22 +787,25 @@ Asserts that a directory exists and is writable. * `param string` $pattern * `param string` $string * `param string` $message +* `return void` Asserts that a string does not match a given regular expression. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L176) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L440) #### assertEmpty() *protected* assertEmpty($actual, $message = '') +* `phpstan-assert` empty $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is empty. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L186) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L452) #### assertEquals() @@ -496,10 +815,11 @@ Asserts that a variable is empty. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L197) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L463) #### assertEqualsCanonicalizing() @@ -509,10 +829,11 @@ Asserts that two variables are equal. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are equal (canonicalizing). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L208) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L474) #### assertEqualsIgnoringCase() @@ -522,10 +843,11 @@ Asserts that two variables are equal (canonicalizing). * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are equal (ignoring case). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L219) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L485) #### assertEqualsWithDelta() @@ -536,22 +858,25 @@ Asserts that two variables are equal (ignoring case). * `param mixed` $actual * `param float` $delta * `param string` $message +* `return void` Asserts that two variables are equal (with delta). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L230) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L496) #### assertFalse() *protected* assertFalse($condition, $message = '') +* `phpstan-assert` false $condition * `param mixed` $condition * `param string` $message +* `return void` Asserts that a condition is false. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L240) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L508) #### assertFileDoesNotExist() @@ -560,10 +885,11 @@ Asserts that a condition is false. * `param string` $filename * `param string` $message +* `return void` Asserts that a file does not exist. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L248) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L516) #### assertFileEquals() @@ -573,10 +899,11 @@ Asserts that a file does not exist. * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is equal to the contents of another file. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L256) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L524) #### assertFileEqualsCanonicalizing() @@ -586,10 +913,11 @@ Asserts that the contents of one file is equal to the contents of another file. * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is equal to the contents of another file (canonicalizing). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L264) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L532) #### assertFileEqualsIgnoringCase() @@ -599,10 +927,11 @@ Asserts that the contents of one file is equal to the contents of another file ( * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is equal to the contents of another file (ignoring case). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L272) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L540) #### assertFileExists() @@ -611,10 +940,11 @@ Asserts that the contents of one file is equal to the contents of another file ( * `param string` $filename * `param string` $message +* `return void` Asserts that a file exists. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L280) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L548) #### assertFileIsNotReadable() @@ -623,10 +953,11 @@ Asserts that a file exists. * `param string` $file * `param string` $message +* `return void` Asserts that a file exists and is not readable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L288) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L556) #### assertFileIsNotWritable() @@ -635,10 +966,11 @@ Asserts that a file exists and is not readable. * `param string` $file * `param string` $message +* `return void` Asserts that a file exists and is not writable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L296) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L564) #### assertFileIsReadable() @@ -647,10 +979,11 @@ Asserts that a file exists and is not writable. * `param string` $file * `param string` $message +* `return void` Asserts that a file exists and is readable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L304) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L572) #### assertFileIsWritable() @@ -659,10 +992,11 @@ Asserts that a file exists and is readable. * `param string` $file * `param string` $message +* `return void` Asserts that a file exists and is writable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L312) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L580) #### assertFileNotEquals() @@ -672,10 +1006,11 @@ Asserts that a file exists and is writable. * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is not equal to the contents of another file. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L320) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L588) #### assertFileNotEqualsCanonicalizing() @@ -685,10 +1020,11 @@ Asserts that the contents of one file is not equal to the contents of another fi * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is not equal to the contents of another file (canonicalizing). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L328) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L596) #### assertFileNotEqualsIgnoringCase() @@ -698,10 +1034,11 @@ Asserts that the contents of one file is not equal to the contents of another fi * `param string` $expected * `param string` $actual * `param string` $message +* `return void` Asserts that the contents of one file is not equal to the contents of another file (ignoring case). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L336) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L604) #### assertFileNotExists() @@ -710,10 +1047,11 @@ Asserts that the contents of one file is not equal to the contents of another fi * `param string` $filename * `param string` $message +* `return void` Asserts that a file does not exist. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L41) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L55) #### assertFinite() @@ -722,10 +1060,11 @@ Asserts that a file does not exist. * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is finite. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L346) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L614) #### assertGreaterOrEquals() @@ -735,10 +1074,11 @@ Asserts that a variable is finite. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is greater than or equal to another value. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L52) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L66) #### assertGreaterThan() @@ -748,10 +1088,11 @@ Asserts that a value is greater than or equal to another value. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is greater than another value. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L357) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L625) #### assertGreaterThanOrEqual() @@ -761,10 +1102,11 @@ Asserts that a value is greater than another value. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is greater than or equal to another value. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L368) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L636) #### assertInfinite() @@ -773,71 +1115,83 @@ Asserts that a value is greater than or equal to another value. * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is infinite. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L378) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L646) #### assertInstanceOf() *protected* assertInstanceOf($expected, $actual, $message = '') -* `param string` $expected +* `template` ExpectedType of object +* `phpstan-assert` =ExpectedType $actual +* `param class-string<ExpectedType>` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of a given type. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L388) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L661) #### assertIsArray() *protected* assertIsArray($actual, $message = '') +* `phpstan-assert` array<mixed> $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type array. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L398) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L672) #### assertIsBool() *protected* assertIsBool($actual, $message = '') +* `phpstan-assert` bool $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type bool. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L408) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L684) #### assertIsCallable() *protected* assertIsCallable($actual, $message = '') +* `phpstan-assert` callable $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type callable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L418) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L696) #### assertIsClosedResource() *protected* assertIsClosedResource($actual, $message = '') +* `phpstan-assert` resource $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type resource and is closed. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L428) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L708) #### assertIsEmpty() @@ -846,154 +1200,179 @@ Asserts that a variable is of type resource and is closed. * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is empty. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L62) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L74) #### assertIsFloat() *protected* assertIsFloat($actual, $message = '') +* `phpstan-assert` float $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type float. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L438) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L720) #### assertIsInt() *protected* assertIsInt($actual, $message = '') +* `phpstan-assert` int $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type int. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L448) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L732) #### assertIsIterable() *protected* assertIsIterable($actual, $message = '') +* `phpstan-assert` iterable<mixed> $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type iterable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L458) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L744) #### assertIsNotArray() *protected* assertIsNotArray($actual, $message = '') +* `phpstan-assert` !array<mixed> $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type array. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L468) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L756) #### assertIsNotBool() *protected* assertIsNotBool($actual, $message = '') +* `phpstan-assert` !bool $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type bool. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L478) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L768) #### assertIsNotCallable() *protected* assertIsNotCallable($actual, $message = '') +* `phpstan-assert` !callable $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type callable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L488) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L780) #### assertIsNotClosedResource() *protected* assertIsNotClosedResource($actual, $message = '') +* `phpstan-assert` !resource $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type resource. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L498) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L792) #### assertIsNotFloat() *protected* assertIsNotFloat($actual, $message = '') +* `phpstan-assert` !float $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type float. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L508) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L804) #### assertIsNotInt() *protected* assertIsNotInt($actual, $message = '') +* `phpstan-assert` !int $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type int. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L518) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L816) #### assertIsNotIterable() *protected* assertIsNotIterable($actual, $message = '') +* `phpstan-assert` !iterable<mixed> $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type iterable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L528) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L828) #### assertIsNotNumeric() *protected* assertIsNotNumeric($actual, $message = '') +* `phpstan-assert` !numeric $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type numeric. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L538) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L840) #### assertIsNotObject() *protected* assertIsNotObject($actual, $message = '') +* `phpstan-assert` !object $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type object. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L548) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L852) #### assertIsNotReadable() @@ -1002,46 +1381,53 @@ Asserts that a variable is not of type object. * `param string` $filename * `param string` $message +* `return void` Asserts that a file/dir exists and is not readable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L556) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L860) #### assertIsNotResource() *protected* assertIsNotResource($actual, $message = '') +* `phpstan-assert` !resource $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type resource. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L566) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L872) #### assertIsNotScalar() *protected* assertIsNotScalar($actual, $message = '') +* `psalm-assert` !scalar $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type scalar. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L576) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L884) #### assertIsNotString() *protected* assertIsNotString($actual, $message = '') +* `phpstan-assert` !string $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of type string. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L586) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L896) #### assertIsNotWritable() @@ -1050,34 +1436,39 @@ Asserts that a variable is not of type string. * `param string` $filename * `param string` $message +* `return void` Asserts that a file/dir exists and is not writable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L594) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L904) #### assertIsNumeric() *protected* assertIsNumeric($actual, $message = '') +* `phpstan-assert` numeric $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type numeric. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L604) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L916) #### assertIsObject() *protected* assertIsObject($actual, $message = '') +* `phpstan-assert` object $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type object. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L614) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L928) #### assertIsReadable() @@ -1086,46 +1477,53 @@ Asserts that a variable is of type object. * `param string` $filename * `param string` $message +* `return void` Asserts that a file/dir is readable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L622) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L936) #### assertIsResource() *protected* assertIsResource($actual, $message = '') +* `phpstan-assert` resource $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type resource. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L632) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L948) #### assertIsScalar() *protected* assertIsScalar($actual, $message = '') +* `phpstan-assert` scalar $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type scalar. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L642) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L960) #### assertIsString() *protected* assertIsString($actual, $message = '') +* `phpstan-assert` string $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is of type string. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L652) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L972) #### assertIsWritable() @@ -1134,10 +1532,11 @@ Asserts that a variable is of type string. * `param string` $filename * `param string` $message +* `return void` Asserts that a file/dir exists and is writable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L660) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L980) #### assertJson() @@ -1146,10 +1545,11 @@ Asserts that a file/dir exists and is writable. * `param string` $actualJson * `param string` $message +* `return void` Asserts that a string is a valid JSON string. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L668) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L988) #### assertJsonFileEqualsJsonFile() @@ -1159,10 +1559,11 @@ Asserts that a string is a valid JSON string. * `param string` $expectedFile * `param string` $actualFile * `param string` $message +* `return void` Asserts that two JSON files are equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L676) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L996) #### assertJsonFileNotEqualsJsonFile() @@ -1172,10 +1573,11 @@ Asserts that two JSON files are equal. * `param string` $expectedFile * `param string` $actualFile * `param string` $message +* `return void` Asserts that two JSON files are not equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L684) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1004) #### assertJsonStringEqualsJsonFile() @@ -1185,10 +1587,11 @@ Asserts that two JSON files are not equal. * `param string` $expectedFile * `param string` $actualJson * `param string` $message +* `return void` Asserts that the generated JSON encoded object and the content of the given file are equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L692) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1012) #### assertJsonStringEqualsJsonString() @@ -1198,10 +1601,11 @@ Asserts that the generated JSON encoded object and the content of the given file * `param string` $expectedJson * `param string` $actualJson * `param string` $message +* `return void` Asserts that two given JSON encoded objects or arrays are equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L700) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1020) #### assertJsonStringNotEqualsJsonFile() @@ -1211,10 +1615,11 @@ Asserts that two given JSON encoded objects or arrays are equal. * `param string` $expectedFile * `param string` $actualJson * `param string` $message +* `return void` Asserts that the generated JSON encoded object and the content of the given file are not equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L708) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1028) #### assertJsonStringNotEqualsJsonString() @@ -1224,10 +1629,11 @@ Asserts that the generated JSON encoded object and the content of the given file * `param string` $expectedJson * `param string` $actualJson * `param string` $message +* `return void` Asserts that two given JSON encoded objects or arrays are not equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L716) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1036) #### assertLessOrEquals() @@ -1237,10 +1643,11 @@ Asserts that two given JSON encoded objects or arrays are not equal. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is smaller than or equal to another value. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L73) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L82) #### assertLessThan() @@ -1250,10 +1657,11 @@ Asserts that a value is smaller than or equal to another value. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is smaller than another value. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L727) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1047) #### assertLessThanOrEqual() @@ -1263,10 +1671,11 @@ Asserts that a value is smaller than another value. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a value is smaller than or equal to another value. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L738) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1058) #### assertMatchesRegularExpression() @@ -1276,10 +1685,11 @@ Asserts that a value is smaller than or equal to another value. * `param string` $pattern * `param string` $string * `param string` $message +* `return void` Asserts that a string matches a given regular expression. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L746) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1066) #### assertNan() @@ -1288,19 +1698,21 @@ Asserts that a string matches a given regular expression. * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is nan. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L756) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1076) #### assertNot() - *protected* assertNot($arguments) + *protected* assertNot(array $arguments) -* `param ` $arguments +* `param array` $arguments +* `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L33) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L47) #### assertNotContains() @@ -1308,23 +1720,25 @@ Asserts that a variable is nan. * `param mixed` $needle -* `param iterable` $haystack +* `param iterable<mixed>` $haystack * `param string` $message +* `return void` Asserts that a haystack does not contain a needle. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L766) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1086) #### assertNotContainsEquals() *protected* assertNotContainsEquals($needle, $haystack, $message = '') -* `param ` $needle -* `param iterable` $haystack +* `param mixed` $needle +* `param iterable<mixed>` $haystack * `param string` $message +* `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L771) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L97) #### assertNotContainsOnly() @@ -1332,13 +1746,14 @@ Asserts that a haystack does not contain a needle. * `param string` $type -* `param iterable` $haystack +* `param iterable<mixed>` $haystack * `param ?bool` $isNativeType * `param string` $message +* `return void` Asserts that a haystack does not contain only values of a given type. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L779) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1096) #### assertNotCount() @@ -1346,24 +1761,27 @@ Asserts that a haystack does not contain only values of a given type. * `param int` $expectedCount -* `param \Countable|iterable` $haystack +* `param \Countable|iterable<mixed>` $haystack * `param string` $message +* `return void` Asserts the number of elements of an array, Countable or Traversable. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L789) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1146) #### assertNotEmpty() *protected* assertNotEmpty($actual, $message = '') +* `phpstan-assert` !empty $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not empty. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L799) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1158) #### assertNotEquals() @@ -1373,10 +1791,11 @@ Asserts that a variable is not empty. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are not equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L810) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1169) #### assertNotEqualsCanonicalizing() @@ -1386,10 +1805,11 @@ Asserts that two variables are not equal. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are not equal (canonicalizing). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L821) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1180) #### assertNotEqualsIgnoringCase() @@ -1399,10 +1819,11 @@ Asserts that two variables are not equal (canonicalizing). * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables are not equal (ignoring case). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L832) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1191) #### assertNotEqualsWithDelta() @@ -1413,47 +1834,55 @@ Asserts that two variables are not equal (ignoring case). * `param mixed` $actual * `param float` $delta * `param string` $message +* `return void` Asserts that two variables are not equal (with delta). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L843) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1202) #### assertNotFalse() *protected* assertNotFalse($condition, $message = '') +* `phpstan-assert` !false $condition * `param mixed` $condition * `param string` $message +* `return void` Asserts that a condition is not false. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L853) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1214) #### assertNotInstanceOf() *protected* assertNotInstanceOf($expected, $actual, $message = '') -* `param string` $expected +* `template` ExpectedType of object +* `phpstan-assert` !ExpectedType $actual +* `param class-string<ExpectedType>` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not of a given type. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L863) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1229) #### assertNotNull() *protected* assertNotNull($actual, $message = '') +* `phpstan-assert` !null $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is not null. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L873) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1241) #### assertNotRegExp() @@ -1463,10 +1892,11 @@ Asserts that a variable is not null. * `param string` $pattern * `param string` $string * `param string` $message +* `return void` Asserts that a string does not match a given regular expression. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L81) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L90) #### assertNotSame() @@ -1476,47 +1906,53 @@ Asserts that a string does not match a given regular expression. * `param mixed` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables do not have the same type and value. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L884) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1252) #### assertNotSameSize() *protected* assertNotSameSize($expected, $actual, $message = '') -* `param \Countable|iterable` $expected -* `param \Countable|iterable` $actual +* `param \Countable|iterable<mixed>` $expected +* `param \Countable|iterable<mixed>` $actual * `param string` $message +* `return void` Assert that the size of two arrays (or `Countable` or `Traversable` objects) is not the same. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L895) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1263) #### assertNotTrue() *protected* assertNotTrue($condition, $message = '') +* `phpstan-assert` !true $condition * `param mixed` $condition * `param string` $message +* `return void` Asserts that a condition is not true. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L905) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1275) #### assertNull() *protected* assertNull($actual, $message = '') +* `phpstan-assert` null $actual * `param mixed` $actual * `param string` $message +* `return void` Asserts that a variable is null. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L915) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1287) #### assertObjectHasAttribute() @@ -1526,10 +1962,11 @@ Asserts that a variable is null. * `param string` $attributeName * `param object` $object * `param string` $message +* `return void` Asserts that an object has a specified attribute. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L923) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1295) #### assertObjectNotHasAttribute() @@ -1539,10 +1976,11 @@ Asserts that an object has a specified attribute. * `param string` $attributeName * `param object` $object * `param string` $message +* `return void` Asserts that an object does not have a specified attribute. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L937) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1309) #### assertRegExp() @@ -1552,36 +1990,44 @@ Asserts that an object does not have a specified attribute. * `param string` $pattern * `param string` $string * `param string` $message +* `return void` Asserts that a string matches a given regular expression. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L89) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L98) #### assertSame() *protected* assertSame($expected, $actual, $message = '') -* `param mixed` $expected +* `template` ExpectedType +* `phpstan-assert` =ExpectedType $actual +* `param ExpectedType` $expected * `param mixed` $actual * `param string` $message +* `return void` Asserts that two variables have the same type and value. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L954) +Used on objects, it asserts that two variables reference +the same object. + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1331) #### assertSameSize() *protected* assertSameSize($expected, $actual, $message = '') -* `param \Countable|iterable` $expected -* `param \Countable|iterable` $actual +* `param \Countable|iterable<mixed>` $expected +* `param \Countable|iterable<mixed>` $actual * `param string` $message +* `return void` Assert that the size of two arrays (or `Countable` or `Traversable` objects) is the same. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L965) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1341) #### assertStringContainsString() @@ -1591,8 +2037,9 @@ Assert that the size of two arrays (or `Countable` or `Traversable` objects) is * `param string` $needle * `param string` $haystack * `param string` $message +* `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L970) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1346) #### assertStringContainsStringIgnoringCase() @@ -1602,34 +2049,37 @@ Assert that the size of two arrays (or `Countable` or `Traversable` objects) is * `param string` $needle * `param string` $haystack * `param string` $message +* `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L975) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1351) #### assertStringEndsNotWith() *protected* assertStringEndsNotWith($suffix, $string, $message = '') -* `param string` $suffix +* `param non-empty-string` $suffix * `param string` $string * `param string` $message +* `return void` Asserts that a string ends not with a given suffix. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L983) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1360) #### assertStringEndsWith() *protected* assertStringEndsWith($suffix, $string, $message = '') -* `param string` $suffix +* `param non-empty-string` $suffix * `param string` $string * `param string` $message +* `return void` Asserts that a string ends with a given suffix. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L991) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1369) #### assertStringEqualsFile() @@ -1639,10 +2089,11 @@ Asserts that a string ends with a given suffix. * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is equal to the contents of a file. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L999) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1377) #### assertStringEqualsFileCanonicalizing() @@ -1652,10 +2103,11 @@ Asserts that the contents of a string is equal to the contents of a file. * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is equal to the contents of a file (canonicalizing). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1007) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1385) #### assertStringEqualsFileIgnoringCase() @@ -1665,10 +2117,11 @@ Asserts that the contents of a string is equal to the contents of a file (canoni * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is equal to the contents of a file (ignoring case). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1015) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1393) #### assertStringMatchesFormat() @@ -1678,10 +2131,11 @@ Asserts that the contents of a string is equal to the contents of a file (ignori * `param string` $format * `param string` $string * `param string` $message +* `return void` Asserts that a string matches a given format string. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1023) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1401) #### assertStringMatchesFormatFile() @@ -1691,10 +2145,11 @@ Asserts that a string matches a given format string. * `param string` $formatFile * `param string` $string * `param string` $message +* `return void` Asserts that a string matches a given format file. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1031) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1409) #### assertStringNotContainsString() @@ -1704,8 +2159,9 @@ Asserts that a string matches a given format file. * `param string` $needle * `param string` $haystack * `param string` $message +* `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1036) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1414) #### assertStringNotContainsStringIgnoringCase() @@ -1715,8 +2171,9 @@ Asserts that a string matches a given format file. * `param string` $needle * `param string` $haystack * `param string` $message +* `return void` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1041) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1419) #### assertStringNotEqualsFile() @@ -1726,10 +2183,11 @@ Asserts that a string matches a given format file. * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is not equal to the contents of a file. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1049) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1427) #### assertStringNotEqualsFileCanonicalizing() @@ -1739,10 +2197,11 @@ Asserts that the contents of a string is not equal to the contents of a file. * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is not equal to the contents of a file (canonicalizing). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1057) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1435) #### assertStringNotEqualsFileIgnoringCase() @@ -1752,10 +2211,11 @@ Asserts that the contents of a string is not equal to the contents of a file (ca * `param string` $expectedFile * `param string` $actualString * `param string` $message +* `return void` Asserts that the contents of a string is not equal to the contents of a file (ignoring case). -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1065) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1443) #### assertStringNotMatchesFormat() @@ -1765,10 +2225,11 @@ Asserts that the contents of a string is not equal to the contents of a file (ig * `param string` $format * `param string` $string * `param string` $message +* `return void` Asserts that a string does not match a given format string. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1073) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1451) #### assertStringNotMatchesFormatFile() @@ -1778,36 +2239,39 @@ Asserts that a string does not match a given format string. * `param string` $formatFile * `param string` $string * `param string` $message +* `return void` Asserts that a string does not match a given format string. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1081) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1461) #### assertStringStartsNotWith() *protected* assertStringStartsNotWith($prefix, $string, $message = '') -* `param string` $prefix +* `param non-empty-string` $prefix * `param string` $string * `param string` $message +* `return void` Asserts that a string starts not with a given prefix. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1089) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1476) #### assertStringStartsWith() *protected* assertStringStartsWith($prefix, $string, $message = '') -* `param string` $prefix +* `param non-empty-string` $prefix * `param string` $string * `param string` $message +* `return void` Asserts that a string starts with a given prefix. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1097) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1485) #### assertThat() @@ -1817,10 +2281,11 @@ Asserts that a string starts with a given prefix. * `param mixed` $value * `param \PHPUnit\Framework\Constraint\Constraint` $constraint * `param string` $message +* `return void` Evaluates a PHPUnit\Framework\Constraint matcher object. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1107) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1495) #### assertThatItsNot() @@ -1830,22 +2295,25 @@ Evaluates a PHPUnit\Framework\Constraint matcher object. * `param mixed` $value * `param \PHPUnit\Framework\Constraint\Constraint` $constraint * `param string` $message +* `return void` Evaluates a PHPUnit\Framework\Constraint matcher object. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L99) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L106) #### assertTrue() *protected* assertTrue($condition, $message = '') +* `phpstan-assert` true $condition * `param mixed` $condition * `param string` $message +* `return void` Asserts that a condition is true. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1117) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1507) #### assertXmlFileEqualsXmlFile() @@ -1855,10 +2323,11 @@ Asserts that a condition is true. * `param string` $expectedFile * `param string` $actualFile * `param string` $message +* `return void` Asserts that two XML files are equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1125) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1515) #### assertXmlFileNotEqualsXmlFile() @@ -1868,10 +2337,11 @@ Asserts that two XML files are equal. * `param string` $expectedFile * `param string` $actualFile * `param string` $message +* `return void` Asserts that two XML files are not equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1133) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1523) #### assertXmlStringEqualsXmlFile() @@ -1881,10 +2351,11 @@ Asserts that two XML files are not equal. * `param string` $expectedFile * `param \DOMDocument|string` $actualXml * `param string` $message +* `return void` Asserts that two XML documents are equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1143) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1531) #### assertXmlStringEqualsXmlString() @@ -1894,10 +2365,11 @@ Asserts that two XML documents are equal. * `param \DOMDocument|string` $expectedXml * `param \DOMDocument|string` $actualXml * `param string` $message +* `return void` Asserts that two XML documents are equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1154) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1545) #### assertXmlStringNotEqualsXmlFile() @@ -1907,10 +2379,11 @@ Asserts that two XML documents are equal. * `param string` $expectedFile * `param \DOMDocument|string` $actualXml * `param string` $message +* `return void` Asserts that two XML documents are not equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1164) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1567) #### assertXmlStringNotEqualsXmlString() @@ -1920,10 +2393,11 @@ Asserts that two XML documents are not equal. * `param \DOMDocument|string` $expectedXml * `param \DOMDocument|string` $actualXml * `param string` $message +* `return void` Asserts that two XML documents are not equal. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1175) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1584) #### debug() @@ -1935,20 +2409,20 @@ Asserts that two XML documents are not equal. Print debug message to the screen. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L237) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L235) #### debugSection() - *protected* debugSection($title, $message) + *protected* debugSection($title, $msg) * `param string` $title -* `param mixed` $message +* `param mixed` $msg * `return void` Print debug message with a title -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L245) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L243) #### fail() @@ -1956,10 +2430,11 @@ Print debug message with a title * `param string` $message +* `return never` Fails a test with the given message. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1183) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1604) #### getModule() @@ -1979,7 +2454,7 @@ $this->getModule('WebDriver')->_findElements('.items'); {% endhighlight %} -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L287) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L285) #### getModules() @@ -1990,7 +2465,7 @@ $this->getModule('WebDriver')->_findElements('.items'); Get all enabled modules -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L272) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L270) #### hasModule() @@ -2002,7 +2477,19 @@ Get all enabled modules Checks that module is enabled. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L264) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L262) + +#### hasStaticAttribute() + + *private static* hasStaticAttribute($attributeName, $className) + + +* `see` https://github.com/sebastianbergmann/phpunit/blob/9.6/src/Framework/Constraint/Object/ClassHasStaticAttribute.php +* `param string` $attributeName +* `param class-string` $className +* `return bool` + +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1629) #### markTestIncomplete() @@ -2010,10 +2497,11 @@ Checks that module is enabled. * `param string` $message +* `return never` Mark the test as incomplete. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1191) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1612) #### markTestSkipped() @@ -2021,10 +2509,11 @@ Mark the test as incomplete. * `param string` $message +* `return never` Mark the test as skipped. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L1199) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L1620) #### onReconfigure() @@ -2033,7 +2522,7 @@ Mark the test as skipped. HOOK to be executed when config changes with `_reconfigure`. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L114) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L113) #### scalarizeArray() @@ -2043,7 +2532,7 @@ HOOK to be executed when config changes with `_reconfigure`. * `param array` $array * `return array` -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L312) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L304) #### shortenMessage() @@ -2056,7 +2545,7 @@ HOOK to be executed when config changes with `_reconfigure`. Short text message to an amount of chars -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L256) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L254) #### validateConfig() @@ -2068,6 +2557,6 @@ Short text message to an amount of chars Validates current config for required fields and required packages. -[See source](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php#L132) +[See source](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php#L131) -<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Module.php">Help us to improve documentation. Edit module reference</a></div> +<p> </p><div class="alert alert-warning">Reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/blob/main/src/Codeception/Module.php">Help us to improve documentation. Edit module reference</a></div> diff --git a/for/joomla.md b/for/joomla.md deleted file mode 100644 index 1b71a8234..000000000 --- a/for/joomla.md +++ /dev/null @@ -1,7 +0,0 @@ -<meta http-equiv="refresh" content="0;url=https://github.com/joomla-projects/joomla-browser"> ---- -layout: page -title: Codeception for Joomla -hero: joomla_hero.html - ---- diff --git a/for/laravel.md b/for/laravel.md index f96ef4651..3b55cbe70 100644 --- a/for/laravel.md +++ b/for/laravel.md @@ -47,7 +47,7 @@ cp .env .env.testing Functional tests allow test application by simulating user actions, this is done by sending requests to framework kernel and checking HTML as a result. Unilke internal tests of Laravel, Codeception doesn't limit you to testing only one request per test. You can **test complex interactions involving different actions and controllers**. This way you can easily cover your specifictions with functional tests. -To start you need to configure `tests/functional.suite.yml` to use Laravel module: +To start you need to configure `tests/Functional.suite.yml` to use Laravel module: ```yaml class_name: FunctionalTester @@ -77,10 +77,10 @@ php vendor/bin/codecept g:cest functional Login To generate a unit test run: ``` -php vendor/bin/codecept g:test unit "Foo\Bar" +php vendor/bin/codecept g:test Unit "Foo\Bar" ``` This generates `Codeception\Test\Unit` testcase which is inherited from PHPUnit but provides a module access. -Enable Laravel module in `unit.suite.yml` to have its methods inside a testcase. They are available injected into `$this->tester` property of a testcase. +Enable Laravel module in `Unit.suite.yml` to have its methods inside a testcase. They are available injected into `$this->tester` property of a testcase. <div class="alert alert-warning"> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> @@ -90,7 +90,7 @@ Enable Laravel module in `unit.suite.yml` to have its methods inside a testcase. ### Acceptance Tests -To test an application in a real environment by using its UI you should use a real browser. Codeception uses Selenium Webdriver and corresponding WebDriver module to interact with a browser. You should configure `acceptance.suite.yml` to use WebDriver module and a browser of your choice. +To test an application in a real environment by using its UI you should use a real browser. Codeception uses Selenium Webdriver and corresponding WebDriver module to interact with a browser. You should configure `Acceptance.suite.yml` to use WebDriver module and a browser of your choice. ```yaml class_name: AcceptanceTester @@ -157,13 +157,13 @@ Laravel module actions like `amOnPage` or `see` should not be available for test ### BDD -If you prefer to describe application with feature files, Codeception can turn them to acceptance or functional tests. It is recommended to store feature files in `features` directory (like it does Behat) but symlinking it to `tests/acceptance/features` or `tests/functional/features` so they can be treated as tests too. For using BDD with acceptance tests you need to run: +If you prefer to describe application with feature files, Codeception can turn them to acceptance or functional tests. It is recommended to store feature files in `features` directory (like it does Behat) but symlinking it to `tests/Acceptance/features` or `tests/Functional/features` so they can be treated as tests too. For using BDD with acceptance tests you need to run: ``` -ln -s $PWD/features tests/acceptance +ln -s $PWD/features tests/Acceptance ``` -Codeception allows to combine tests written in different formats. If are about to wirite a regression test it probably should not be described as a product's feature. That's why feature-files is subset of all acceptance tests, and they are stored in subfolder of `tests/acceptance`. +Codeception allows to combine tests written in different formats. If are about to wirite a regression test it probably should not be described as a product's feature. That's why feature-files is subset of all acceptance tests, and they are stored in subfolder of `tests/Acceptance`. There is no standard Gherkin steps built in. By writing your feature files you can get code snippets which should be added to `AcceptanceTester` class. diff --git a/for/phalcon.md b/for/phalcon.md index 875036c48..2be2084c4 100644 --- a/for/phalcon.md +++ b/for/phalcon.md @@ -36,7 +36,7 @@ This will create `tests` directory and configuration file `codeception.yml`. Thi ### Unit Testing -Add Phalcon to your unit test by adding the following to your `unit.suite.yml`: +Add Phalcon to your unit test by adding the following to your `Unit.suite.yml`: ```yaml # Codeception Test Suite Configuration # @@ -57,7 +57,7 @@ modules: To generate a plain PHPUnit test for class `Users`, run: ``` -vendor/bin/codecept g:test unit Users +vendor/bin/codecept g:test Unit Users ``` Actions of the Phalcon module will be accessible from `$this->tester` inside a test of `Codeception\Test\Unit`. @@ -95,7 +95,7 @@ modules: Then use [Cest](https://codeception.com/docs/07-AdvancedUsage) or Cept to create a test. ``` -vendor/bin/codecept g:cest functional Login +vendor/bin/codecept g:cest Functional Login ``` Then add your test case ```php @@ -138,7 +138,7 @@ class LoginCest ### Acceptance Testing -Sample configuration of `tests/acceptance.suite.yml`: +Sample configuration of `tests/Acceptance.suite.yml`: ```yaml class_name: AcceptanceTester @@ -155,10 +155,10 @@ Browser can be specified as `chrome`, `firefox`, `phantomjs`, or others. To create a sample test called, run: ``` -vendor/bin/codecept g:cest acceptance Login +vendor/bin/codecept g:cest Acceptance Login ``` -This will create the file `tests/acceptance/LoginCest.php`. Each method of a class (except `_before` and `_after`) is a test. Tests use `$I` object (instance of `AcceptanceTester` class) to perform actions on a webpage. Methods of `AcceptanceTester` are proxified to corresponding modules, which in current case is `WebDriver`. +This will create the file `tests/Acceptance/LoginCest.php`. Each method of a class (except `_before` and `_after`) is a test. Tests use `$I` object (instance of `AcceptanceTester` class) to perform actions on a webpage. Methods of `AcceptanceTester` are proxified to corresponding modules, which in current case is `WebDriver`. <div class="alert alert-warning"> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> @@ -168,7 +168,7 @@ This will create the file `tests/acceptance/LoginCest.php`. Each method of a cla To run the tests you will need chrome browser, [selenium server running](https://codeception.com/docs/modules/WebDriver#Selenium). If this requirements met acceptance tests can be executed as ``` -vendor/bin/codecept run acceptance +vendor/bin/codecept run Acceptance ``` ### BDD @@ -176,7 +176,7 @@ vendor/bin/codecept run acceptance If you prefer to describe application with feature files, Codeception can turn them to acceptance tests. It is recommended to store feature files in `features` directory (like Behat does it) but symlinking it to `tests/acceptance/features` so they can be treated as tests too. ``` -ln -s $PWD/features tests/acceptance +ln -s $PWD/features tests/Acceptance ``` Codeception allows to combine tests written in different formats. If you are about to write a regression test it probably should not be described as a product's feature. That's why feature-files are a subset of all acceptance tests, and they are stored in subfolder of `tests/acceptance`. diff --git a/for/wordpress.md b/for/wordpress.md deleted file mode 100644 index 5b33c0fc5..000000000 --- a/for/wordpress.md +++ /dev/null @@ -1,7 +0,0 @@ -<meta http-equiv="refresh" content="0;url=https://github.com/lucatume/wp-browser"> ---- -layout: page -title: Codeception for WordPress -hero: wp_hero.html - ---- diff --git a/for/yii.md b/for/yii.md index 293078b7f..592e369e2 100644 --- a/for/yii.md +++ b/for/yii.md @@ -35,7 +35,7 @@ Run them by executing in terminal: ### Unit Tests -Unit tests are located in `tests/unit` directory and are supposed to contain all kind of unit and integration testing. +Unit tests are located in `tests/Unit` directory and are supposed to contain all kind of unit and integration testing. Each test case extends `Codeception\Test\Unit` class, which is standard Codeception format for unit testing. It is pretty hard to develop completely isolated unit tests in Yii, so an application is bootstrapped before each test case. Tests are configured in `tests/unit.suite.yml` file with Yii2 module enabled: @@ -152,10 +152,10 @@ Yii2 module actions like `amOnPage` or `see` should not be available for testing From a test perspective acceptance tests do the same as functional tests. They test the user interaction with application but in this case using *real* browser and web server. They are much slower and much more fragile. They should not duplicate functional tests in matter of testing functionality but should be used for testing the UI of your application. If you are unsure which tests should be acceptance and which are functional, write acceptance tests for JavaScript-rich applications, where UI highly depends on a browser processing. You can also use acceptance tests for happy-path scenarios, just to ensure that a real user using a real browser achieve the same results you expect in functional tests. -By default in basic application acceptance tests are disabled (as they require web server, Selenium Server and browser to be running). You can easily enable them by renaming `acceptance.suite.yml.example` to `acceptance.suite.yml` +By default in basic application acceptance tests are disabled (as they require web server, Selenium Server and browser to be running). You can easily enable them by renaming `Acceptance.suite.yml.example` to `Acceptance.suite.yml` ``` -mv tests/acceptance.suite.yml.example tests/acceptance.suite.yml +mv tests/Acceptance.suite.yml.example tests/Acceptance.suite.yml ``` Basic template uses `codeception/base` package which doesn't contain `facebook/webdriver` library required to run acceptance tests. Please change `codeception/base` to `codeception/codeception` in `composer.json` and run the update command. @@ -169,7 +169,7 @@ Then you will need to launch application server in test mode: and start a [Selenium Server](https://codeception.com/docs/modules/WebDriver#Local-Testing). For acceptance WebDriver module is used. Please check its reference to learn how to work with it. Unlike Yii2 module it does know nothing about your application, so if you want to use features of Yii like fixtures for acceptance testing, you should check that enable Yii2 module is enabled as well: ```yml -# config at tests/acceptance.yml +# config at tests/Acceptance.yml modules: enabled: - WebDriver: @@ -186,7 +186,7 @@ As it was said, functional and acceptance tests are similar, so in order to avoi Similar as for functional tests it is recommended to use Cest format for acceptance testing: ``` -./vendor/bin/codecept g:cest acceptance MyNewScenarioCest +./vendor/bin/codecept g:cest Acceptance MyNewScenarioCest ``` <div class="alert alert-warning"> @@ -222,10 +222,10 @@ Create basic test suites ./vendor/bin/codecept bootstrap ``` -Enable module Yii2 for functional tests inside `functional.suite.yml`: +Enable module Yii2 for functional tests inside `Functional.suite.yml`: ```yml -# functional.suite.yml +# Functional.suite.yml modules: enabled: - Yii2: diff --git a/images/codecept_acceptance.gif b/images/codecept_acceptance.gif deleted file mode 100644 index fe001c377..000000000 Binary files a/images/codecept_acceptance.gif and /dev/null differ diff --git a/images/codecept_api.gif b/images/codecept_api.gif deleted file mode 100644 index 40d740c10..000000000 Binary files a/images/codecept_api.gif and /dev/null differ diff --git a/images/codecept_bootstrap.gif b/images/codecept_bootstrap.gif deleted file mode 100644 index b04935aee..000000000 Binary files a/images/codecept_bootstrap.gif and /dev/null differ diff --git a/images/codecept_unit.gif b/images/codecept_unit.gif deleted file mode 100644 index 0c0a3594e..000000000 Binary files a/images/codecept_unit.gif and /dev/null differ diff --git a/images/frameworks/joomla.svg b/images/frameworks/joomla.svg deleted file mode 100644 index c654d8688..000000000 --- a/images/frameworks/joomla.svg +++ /dev/null @@ -1 +0,0 @@ -<svg width="2481" height="2500" viewBox="0 0 256 258" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet"><path d="M255.667 35.561c0-18.607-15.084-33.691-33.691-33.691-16.99 0-31.035 12.578-33.349 28.929l-.341-.18c-27.553-12.427-50.762 9.584-50.762 9.584l-61.391 61.692 24.257 23.36 49.413-48.546c23.074-23.075 35.638-7.457 35.638-7.457 17.37 14.674.598 32.044.598 32.044l24.857 23.959c20.298-21.923 21.475-41.056 15.305-56.276 16.612-2.08 29.466-16.243 29.466-33.418" fill="#F9AE41"/><path d="M226.514 190.507c.115-.215.18-.34.18-.34 12.428-27.554-9.584-50.763-9.584-50.763l-61.693-61.393-23.359 24.259 48.546 49.412c23.074 23.075 7.456 35.64 7.456 35.64-14.673 17.37-32.043.598-32.043.598l-23.959 24.856c21.922 20.298 41.056 21.475 56.275 15.305 2.08 16.612 16.244 29.467 33.419 29.467 18.607 0 33.69-15.084 33.69-33.691 0-16.99-12.577-31.035-28.928-33.35" fill="#EE4035"/><path d="M155.942 133.04l-49.413 48.545c-23.075 23.076-35.639 7.459-35.639 7.459C53.52 174.369 70.291 157 70.291 157l-24.855-23.96c-20.298 21.922-21.476 41.055-15.307 56.275C13.517 191.396.663 205.558.663 222.734c0 18.607 15.084 33.69 33.692 33.69 16.99.001 31.035-12.576 33.349-28.927.216.115.341.179.341.179 27.554 12.43 50.762-9.584 50.762-9.584l61.392-61.693-24.257-23.359" fill="#4F91CD"/><path d="M75.727 106.613c-23.075-23.075-7.459-35.64-7.459-35.64 14.676-17.37 32.045-.598 32.045-.598l23.959-24.855C102.35 25.222 83.217 24.045 67.997 30.214 65.917 13.601 51.755.747 34.577.747 15.973.747.89 15.831.888 34.438c0 16.991 12.577 31.036 28.929 33.35-.115.216-.179.342-.179.342-12.43 27.552 9.583 50.76 9.583 50.76l61.694 61.393 23.359-24.257-48.546-49.413" fill="#7AC043"/></svg> \ No newline at end of file diff --git a/images/frameworks/wordpress.svg b/images/frameworks/wordpress.svg deleted file mode 100644 index 57e7c4d24..000000000 --- a/images/frameworks/wordpress.svg +++ /dev/null @@ -1 +0,0 @@ -<svg width="2500" height="2490" viewBox="0 0 256 255" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet"><path d="M18.124 127.5c0 43.296 25.16 80.711 61.646 98.442L27.594 82.986a108.965 108.965 0 0 0-9.47 44.514zm183.221-5.52c0-13.517-4.856-22.879-9.02-30.165-5.545-9.01-10.742-16.64-10.742-25.65 0-10.055 7.626-19.415 18.368-19.415.485 0 .944.06 1.417.088-19.46-17.829-45.387-28.714-73.863-28.714-38.213 0-71.832 19.606-91.39 49.302 2.566.077 4.984.13 7.039.13 11.44 0 29.15-1.387 29.15-1.387 5.897-.348 6.592 8.312.702 9.01 0 0-5.926.697-12.52 1.042L100.32 194.7l23.937-71.79-17.042-46.692c-5.89-.345-11.47-1.042-11.47-1.042-5.894-.346-5.203-9.358.691-9.01 0 0 18.064 1.388 28.811 1.388 11.44 0 29.151-1.388 29.151-1.388 5.9-.348 6.594 8.312.702 9.01 0 0-5.938.697-12.52 1.042l39.529 117.581 10.91-36.458c4.728-15.129 8.327-25.995 8.327-35.36zm-71.921 15.088l-32.818 95.363a109.376 109.376 0 0 0 30.899 4.456c12.737 0 24.952-2.202 36.323-6.2a9.605 9.605 0 0 1-.779-1.507l-33.625-92.112zm94.058-62.045c.47 3.484.737 7.224.737 11.247 0 11.1-2.073 23.577-8.317 39.178l-33.411 96.6c32.518-18.963 54.39-54.193 54.39-94.545.002-19.017-4.856-36.9-13.4-52.48zM127.505 0C57.2 0 0 57.196 0 127.5c0 70.313 57.2 127.507 127.505 127.507 70.302 0 127.51-57.194 127.51-127.507C255.014 57.196 197.808 0 127.506 0zm0 249.163c-67.08 0-121.659-54.578-121.659-121.663 0-67.08 54.576-121.654 121.659-121.654 67.078 0 121.652 54.574 121.652 121.654 0 67.085-54.574 121.663-121.652 121.663z" fill="#464342"/></svg> \ No newline at end of file diff --git a/images/mailpit.svg b/images/mailpit.svg new file mode 100644 index 000000000..41fd0b1a7 --- /dev/null +++ b/images/mailpit.svg @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg width="350" height="190" viewBox="0 0 264.584 243.416" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> + <defs id="defs10"/> + <rect width="100%" height="100%" fill="#2C3E50" /> + <g transform="translate(65, 65)"> + <path d="M12.321 0l53.861 53.918L120.365 0zM5.155 9.025l60.842 59.673 61.211-59.489-.185 36.835L66.921 70.54l15.164 12.616-8.137 5.986-41.609.184c-4.838-.022-25.877-18.34-27.185-41.255z" fill-opacity=".941" fill="#2d4a5f" id="path2" style="fill:#ffffff;fill-opacity:1"/> + <path d="M78.385 72.049l53.907-21.679-8.031 57.318-11.845-9.132c-21.727 23.171-45.255 26.289-67.997 20.837S12.281 98.39 5.155 83.8-.67 53.116 2.843 38.769c1.13 10.511-1.313 16.316 6.38 33.612 6.31 11.399 14.413 20.417 25.89 24.956 13.9 6.195 32.247 3.357 41.701-3.039l14.24-12.156z" fill="#00b786" id="path4"/> + </g> +</svg> diff --git a/index.html b/index.html index 688e729ef..aa32aa426 100644 --- a/index.html +++ b/index.html @@ -4,162 +4,118 @@ --- <div class="bg-white"> - <div class="container"> - <div class="row"> - - <div class="col-lg-12 feature"> - <h2>Benefits<span class="blue">_</span></h2> - </div> - - <div class="col-sm-6 feature clearfix"> - <svg width="70" height="70" viewBox="0 0 70 70" fill="none" xmlns="http://www.w3.org/2000/svg"><path stroke="#226AFD" stroke-width="5" d="M2.5 48.5h65v19h-65z"/><circle cx="34.5" cy="20.5" r="18" stroke="#226AFD" stroke-width="5"/></svg> - - <h3>User_Centric_Tests</h3> - - <p> - Codeception provides high-level domain language for tests. - Tests are represented as a set of user's actions. - </p> - - <a class="btn btn-default" href="/docs/02-GettingStarted">Learn More</a> - </div> - - <div class="col-sm-6 feature clearfix"> - <svg width="70" height="70" viewBox="0 0 70 70" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 0v58.333h32.083v5.834h-17.5V70h40.834v-5.833h-17.5v-5.834H70V0H0zm64.167 52.5H5.833v-5.833h58.334V52.5zm0-11.667H5.833v-35h58.334v35z" fill="#236BFD"/></svg> - - <h3>Browser_Testing</h3> - - <p> - Tests can be executed using Firefox, Chrome, Safari or Cloud Testing services with <strong>Selenium - WebDriver</strong>. Browser can be emulated with HTTP-requests through CURL with PhpBrowser. - </p> - - <a class="btn btn-default" href="/docs/03-AcceptanceTests">Learn More</a> - </div> - </div> - - - <div class="row"> - - <div class="col-sm-6 feature clearfix"> - <svg width="70" height="71" viewBox="0 0 70 71" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M70 20.46V.045H49.572v7.292h-14.58v24.791H26.26V17.544h-5.832v5.833H0v23.334h20.428v5.833h5.832V37.96h8.732v24.791h14.58v7.292H70V49.627H49.572v7.292h-8.748V37.96h8.748v5.833h5.832v-17.5h-5.832v5.833h-8.748V13.17h8.748v7.292H70zM55.404 5.878h8.764v8.75h-8.764v-8.75zm-34.992 35H5.832V29.211h14.58v11.666zm34.992 21.875v-7.291h8.764v8.75h-8.764v-1.459z" fill="#226AFD"/></svg> - - <h3>Framework_Testing</h3> - - <p> - Tests can be executed inside a PHP framework. This way web application can be executed without web server to - running faster and accessing application internals. <strong>Symfony</strong>, <strong>Laravel</strong>, - <strong>Zend Framework</strong>, <strong>Yii</strong>, <strong>Phalcon</strong> are supported. - </p> - - <a class="btn btn-default" href="/docs/04-FunctionalTests">Learn More</a> - </div> - - <div class="col-sm-6 feature clearfix"> - <svg width="70" height="70" viewBox="0 0 70 70" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.75 23.333v23.334h5.833v-5.834h5.834v5.834h5.833V23.333H8.75zM20.417 35h-5.834v-5.833h5.834V35zM37.917 23.333h-5.834v23.334h5.834v-5.834h11.666v-17.5H37.917zM43.75 35h-5.833v-5.833h5.833V35zM61.25 23.333h-5.833v23.334h5.833V23.333zM42.04 7.292L35 .249l-7.04 7.043H0v11.666h5.833v-5.833h24.541L35 8.501l4.626 4.624h24.54v5.833H70V7.292H42.04zM64.167 51.042v5.833H39.626L35 61.499l-4.626-4.624H5.834v-5.833H0v11.666h27.96L35 69.751l7.04-7.043H70V51.042h-5.833z" fill="#236BFD"/></svg> - - <h3>API_Testing</h3> - - <p> - Codeception simplifies <strong>REST</strong> and <strong>SOAP</strong> testing. - There are flexible commands to test structure and data of JSON and XML responses. - Testing can be done over HTTP or inside a framework. - </p> - - <a class="btn btn-default" href="/docs/10-APITesting">Learn More</a> - </div> - </div> - - <div class="row"> - <div class="col-sm-6 feature clearfix"> - <svg width="70" height="70" viewBox="0 0 70 70" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 0v70h70V0H0zm64.167 64.167H5.833V17.5h58.334v46.667zm0-52.5H5.833V5.833h58.334v5.834z" fill="#236BFD"/></svg> - - <h3>Data Driven Tests_</h3> - - <p> - Connect to various data sources - <strong>MySQL, PostgreSQL, MongoDB, Redis, Memcache</strong> to use their data inside tests. - Take <strong>snapshots</strong> to compare data changes with previous runs. - </p> - - <a class="btn btn-default" href="/docs/09-Data">Learn More</a> - </div> - - <div class="col-sm-6 feature clearfix"> - <svg width="70" height="70" viewBox="0 0 70 70" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M70 5.833V0H0v70h70V58.333h-5.833v5.834h-5.834V50.512C65.384 47.172 70 40.017 70 32.083c0-8.645-5.472-16.378-13.615-19.245L52.5 11.47v17.696h-5.833V11.47l-3.885 1.368c-8.144 2.866-13.615 10.6-13.615 19.244 0 7.938 4.621 15.099 11.666 18.43v13.654h-35V17.5h23.334v-5.833H5.833V5.833H70zM52.5 64.167h-5.833V52.293c.256.036.519.057.778.083.171.018.342.04.514.056 1.079.084 2.168.084 3.247 0 .177-.015.352-.038.527-.057.257-.027.513-.046.767-.082v11.874zM35 32.083c0-4.668 2.231-8.963 5.833-11.665V35h17.5V20.418a14.595 14.595 0 015.834 11.665 14.589 14.589 0 01-9.738 13.75c-2.307.83-4.875 1.036-7.313.622-.817-.14-1.62-.35-2.398-.63C38.905 43.781 35 38.256 35 32.083z" fill="#236BFD"/><path d="M17.5 52.5V29.167h5.833v-5.834H11.667v35h17.5V52.5H17.5z" fill="#236BFD"/></svg> - - <h3>Unit & Integration Testing</h3> - - <p> - Codeception is built on top of <strong>PHPUnit</strong> and is able to execute its tests. - </p> - - <a class="btn btn-default" href="/docs/05-UnitTests">Learn More</a> - </div> + <div class="container"> + <div class="row"> + <div class="col-lg-12 feature"> + <h2>Benefits<span class="blue">_</span></h2> + </div> + <div class="col-sm-6 feature clearfix"> + <svg xmlns="http://www.w3.org/2000/svg" width="70" height="70" fill="none" viewBox="0 0 70 70"><path stroke="#226AFD" stroke-width="5" d="M2.5 48.5h65v19h-65z"/><circle cx="34.5" cy="20.5" r="18" stroke="#226AFD" stroke-width="5"/></svg> + <h3>User_Centric_Tests</h3> + <p> + Codeception provides high-level domain language for tests. + Tests are represented as a set of user's actions. + </p> + <a class="btn btn-default" href="/docs/02-GettingStarted">Learn More</a> + </div> + <div class="col-sm-6 feature clearfix"> + <svg xmlns="http://www.w3.org/2000/svg" width="70" height="70" fill="none" viewBox="0 0 70 70"><path fill="#236BFD" d="M0 0v58.333h32.083v5.834h-17.5V70h40.834v-5.833h-17.5v-5.834H70V0H0zm64.167 52.5H5.833v-5.833h58.334V52.5zm0-11.667H5.833v-35h58.334v35z"/></svg> + <h3>Browser_Testing</h3> + <p> + Tests can be executed using Firefox, Chrome, Safari or Cloud Testing services with <strong>Selenium + WebDriver</strong>. Browser can be emulated with HTTP-requests through CURL with PhpBrowser. + </p> + <a class="btn btn-default" href="/docs/03-AcceptanceTests">Learn More</a> + </div> + </div> + <div class="row"> + <div class="col-sm-6 feature clearfix"> + <svg xmlns="http://www.w3.org/2000/svg" width="70" height="71" fill="none" viewBox="0 0 70 71"><path fill="#226AFD" d="M70 20.46V.045H49.572v7.292h-14.58v24.791H26.26V17.544h-5.832v5.833H0v23.334h20.428v5.833h5.832V37.96h8.732v24.791h14.58v7.292H70V49.627H49.572v7.292h-8.748V37.96h8.748v5.833h5.832v-17.5h-5.832v5.833h-8.748V13.17h8.748v7.292H70zM55.404 5.878h8.764v8.75h-8.764v-8.75zm-34.992 35H5.832V29.211h14.58v11.666zm34.992 21.875v-7.291h8.764v8.75h-8.764v-1.459z"/></svg> + <h3>Framework_Testing</h3> + <p> + Tests can be executed inside a PHP framework. This way web application can be executed without web + server to + running faster and accessing application internals. <strong>Symfony</strong>, + <strong>Laravel</strong>, + <strong>Zend Framework</strong>, <strong>Yii</strong>, <strong>Phalcon</strong> are supported. + </p> + <a class="btn btn-default" href="/docs/04-FunctionalTests">Learn More</a> + </div> + <div class="col-sm-6 feature clearfix"> + <svg xmlns="http://www.w3.org/2000/svg" width="70" height="70" fill="none" viewBox="0 0 70 70"><path fill="#236BFD" d="M8.75 23.333v23.334h5.833v-5.834h5.834v5.834h5.833V23.333H8.75zM20.417 35h-5.834v-5.833h5.834V35zm17.5-11.667h-5.834v23.334h5.834v-5.834h11.666v-17.5H37.917zM43.75 35h-5.833v-5.833h5.833V35zm17.5-11.667h-5.833v23.334h5.833V23.333zM42.04 7.292 35 .249l-7.04 7.043H0v11.666h5.833v-5.833h24.541L35 8.501l4.626 4.624h24.54v5.833H70V7.292H42.04zm22.127 43.75v5.833H39.626L35 61.499l-4.626-4.624H5.834v-5.833H0v11.666h27.96L35 69.751l7.04-7.043H70V51.042h-5.833z"/></svg> + <h3>API_Testing</h3> + <p> + Codeception simplifies <strong>REST</strong> and <strong>SOAP</strong> testing. + There are flexible commands to test structure and data of JSON and XML responses. + Testing can be done over HTTP or inside a framework. + </p> + <a class="btn btn-default" href="/docs/10-APITesting">Learn More</a> + </div> + </div> + <div class="row"> + <div class="col-sm-6 feature clearfix"> + <svg xmlns="http://www.w3.org/2000/svg" width="70" height="70" fill="none" viewBox="0 0 70 70"><path fill="#236BFD" d="M0 0v70h70V0H0zm64.167 64.167H5.833V17.5h58.334v46.667zm0-52.5H5.833V5.833h58.334v5.834z"/></svg> + <h3>Data Driven Tests_</h3> + <p> + Connect to various data sources + <strong>MySQL, PostgreSQL, MongoDB, Redis, Memcache</strong> to use their data inside tests. + Take <strong>snapshots</strong> to compare data changes with previous runs. + </p> + <a class="btn btn-default" href="/docs/09-Data">Learn More</a> + </div> + <div class="col-sm-6 feature clearfix"> + <svg xmlns="http://www.w3.org/2000/svg" width="70" height="70" fill="none" viewBox="0 0 70 70"><path fill="#236BFD" d="M70 5.833V0H0v70h70V58.333h-5.833v5.834h-5.834V50.512C65.384 47.172 70 40.017 70 32.083c0-8.645-5.472-16.378-13.615-19.245L52.5 11.47v17.696h-5.833V11.47l-3.885 1.368c-8.144 2.866-13.615 10.6-13.615 19.244a20.42 20.42 0 0 0 11.666 18.43v13.654h-35V17.5h23.334v-5.833H5.833V5.833H70zM52.5 64.167h-5.833V52.293c.256.036.519.057.778.083.171.018.342.04.514.056a20.95 20.95 0 0 0 3.247 0c.177-.015.352-.038.527-.057.257-.027.513-.046.767-.082v11.874zM35 32.083c0-4.668 2.231-8.963 5.833-11.665V35h17.5V20.418a14.595 14.595 0 0 1 5.834 11.665 14.589 14.589 0 0 1-9.738 13.75c-2.307.83-4.875 1.036-7.313.622-.817-.14-1.62-.35-2.398-.63C38.905 43.781 35 38.256 35 32.083z"/><path fill="#236BFD" d="M17.5 52.5V29.167h5.833v-5.834H11.667v35h17.5V52.5H17.5z"/></svg> + <h3>Unit & Integration Testing</h3> + <p> + Codeception is built on top of <strong>PHPUnit</strong> and is able to execute its tests. + </p> + <a class="btn btn-default" href="/docs/05-UnitTests">Learn More</a> + </div> + </div> </div> - </div> </div> - <div class="bg-white community-wrapper"> - - <div class="container"> - - - <div class="row"> - - - <div class="col-sm-12 col-lg-6"> - <h3 class="text-center">Voice of Developers_</h3> - - <div id="carousel-tweets" data-interval="10000" class="carousel slide" data-ride="carousel"> - - <!-- Wrapper for slides --> - <div class="carousel-inner" title="tweets"> - - - {%include tweets.html %} - - </div> - - <!-- Controls --> - <a class="right carousel-control" href="#carousel-tweets" role="button" data-slide="next"> - <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> - <span class="sr-only">Next</span> - </a> + <div class="container"> + <div class="row"> + <div class="col-sm-12 col-lg-6"> + <h3 class="text-center">Voice of Developers_</h3> + <div id="carousel-tweets" data-interval="10000" class="carousel slide" data-ride="carousel"> + <!-- Wrapper for slides --> + <div class="carousel-inner" title="tweets"> + {%include tweets.html %} + </div> + <!-- Controls --> + <a class="right carousel-control" href="#carousel-tweets" role="button" data-slide="next"> + <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> + <span class="sr-only">Next</span> + </a> + </div> + </div> + <div class="col-sm-12 col-lg-6"> + <h3 class="text-center">Trusted By_</h3> + <div data-interval="10000" id="carousel-companies" class="carousel slide" data-ride="carousel"> + <!-- Wrapper for slides --> + <div class="carousel-inner" title="companies"> + {% include companies.html %} + </div> + <!-- Controls --> + <a class="right carousel-control" href="#carousel-companies" role="button" data-slide="next"> + <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> + <span class="sr-only">Next</span> + </a> + </div> + <p class="text-center"> + <a href="https://github.com/Codeception/Codeception/wiki/Who-is-using-it%3F">...and many others. Add + your + company too!</a> + </p> + </div> </div> - </div> - - <div class="col-sm-12 col-lg-6"> - <h3 class="text-center">Trusted By_</h3> - - <div data-interval="10000" id="carousel-companies" class="carousel slide" data-ride="carousel"> - - <!-- Wrapper for slides --> - <div class="carousel-inner" title="companies"> - {% include companies.html %} - </div> - - <!-- Controls --> - <a class="right carousel-control" href="#carousel-companies" role="button" data-slide="next"> - <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> - <span class="sr-only">Next</span> - </a> - </div> - - <p class="text-center"> - - <a href="https://github.com/Codeception/Codeception/wiki/Who-is-using-it%3F">...and many others. Add your - company too!</a> - </p> - - </div> </div> - </div> </div> - <div class="bg-grey"> - <div class="container"> - <h2 class="text-center">Use_With</h2> - {% include for.html %} - </div> + <div class="container"> + <h2 class="text-center">Use_With</h2> + {% include frameworks.html %} + </div> </div> diff --git a/install.html b/install.html index 940b02932..59c333e12 100644 --- a/install.html +++ b/install.html @@ -3,80 +3,77 @@ title: Codeception Installation --- <div class="container"> - <div class="page-header"> - <div class="intro-block"> - <h1>Installation</h1> - <div class="pull-right well well-custom"> - <h4>Requirements</h4> - <strong>PHP 5.6+</strong> - <strong>CURL enabled</strong> - </div> + <div class="page-header"> + <div class="intro-block"> + <h1>Installation</h1> + <div class="pull-right well well-custom"> + <h4>Requirements</h4> + <strong>PHP 5.6+</strong> + <strong>CURL enabled</strong> + </div> + </div> + </div> + <div class="row"> + <div class="col-sm-8 col-lg-8"> + <div class="well well-custom-row"> + <h4>Follow QuickStart Guide to Install and execute your first test in 6 easy + steps. + </h4> + <a class="btn btn-lg btn-warning" href="/quickstart">QuickStart Guide →</a> + </div> + </div> </div> - </div> - <div class="row"> - <div class="col-sm-8 col-lg-8"> - <div class="well well-custom-row"> - <h4>Follow QuickStart Guide to Install and execute your first test in 6 easy - steps. - </h4> - <a class="btn btn-lg btn-warning" href="/quickstart">QuickStart Guide →</a> - </div> + <div class="row"> + <div class="col-sm-6 col-lg-6"> + <div class="page"> + <h3>Composer <small><i>(recommended)</i></small></h3> + <p>To install via <a href="https://getcomposer.org">Composer</a>, run this in your project's root:</p> + <div class="highlight"> + <pre><code>composer require "codeception/codeception" --dev</code></pre> + </div> + <p>From now on Codeception (with installed PHPUnit) can be run as:</p> + <div class="highlight"> + <pre><code>php vendor/bin/codecept</code></pre> + </div> + <p>Initialize your testing environment with</p> + <div class="highlight"> + <pre><code>php vendor/bin/codecept bootstrap</code></pre> + </div> + </div> + </div> + <div class="col-sm-6 col-lg-6"> + <h3>Phar</h3> + {% include phar.html %} + </div> </div> - </div> - <div class="row"> - <div class="col-sm-6 col-lg-6"> - <div class="page"> - <h3>Composer <small><i>(recommended)</i></small></h3> - <p>Install a <a href="https://getcomposer.org">Composer</a> to your project's root</p> - <p>Run</p> + <hr> + <div class="row page"> + <h3>Git</h3> + <p>Alternative installation method for bugfixing, contributions and hacking</p> + <p> + Clone from GitHub: + </p> <div class="highlight"> - <pre><code>composer require codeception/codeception --dev</code></pre> + <pre><code>git clone git@github.com:Codeception/Codeception.git && cd Codeception</code></pre> </div> - <p>From now on Codeception (with installed PHPUnit) can be run as:</p> + <p> + Install dependencies with Composer + </p> <div class="highlight"> - <pre><code>php vendor/bin/codecept</code></pre> + <pre><code>composer install</code></pre> </div> - <p>Initialize your testing environment with</p> + <p> + Execute bootstrap, specifying path to your directory. + </p> <div class="highlight"> - <pre><code>php vendor/bin/codecept bootstrap</code></pre> + <pre><code>php codecept bootstrap /path/to/demo/project</code></pre> </div> - </div> - - </div> - <div class="col-sm-6 col-lg-6"> - <h3>Phar</h3> - {% include phar.html %} - </div> - - </div> - <hr> - <div class="row page"> - <h3>Git</h3> - <p>Alternative installation method for bugfixing, contributions and hacking</p> - <p> - Clone from GitHub: - </p> - <div class="highlight"> - <pre><code>git clone git@github.com:Codeception/Codeception.git && cd Codeception</code></pre> + <p> + To <strong>run tests</strong> use <code>-c</code> option for specifing path. + </p> + <div class="highlight"> + <pre><code>php codecept run -c /path/to/demo/project</code></pre> + </div> + <p>Don't forget to send Pull Requests!</p> </div> - <p> - Install dependencies with Composer - </p> - <div class="highlight"> - <pre><code>composer install</code></pre> - </div> - <p> - Execute bootstrap, specifying path to your directory. - </p> - <div class="highlight"> - <pre><code>php codecept bootstrap /path/to/demo/project</code></pre> - </div> - <p> - To <strong>run tests</strong> use <code>-c</code> option for specifing path. - </p> - <div class="highlight"> - <pre><code>php codecept run -c /path/to/demo/project</code></pre> - </div> - <p>Don't forget to send Pull Requests!</p> - </div> </div> <!-- /.container --> diff --git a/package/README.md b/package/README.md index dcaa60786..07bac74b2 100644 --- a/package/README.md +++ b/package/README.md @@ -2,8 +2,8 @@ This directory contains files necessary for building Phar file Modules excluded from phar file: * datafactory -* doctrine2 -* laravel5 +* doctrine +* laravel * lumen * phalcon * symfony @@ -17,13 +17,7 @@ Additional dependency compared with codeception/codecepion: ### Build instructions 1. Install dependencies by running `composer install` in parent directory. 2. Disable phar.readonly in your php.ini file, it must be `phar.readonly = Off` -3. Build Codeception 4 phar file: - 1. Run `./vendor/bin/robo build:phar72` - 2. Run `./vendor/bin/robo build:phar56` - 3. Run `./vendor/bin/robo release` -4. Build Codeception 5 phar file: - 1. Run `./vendor/bin/robo build:phar80` - 2. Run `./vendor/bin/robo release80` -5. Commit added files and push - -Note: it is necessary to delete package/composer.lock and package/vendor between Codeception 4 and 5 builds. \ No newline at end of file +3. Build Codeception 5.3 phar file + 1. Run `./vendor/bin/robo build:phar82` + 2. Run `./vendor/bin/robo release82` +4. Commit added files and push \ No newline at end of file diff --git a/php80/codecept.phar b/php80/codecept.phar index 79ad140e2..e8e049b37 120000 --- a/php80/codecept.phar +++ b/php80/codecept.phar @@ -1 +1 @@ -../releases/5.0.20230314/codecept.phar \ No newline at end of file +../releases/5.1.20240307/codecept.phar \ No newline at end of file diff --git a/php80/codecept.version b/php80/codecept.version index 4b8c7edb3..b898d9daf 100644 --- a/php80/codecept.version +++ b/php80/codecept.version @@ -1 +1 @@ -edf1864a9cd41caa0360fc90b0c68a7aefe0cc9f \ No newline at end of file +57f41236a5933923d4e510e3e88274883a36e7fd \ No newline at end of file diff --git a/quickstart.html b/quickstart.html index d38476b9a..ad4a57445 100644 --- a/quickstart.html +++ b/quickstart.html @@ -1,6 +1,6 @@ --- layout: bootstrap -title: Quick Start Codeception +title: Quickstart Codeception --- <div class="row"> @@ -44,34 +44,24 @@ <h4 class="panel-title">1.Install</h4> <div class="row"> <div class="col-sm-12 col-md-6"> <div class="panel panel-info"> - <div class="panel-heading"><h4 class="panel-title">2. Setup</h4></div> + <div class="panel-heading"><h4 class="panel-title">2. Bootstrap</h4></div> <div class="panel-body"> <p>Execute:</p> <div class="highlight"> <p> <pre>php vendor/bin/codecept bootstrap</pre> </div> - <p class="text-muted">This creates configuration file - <b>codeception.yml</b> and <b>tests</b> directory and default test suites. + <p class="text-muted">This creates the global configuration file + <b>codeception.yml</b>, the <b>tests/</b> directory, and the default test suites. </p> - - <a class="btn btn-primary" role="button" data-toggle="collapse" href="#bootstrap-demo" aria-expanded="false"> - See Demo - </a> - - <div class="collapse" id="bootstrap-demo"> - <div class="panel-collapse-body"> - <img src="/images/codecept_bootstrap.gif" alt="codeception bootstrap" class="img-responsive"> - </div> - </div> </div> <!-- /.panel-body --> </div> <!-- /.panel --> <div class="panel panel-info"> <div class="panel-heading"><h4 class="panel-title">3. Create Test</h4></div> <div class="panel-body"> - <p>Generate your first acceptance test. Acceptance tests emulate behavior - of a real user visiting your site.</p> + <p>Generate your first acceptance test. Acceptance tests emulate the behavior + of a real user visiting your site.<br><a href="/docs/AcceptanceTests" class="btn btn-secondary">Acceptance Testing Guide »</a></p> <div class="highlight"> <p> <pre>php vendor/bin/codecept generate:cest Acceptance First</pre> @@ -79,27 +69,9 @@ <h4 class="panel-title">1.Install</h4> </div> <!-- /.panel-body --> </div> <!-- /.panel --> - <div class="panel panel-info"> - <div class="panel-heading"><h4 class="panel-title">4. Configure Acceptance Tests</h4></div> - <div class="panel-body"> - <p>Please make sure your local - <b>development server</b> is running.  Put application URL into:  - <b>tests/Acceptance.suite.yml</b> </p> - <div class="highlight"> - <pre> -actor: AcceptanceTester -modules: - enabled: - - PhpBrowser: - url: {YOUR APP'S URL} - </pre> - </div> - </div> <!-- /.panel-body --> - </div> <!-- /.panel --> - <div class="panel panel-info"> <div class="panel-heading"> - <h4 class="panel-title">5. Write a Basic Test</h4> + <h4 class="panel-title">4. Write a Basic Test</h4> </div> <div class="panel-body"> <p>It's now time to write your first test. Edit the file we've just created @@ -123,6 +95,24 @@ <h4 class="panel-title">5. Write a Basic Test</h4> </div> <!-- /.panel-body --> </div> <!-- /.panel --> + <div class="panel panel-info"> + <div class="panel-heading"><h4 class="panel-title">5. Configure Acceptance Tests</h4></div> + <div class="panel-body"> + <p>Please make sure your local + <b>development server</b> is running.  Put application URL into:  + <b>tests/Acceptance.suite.yml</b> </p> + <div class="highlight"> + <pre> +actor: AcceptanceTester +modules: + enabled: + - PhpBrowser: + url: {YOUR APP'S URL} + </pre> + </div> + </div> <!-- /.panel-body --> + </div> <!-- /.panel --> + <div class="panel panel-info"> <div class="panel-heading"><h4 class="panel-title">6. Run!</h4></div> <div class="panel-body"> @@ -143,11 +133,9 @@ <h4 class="panel-title">5. Write a Basic Test</h4> <div class="col-sm-12 col-md-6"> <div class="page"> - <h3>Simplified Setup</h3> + <h3>Setup for a Single Test Suite</h3> - <p>Use predefined installation templates for common use cases. - Run them instead of <code>bootstrap</code> command. - </p> + <p>Instead of the <code>bootstrap</code> command, you can set up just a single test suite.</p> <h4>Acceptance Testing (only)</h4> @@ -155,15 +143,7 @@ <h4>Acceptance Testing (only)</h4> <pre>php vendor/bin/codecept init Acceptance</pre> </div> - <a class="btn btn-primary" role="button" data-toggle="collapse" href="#acceptance-demo" aria-expanded="false"> - See Demo - </a> <a href="/docs/03-AcceptanceTests" class="btn btn-secondary">Acceptance Testing Guide »</a> - - <div class="collapse" id="acceptance-demo"> - <div class="panel-collapse-body"> - <img src="/images/codecept_acceptance.gif" alt="codeception acceptance" class="img-responsive"> - </div> - </div> + <a href="/docs/AcceptanceTests" class="btn btn-secondary">Acceptance Testing Guide »</a> <hr> @@ -173,18 +153,7 @@ <h4>REST API Testing (only)</h4> <pre>php vendor/bin/codecept init Api</pre> </div> - - <a class="btn btn-primary" role="button" data-toggle="collapse" href="#api-demo" aria-expanded="false"> - See Demo - </a> - - <a href="/docs/10-APITesting" class="btn btn-secondary">REST API Testing Guide »</a> - - <div class="collapse" id="api-demo"> - <div class="panel-collapse-body"> - <img src="/images/codecept_api.gif" alt="codeception api" class="img-responsive"> - </div> - </div> + <a href="/docs/APITesting" class="btn btn-secondary">REST API Testing Guide »</a> <hr> @@ -194,17 +163,7 @@ <h4>Unit Testing (only)</h4> <pre>php vendor/bin/codecept init Unit</pre> </div> - <a class="btn btn-primary" role="button" data-toggle="collapse" href="#unit-demo" aria-expanded="false"> - See Demo - </a> - - <a href="/docs/05-UnitTests" class="btn btn-secondary">Unit Testing Guide »</a> - - <div class="collapse" id="unit-demo"> - <div class="panel-collapse-body"> - <img src="/images/codecept_unit.gif" alt="codeception unit" class="img-responsive"> - </div> - </div> + <a href="/docs/UnitTests" class="btn btn-secondary">Unit Testing Guide »</a> </div> diff --git a/releases/5.0.20231015/codecept.phar b/releases/5.0.20231015/codecept.phar new file mode 100644 index 000000000..d3ee9fce8 Binary files /dev/null and b/releases/5.0.20231015/codecept.phar differ diff --git a/releases/5.0.20231222/codecept.phar b/releases/5.0.20231222/codecept.phar new file mode 100644 index 000000000..a0b358b99 Binary files /dev/null and b/releases/5.0.20231222/codecept.phar differ diff --git a/releases/5.1.20240204/codecept.phar b/releases/5.1.20240204/codecept.phar new file mode 100644 index 000000000..bb186cfe2 Binary files /dev/null and b/releases/5.1.20240204/codecept.phar differ diff --git a/releases/5.1.20240307/codecept.phar b/releases/5.1.20240307/codecept.phar new file mode 100644 index 000000000..1133d8436 Binary files /dev/null and b/releases/5.1.20240307/codecept.phar differ diff --git a/thanks.html b/thanks.html index 1b6d0afbf..a3d7ac6d3 100644 --- a/thanks.html +++ b/thanks.html @@ -1,24 +1,21 @@ --- layout: bootstrap title: Thanks for choosing Codeception! -meta: <meta http-equiv="REFRESH" content="3;url=https://codeception.com/codecept.phar"> +meta: +<meta http-equiv="REFRESH" content="3;url=https://codeception.com/codecept.phar"> --- <div class="container"> - <div class="row"> - <div class="col-xs-12 fill-thanks"> - <h2>Installation - Codeception v4 Phar for PHP 7.2-8.2</h2> - - <p><strong>1.</strong> Save this file into the root of desired PHP project</p> - - <p><strong>2.</strong> Initialize test classes inside the root of your project</p> - - <p><code>php codecept.phar bootstrap</code></p> - - <p><strong>3.</strong> Write your tests!</p> - - <p>Follow <a href="https://codeception.com/docs/4.x/GettingStarted"> Getting Started Guide</a> to perform configuration and write the first test.</p> - - <p class="small">Your download is on the way. <a href="https://codeception.com/codecept.phar">Click here</a> if you don't want to wait any longer</p> + <div class="row"> + <div class="col-xs-12 fill-thanks"> + <h2>Installation - Codeception v4 Phar for PHP 7.2-8.2</h2> + <p><strong>1.</strong> Save this file into the root of desired PHP project</p> + <p><strong>2.</strong> Initialize test classes inside the root of your project</p> + <p><code>php codecept.phar bootstrap</code></p> + <p><strong>3.</strong> Write your tests!</p> + <p>Follow <a href="https://codeception.com/docs/4.x/GettingStarted"> Getting Started Guide</a> to perform + configuration and write the first test.</p> + <p class="small">Your download is on the way. <a href="https://codeception.com/codecept.phar">Click here</a> + if you don't want to wait any longer</p> + </div> </div> - </div> </div> diff --git a/thanks_php5.html b/thanks_php5.html index 38bff143b..0cc434679 100644 --- a/thanks_php5.html +++ b/thanks_php5.html @@ -1,24 +1,21 @@ --- layout: bootstrap title: Thanks for choosing Codeception! -meta: <meta http-equiv="REFRESH" content="3;url=https://codeception.com/php56/codecept.phar"> +meta: +<meta http-equiv="REFRESH" content="3;url=https://codeception.com/php56/codecept.phar"> --- <div class="container"> - <div class="row"> - <div class="col-xs-12 fill-thanks"> - <h2>Installation - Codeception v4 Phar for PHP 5.6-7.1</h2> - - <p><strong>1.</strong> Save this file into the root of desired PHP project</p> - - <p><strong>2.</strong> Initialize test classes inside the root of your project</p> - - <p><code>php codecept.phar bootstrap</code></p> - - <p><strong>3.</strong> Write your tests!</p> - - <p>Follow <a href="https://codeception.com/docs/4.x/GettingStarted"> Getting Started Guide</a> to perform configuration and write the first test.</p> - - <p class="small">Your download is on the way. <a href="https://codeception.com/php56/codecept.phar"> Click here</a> if you don't want to wait any longer</p> + <div class="row"> + <div class="col-xs-12 fill-thanks"> + <h2>Installation - Codeception v4 Phar for PHP 5.6-7.1</h2> + <p><strong>1.</strong> Save this file into the root of desired PHP project</p> + <p><strong>2.</strong> Initialize test classes inside the root of your project</p> + <p><code>php codecept.phar bootstrap</code></p> + <p><strong>3.</strong> Write your tests!</p> + <p>Follow <a href="https://codeception.com/docs/4.x/GettingStarted"> Getting Started Guide</a> to perform + configuration and write the first test.</p> + <p class="small">Your download is on the way. <a href="https://codeception.com/php56/codecept.phar"> Click + here</a> if you don't want to wait any longer</p> + </div> </div> - </div> </div> diff --git a/thanks_php80.html b/thanks_php80.html index 23b201365..459893dd1 100644 --- a/thanks_php80.html +++ b/thanks_php80.html @@ -1,24 +1,21 @@ --- layout: bootstrap title: Thanks for choosing Codeception! -meta: <meta http-equiv="REFRESH" content="3;url=https://codeception.com/php80/codecept.phar"> +meta: +<meta http-equiv="REFRESH" content="3;url=https://codeception.com/php80/codecept.phar"> --- <div class="container"> - <div class="row"> - <div class="col-xs-12 fill-thanks"> - <h2>Installation - Codeception v5 Phar for PHP 8.0+</h2> - - <p><strong>1.</strong> Save this file into the root of desired PHP project</p> - - <p><strong>2.</strong> Initialize test classes inside the root of your project</p> - - <p><code>php codecept.phar bootstrap</code></p> - - <p><strong>3.</strong> Write your tests!</p> - - <p>Follow <a href="https://codeception.com/docs/GettingStarted"> Getting Started Guide</a> to perform configuration and write the first test.</p> - - <p class="small">Your download is on the way. <a href="https://codeception.com/php80/codecept.phar"> Click here</a> if you don't want to wait any longer</p> + <div class="row"> + <div class="col-xs-12 fill-thanks"> + <h2>Installation - Codeception v5 Phar for PHP 8.0+</h2> + <p><strong>1.</strong> Save this file into the root of desired PHP project</p> + <p><strong>2.</strong> Initialize test classes inside the root of your project</p> + <p><code>php codecept.phar bootstrap</code></p> + <p><strong>3.</strong> Write your tests!</p> + <p>Follow <a href="https://codeception.com/docs/GettingStarted"> Getting Started Guide</a> to perform + configuration and write the first test.</p> + <p class="small">Your download is on the way. <a href="https://codeception.com/php80/codecept.phar"> Click + here</a> if you don't want to wait any longer</p> + </div> </div> - </div> </div> diff --git a/video.html b/video.html deleted file mode 100644 index 8022b62a1..000000000 --- a/video.html +++ /dev/null @@ -1,43 +0,0 @@ ---- -layout: page -title: Video ---- - -<h1>Video</h1> - -<h2>Getting Started with Codeception</h2> - -<p>By Reval Govender</p> - -<div class="iframe-wrapper"> - <iframe width="560" height="315" title="Introduction to Codeception Unit Tests with Laravel" src="https://www.youtube.com/embed/videoseries?list=PLrIm-p2rpV0Hu9EvTidyYG1vsX0LWIM7Q" allowfullscreen></iframe> -</div> - -<h2>How to TDD a REST API in Laravel</h2> - -<p>By Reval Govender</p> - -<p>This is a detailed course covering how to build a RESTful API using Laravel and Codeception</p> - -<div class="iframe-wrapper"> - <iframe width="560" height="315" title="Part 1 - How to use TDD to build a REST API in Laravel 6" src="https://www.youtube.com/embed/videoseries?list=PLrIm-p2rpV0F-rl4NPjNslEmW-D83AHOr" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -</div> - - -<h2>Codeception in PhpStorm</h2> - -<p>By Gary Hockin</p> - -<div class="iframe-wrapper"> - <iframe width="560" height="315" title="Codeception support in PhpStorm" src="https://www.youtube.com/embed/B3PE7w-jvjQ" allowfullscreen></iframe> -</div> - -<h2>Complete Video Course on Nettuts Premium</h2> - -<p> - Great videos from <strong>Jeffrey Way</strong>. You should definetely start with them if you prefer learn by watching. -</p> - -<a href="https://tutsplus.com/course/modern-testing-in-php-with-codeception/"> - <img src="/images/codeception-nettuts.png" alt="Modern Testing in PHP with Codeception on NetTuts Premium" style="width: 100%;"> -</a> diff --git a/videos.html b/videos.html new file mode 100644 index 000000000..bea9bcf34 --- /dev/null +++ b/videos.html @@ -0,0 +1,36 @@ +--- +layout: page +title: Videos +--- + +<h1>Videos</h1> +<h2>Getting Started with Codeception</h2> +<p>By Reval Govender</p> +<div class="iframe-wrapper"> + <iframe width="560" height="315" title="Introduction to Codeception Unit Tests with Laravel" + src="https://www.youtube.com/embed/videoseries?list=PLrIm-p2rpV0Hu9EvTidyYG1vsX0LWIM7Q" + allowfullscreen></iframe> +</div> +<h2>How to TDD a REST API in Laravel</h2> +<p>By Reval Govender</p> +<p>This is a detailed course covering how to build a RESTful API using Laravel and Codeception</p> +<div class="iframe-wrapper"> + <iframe width="560" height="315" title="Part 1 - How to use TDD to build a REST API in Laravel 6" + src="https://www.youtube.com/embed/videoseries?list=PLrIm-p2rpV0F-rl4NPjNslEmW-D83AHOr" + allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> +</div> +<h2>Codeception in PhpStorm</h2> +<p>By Gary Hockin</p> +<div class="iframe-wrapper"> + <iframe width="560" height="315" title="Codeception support in PhpStorm" + src="https://www.youtube.com/embed/B3PE7w-jvjQ" allowfullscreen></iframe> +</div> +<h2>Complete Video Course on Nettuts Premium</h2> +<p> + Great videos from <strong>Jeffrey Way</strong>. You should definetely start with them if you prefer learn by + watching. +</p> +<a href="https://tutsplus.com/course/modern-testing-in-php-with-codeception/"> + <img src="/images/codeception-nettuts.png" alt="Modern Testing in PHP with Codeception on NetTuts Premium" + style="width: 100%;"> +</a>