Skip to content
Snippets Groups Projects
Commit 9bf49f94 authored by Sean Madsen's avatar Sean Madsen
Browse files

Re-organize PhpStorm testing docs

Move them into the dedicated page on PhpStorm. Why? Tim has expressed
some concern about the potential difficulty (and slippery slope) of
starting to maintain IDE-specific docs. I like the PhpStorm page, but I
can see where he's coming from to a certain extent. As such, I think it
will be a good compromise if we can keep all the IDE-specific stuff as
consolidated as possible.
parent 08b4dfc7
No related branches found
No related tags found
No related merge requests found
## One-click Testing
These instructions assume you already have a working instance of CiviCRM
running locally. Check [setup] for help creating one.
### Locally
From the `Run > Edit Configurations` menu add a new PHPUnit configuration.
Check "Use alternative configuration file" and choose `phpunit.xml.dist` in your
CiviCRM root directory.
Expand "Environment variables" and add the following two:
- `TEST_DB_DSN`: Use the DSN to connect to your test database. It is displayed
on completion of civibuild. You should also be able to find it by running
`cv vars:show`.
- `CIVICRM_UF`: Use "UnitTests" unless you're running WebTests or End-to-end
tests.
## Adding external libraries
It can be frustrating when writing tests the PHPStorm complains about missing
classes or undefined methods. This happens because PHPUnit is not included in
the CiviCRM codebase.
To remedy this you can add an external content root. You'll need to clone the
[phpunit] library locally. Then from that directory check out the latest supported
version of phpunit (4.x right now).
After that you just add the directory to your project include paths by
[following the instructions on the Jetbrains site][phpstorm-include-paths].
[phpstorm-include-paths]: https://www.jetbrains.com/help/phpstorm/configuring-include-paths.html
[phpunit]: https://github.com/sebastianbergmann/phpunit
[setup]: setup.md
......@@ -8,3 +8,5 @@ From there you can create a test site using [civibuild](/tools/civibuild).
When writing new tests or making any changes make sure you run [civilint](/tools/civilint)
to ensure your changes match our coding style.
!!! tip
If you are using PhpStorm, you can [run the tests from within PhpStorm](/tools/phpstorm/#testing) (which is especially helpful because you can set breakpoints and inspect variables while the tests run).
\ No newline at end of file
......@@ -27,4 +27,39 @@ That's it. You can now use this code style on all future CiviCRM-related project
TODO
## Running automated tests from within PhpStorm {:#testing}
!!! note
These instructions assume you already have a working instance of CiviCRM running locally with [buildkit](/tools/buildkit).
From the `Run > Edit Configurations` menu add a new PHPUnit configuration.
Check "Use alternative configuration file" and choose `phpunit.xml.dist` in your
CiviCRM root directory.
Expand "Environment variables" and add the following two:
- `TEST_DB_DSN`: Use the DSN to connect to your test database. It is displayed
on completion of civibuild. You should also be able to find it by running
`cv vars:show`.
- `CIVICRM_UF`: Use "UnitTests" unless you're running WebTests or End-to-end
tests.
### Adding external libraries
It can be frustrating when writing tests the PHPStorm complains about missing
classes or undefined methods. This happens because PHPUnit is not included in
the CiviCRM codebase.
To remedy this you can add an external content root. You'll need to clone the
[phpunit] library locally. Then from that directory check out the latest supported
version of phpunit (4.x right now).
After that you just add the directory to your project include paths by
[following the instructions on the Jetbrains site][phpstorm-include-paths].
[phpstorm-include-paths]: https://www.jetbrains.com/help/phpstorm/configuring-include-paths.html
[phpunit]: https://github.com/sebastianbergmann/phpunit
......@@ -45,7 +45,6 @@ pages:
- Advanced patterns: extensions/advanced.md
- Testing:
- Testing Setup: testing/setup.md
- PHPStorm: testing/phpstorm.md
- "PHPUnit Tests": testing/phpunit-tests.md
- "Javascript Tests": testing/javascript-tests.md
- "Selinium Tests": testing/selinium-tests.md
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment