Download the PHP package tyler36/cypress-cake without Composer
On this page you can find all versions of the php package tyler36/cypress-cake. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cypress-cake
Cypress plugin for CakePHP
- Overview
- Installation
- Helpers
- Clear Database
- Import Database
- Create An Entity
- Run Arbitrary Cake Command
- Contributing
Overview
This add-on adds some helper files for working with Cypress and CakePHP.
- This plugin injects a CSRF token into POST requests made to
cypress-cakeendpoints. - This plugin bypasses
Authenticationoncypress-cakeendpoints.
[!IMPORTANT] This plugin exposes an API to work with the database. It is recommend for local development only. Do not use in production!
Installation
-
Install plugin
-
Install Cypress if not available. Eg.
- via NPM:
npm require cypress - via tyler36/ddev-cypress:
ddev addon get tyler36/ddev-cypress
- via NPM:
- Update
cypress/support/commands.jsto import the helpers
Helpers
| API | Description |
|---|---|
/cypress/clear-database |
Clear all data from database. |
/cypress/import-database |
Import a database file. |
/cypress/csrf-token |
Get a CSRF token. This is required POST forms. |
/cypress/create |
Run a factory to generate a entity. |
/cypress/cake |
Run arbitrary cake commands. |
Clear Database
Use the Cypress command cy.clearDatabase() to clear all data from database.
Import Database
Use cy.importDatabase() to import a SQL file.
By default, this it will import a file located at env('SQL_TESTING_BASE_DUMP'), relative to the root.
However, you can provide a path as the first parameter.
Create An Entity
Use cy.create('User') to generate an entity from a configured factory.
This packages expects to find vierge-noire/cakephp-fixture-factories factories. Please see their documentation for creating factories.
It is possible to pass additional attributes to the factory allowing to to set default data.
For example, the following creates a User entity with the email set to [email protected].
Run Arbitrary Cake Command
Post a request to /cypress/cake to run CakePHP commands.
Contributing
PRs, especially with tests, will be considered.
Contributed and maintained by tyler36