/public/wp-content/plugins/events-calendar-pro/tests.md

https://gitlab.com/kath.de/cibedo_cibedo.de · Markdown · 47 lines · 31 code · 16 blank · 0 comment · 0 complexity · f2a1de2a3286c8cdb6987d294c59bfea MD5 · raw file

  1. # Events Calendar PRO tests
  2. This is a brief and quick guide that's covering the bare essentials needed to set up the tests on your local plugin copy.
  3. Please refer to [Codeception](http://codeception.com/docs) and [WP Browser](https://github.com/lucatume/wp-browser) documentation for any issue that's not TEC related.
  4. ## Set up
  5. After cloning the TEX repository on your local machine change directory to the plugin root folder and pull in any needed dependency using [Composer](https://getcomposer.org/):
  6. composer update
  7. when Composer finished the update process (might take a while) set up your own [Codeception](http://codeception.com/) installation running
  8. vendor/bin/wpcept bootstrap
  9. The `wpcept bootstrap` command is a modified version of the default `codecept bootstrap` command that will take care of setting up a WordPress-friendly testing environment.
  10. To be able to run successfully on your system Codeception will need to be configured to look for the right database, the right WordPress installation and so on.
  11. Codeception allows for "distribution" versions of its configuration to be shared among developers, what you define in your local Codeception configuration files will override the "distribution" setting; think of CSS rules.
  12. The repository contains a `codeception.dist.yml` file that Codeception will read before reading the local to your machine `codeception.yml` file.
  13. Copy the distribution version of the Codeception configuration file in the root folder of the plugin
  14. cp codeception.dist.yml codeception.yml
  15. **Edit the file `codeception.yml` file to suit your database, installation folder and web driver settings.**
  16. **Beware**: The `WPLoader` module that's used in functional tests will **destroy** the database it's working on: **do not** point it to the same database you use for development! A good rule of thumb is to have a database for development (e.g. `tec`) and one that will be used for tests (e.g. `tec-tests`).
  17. On the same lines the repository packs "distribution" versions of the `unit.suite.dist.yml`, `functional.suite.dist.yml` and `acceptance.suite.dist.yml` configuration files: there is usually no need to override those but it's worth mentioning they exist.
  18. The last piece of the configuration is the bootstrap file; the repository comes with "distribution" versions of these file in the root folder of the pluging tests (`/tests/_bootstrap.dist.php`) and a bootstrap file specific to each suite (`/tests/acceptance/_bootstrap.dist.php`, `/tests/functional/_bootstrap.dist.php`, `/tests/unit/_bootstrap.dist.php`); remove the root `_bootstrap.php` file Codeception created during bootstrapping and copy the one in the root of the plugin tests (`/tests`)
  19. rm _bootstrap.php
  20. cp _bootstrap.dist.php _bootstrap.php
  21. You *should* not need to edit anything in any bootstrap file to make things work. Do the same for the suite specific bootstrap files
  22. cp acceptance/_bootstrap.dist.php acceptance/_bootstrap.php
  23. cp functional/_bootstrap.dist.php functional/_bootstrap.php
  24. cp unit/_bootstrap.dist.php unit/_bootstrap.php
  25. ## Running the tests
  26. Nothing different from a default Codeception environment so this command will run all the tests
  27. vendor/bin/codecept run
  28. Failing tests are ok in set up terms: the system works. Errors should be reported.
  29. Please refer to [Codeception documentation](http://codeception.com/docs) to learn about more run and configuaration options.
  30. ## Contributing to tests
  31. Should you come up with good utility methods, worthy database configurations and "cool additions" in general for the plugin tests feel free to open a PR and submit them for review.