mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Updated en/topics/testing/index.md for clearer PHPUnit installation instructions
Step by step Composer installation instructions, including a composer.json example. In addition: - Removed self-page reference to an introduction - Removed reference to PEAR installation instructions due to end of life - Removed reference to Ruby as doesn't add value - Shortened testing via Web Browser section (as covered in Composer installation instructions)
This commit is contained in:
parent
9f3506bf02
commit
f5ccdda22f
@ -13,39 +13,52 @@ If you're more familiar with unit testing, but want a refresher of some of the c
|
|||||||
the [Testing Glossary](glossary). To get started now, follow the installation instructions below, and check
|
the [Testing Glossary](glossary). To get started now, follow the installation instructions below, and check
|
||||||
[Troubleshooting](testing-guide-troubleshooting) in case you run into any problems.
|
[Troubleshooting](testing-guide-troubleshooting) in case you run into any problems.
|
||||||
|
|
||||||
If you are familiar with PHP coding but new to unit testing, you should read the [Introduction](/topics/testing) and
|
If you are familiar with PHP coding but new to unit testing then check out Mark's presentation [Getting to Grips with SilverStripe Testing](http://www.slideshare.net/maetl/getting-to-grips-with-silverstripe-testing).
|
||||||
check out Mark's presentation [Getting to Grips with SilverStripe Testing](http://www.slideshare.net/maetl/getting-to-grips-with-silverstripe-testing).
|
|
||||||
|
|
||||||
[Why Unit Test?](why-should-i-test) will give you reasons why you should be testing your code.
|
[Why Unit Test?](why-should-i-test) will give you reasons why you should be testing your code.
|
||||||
|
|
||||||
You should also read over [the PHPUnit manual](http://www.phpunit.de/manual/current/en/). It provides a lot of
|
You should also read over [the PHPUnit manual](http://www.phpunit.de/manual/current/en/). It provides a lot of
|
||||||
fundamental concepts that we build on in this documentation.
|
fundamental concepts that we build on in this documentation.
|
||||||
|
|
||||||
## Installation
|
Unit tests are not included in the normal SilverStripe downloads so you need to install them through git repositories
|
||||||
|
|
||||||
### Via Composer
|
|
||||||
|
|
||||||
Unit tests are not included in the normal SilverStripe downloads, you are expected to work with local git repositories
|
|
||||||
([installation instructions](/installation/composer)).
|
([installation instructions](/installation/composer)).
|
||||||
|
|
||||||
Once you've got the project up and running, check out the additional requirements to run unit tests:
|
## Install with Composer
|
||||||
|
|
||||||
|
Once you've got your project up and running, add PHPUnit to your composer.json (in your project root) as a package required for development (note that SilverStripe is not compatible with PHPUnit 4). Example below:
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "silverstripe/installer",
|
||||||
|
"description": "The SilverStripe Framework Installer",
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.2",
|
||||||
|
"silverstripe/cms": "~3.1@stable",
|
||||||
|
"silverstripe/framework": "~3.1@stable",
|
||||||
|
"silverstripe-themes/simple": "*"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/PHPUnit": "~3.5@stable"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"process-timeout": 600
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev"
|
||||||
|
}
|
||||||
|
|
||||||
|
In the terminal cd to your project root and install the required components to run unit tests:
|
||||||
|
|
||||||
composer update --dev
|
composer update --dev
|
||||||
|
|
||||||
This will install (among other things) the [PHPUnit](http://www.phpunit.de/) dependency, which is the framework we're
|
This will install (among other things) the [PHPUnit](http://www.phpunit.de/) dependency, which is the framework we're
|
||||||
building our unit tests on. Composer installs it alongside the required PHP classes into the `vendor/bin/` directory.
|
building our unit tests on. Composer installs it alongside the required PHP classes into the `vendor/bin/` directory.
|
||||||
You can either use it through its full path (`vendor/bin/phpunit`), or symlink it into the root directory of your website:
|
|
||||||
|
Open a browser at `http://localhost/dev/tests` to see a list of available tests. Run a test to ensure the installation is complete.
|
||||||
|
|
||||||
|
### Symlinking the PHPUnit Binary
|
||||||
|
You can either use PHPUnit through its full path (`vendor/bin/phpunit`), or symlink it into the root directory of your website:
|
||||||
|
|
||||||
ln -s vendor/bin/phpunit phpunit
|
ln -s vendor/bin/phpunit phpunit
|
||||||
|
|
||||||
### Via PEAR
|
|
||||||
|
|
||||||
Alternatively, you can check out PHPUnit globally via the PEAR package manager
|
|
||||||
([instructions](https://github.com/sebastianbergmann/phpunit/)).
|
|
||||||
|
|
||||||
pear config-set auto_discover 1
|
|
||||||
pear install pear.phpunit.de/PHPUnit
|
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
### phpunit.xml
|
### phpunit.xml
|
||||||
@ -83,8 +96,6 @@ You will generally write two different kinds of test classes.
|
|||||||
* **Unit Test:** Test the behaviour of one of your DataObjects.
|
* **Unit Test:** Test the behaviour of one of your DataObjects.
|
||||||
* **Functional Test:** Test the behaviour of one of your controllers.
|
* **Functional Test:** Test the behaviour of one of your controllers.
|
||||||
|
|
||||||
Some people may note that we have used the same naming convention as Ruby on Rails.
|
|
||||||
|
|
||||||
Tutorials and recipes for creating tests using the SilverStripe framework:
|
Tutorials and recipes for creating tests using the SilverStripe framework:
|
||||||
|
|
||||||
* [Creating a SilverStripe test](creating-a-silverstripe-test): Writing tests to check core data objects
|
* [Creating a SilverStripe test](creating-a-silverstripe-test): Writing tests to check core data objects
|
||||||
@ -140,7 +151,6 @@ particularly around formatting test output.
|
|||||||
### Via Web Browser
|
### Via Web Browser
|
||||||
|
|
||||||
Executing tests from the command line is recommended, since it most closely reflects
|
Executing tests from the command line is recommended, since it most closely reflects
|
||||||
test runs in any automated testing environments. If for some reason you don't have
|
test runs in any automated testing environments. However, you can also run tests through the browser:
|
||||||
access to the command line, you can also run tests through the browser.
|
|
||||||
|
|
||||||
http://localhost/dev/tests
|
http://localhost/dev/tests
|
||||||
|
Loading…
Reference in New Issue
Block a user