From 46b7c80e61c6be3051709b53c9f9b6ef4c96cb15 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Tue, 16 Mar 2021 18:56:54 +0100 Subject: [PATCH] Deleting incomplete Zend Framework file See https://github.com/Codeception/module-symfony/pull/98#issuecomment-763411842 --- for/zend-framework.md~ | 180 ----------------------------------------- 1 file changed, 180 deletions(-) delete mode 100644 for/zend-framework.md~ diff --git a/for/zend-framework.md~ b/for/zend-framework.md~ deleted file mode 100644 index 6fc175bf1..000000000 --- a/for/zend-framework.md~ +++ /dev/null @@ -1,180 +0,0 @@ ---- -layout: page -title: Codeception for Zend Framework -hero: zf_hero.html -sidebar: | - - ## Codeception Tests - - * Combine **all testing levels** (acceptance, functional, unit) - * Allow **multi-request** functional tests - * **Fast**: Tests are wrapped into Eloquent transaction - * **Scenario-Driven**: described in easy to get PHP DSL - * can be written in **BDD** format with Gherkin - * Great for **REST** and SOAP API testing - - ## Reference - - * [Laravel5 Module](/docs/modules/Laravel5) - * [Demo Application](https://github.com/janhenkgerritsen/codeception-laravel5-sample) - ---- - -## Install - -Install latest stable Codeception via Composer: - -```bash -composer require codeception/codeception --dev -``` - -## Setup - -It is easy to setup tests by running bootstrap command: - -``` -composer exec codecept bootstrap -``` - -This will create `tests` directory and configuration file `codeception.yml`. This also prepares 3 suites for testing: acceptance, functional, and unit. - -## Functional Tests - -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 Laravel5 module: - -```yaml -class_name: FunctionalTester -modules: - enabled: - - Laravel5: - environment_file: .env.testing - - \AppBundle\Helper\Functional -``` - - -
- - Continue to Functional Testing Guide » -
- -Codeception will also use **Eloquent to cleanup changes to database** by wrapping tests into transaction and rolling it back in the end of a test. This makes tests isolated and fast. Laravel5 module allows to access services from DIC container, user authentication methods, fixture generators, check form validations and more. - -To create first functional test for `Login` you should run: - -``` -composer exec codecept g:cest functional Login -``` - -## Unit Tests - -Codeception is powered by PHPUnit so unit and integration test work in a similar manner. To genereate a plain PHPUnit test for `Foo\Bar` class - -``` -composer exec codecept g:phpunit unit "Foo\Bar" -``` - -This generates a standard test inherited from `PHPUnit_Framework_TestCase`. For integration tests you may use Codeception-enhanced format which allows accessing services from DI container, use Eloquent, Data Factories. To have it create a unit test extending `Codeception\Test\Unit` class: - -``` -composer exec codecept g:test unit "Foo\Bar" -``` - -You will need to enable Laravel5 module in `unit.suite.yml` to have its methods inside `$this->tester` object. - -
- - Continue to Unit Testing Guide ». -
- - -### 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. - -```yaml -class_name: AcceptanceTester -modules: - enabled: - - WebDriver: - url: 'https://localhost/' # put your local url - browser: firefox - - \Helper\Acceptance -``` - -Browser can be specified as `firefox`, `chrome`, `phantomjs`, or others. - -Acceptance tests will be executed in development environment using real web server, so settings from `.env.testing` can't be passed to them. - -You can also use Eloquent to create data for acceptance tests. This way you can use data factories and models to prepare and cleanup data for tests. You should enable Laravel5 module with ORM part to add ActiveRecord methods: - -```yaml -class_name: AcceptanceTester -modules: - enabled: - - WebDriver: - url: 'https://localhost/' # put your local url - browser: firefox - - Laravel5 - part: ORM - cleanup: false # can't wrap into transaction - - \Helper\Acceptance -``` - -Laravel5 module won't be able to wrap test execution in a transaction but methods like `haveRecord` or `haveModel` will delete objects they created when test ends. - -### API Tests - -API Tests are done at functional testing level but instead of testing HTML responses on user actions, they test requests and responses via protocols like REST or SOAP. To create api tests you should create a suite for them - -``` -composer exec codecept g:suite api -``` - -You will need to enable `REST`, `Laravel5` module in `tests/api.suite.yml`: - -```yaml -class_name: ApiTester -modules: - enabled: - - REST: - url: /api/v1 - depends: Laravel5 - - \ApiBundle\Helper\Api - config: - - Laravel5: - environment_file: .env.testing - -``` - -Laravel5 module actions like `amOnPage` or `see` should not be available for testing API. This why Laravel5 module is not enabled but declared with `depends` for REST module. Laravel5 should use testing environment which is specified in `config` section - - -
- - Continue to REST API Testing Guide ». -
- -### 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: - -``` -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`. - -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. - -``` -composer exec codecept gherkin:snippets -``` - -In the same manner features can be set up as functional tests. - -
- - Continue to Behavior Driven Development Guide » -
\ No newline at end of file