Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Commit

Permalink
Update testing readme.md doc (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyrob authored Sep 14, 2023
1 parent 95eaefa commit c17928f
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions tests/phpunit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,44 @@

1. **Be sure your PHP installation supports the `mbstring` module.** If you're not sure, run `php -m` and look for `mbstring` in the list. If it's not present, and you're on Ubuntu or Debian Linux, you can run `sudo apt-get install php-mbstring` to fix this.

2. **Install `phpunit` version `6.x`.** Example terminal commands:
2. **Clone the ClassicPress `git` repository to your computer, if needed:**

```
wget https://phar.phpunit.de/phpunit-6.5.9.phar
chmod +x phpunit-6.5.9.phar
sudo mv phpunit-6.5.9.phar /usr/local/bin/phpunit
phpunit --version
```
git clone https://github.com/ClassicPress/ClassicPress.git
cd ClassicPress

3. **Clone the ClassicPress `git` repository to your computer:**
3. **Install MySQL and create an empty MySQL database.** The test suite will **delete all data** from all tables for whichever MySQL database is configured. *Use a separate database from any ClassicPress or WordPress installations on your computer*.

```
git clone https://github.com/ClassicPress/ClassicPress.git
cd ClassicPress
```
4. **Set up a config file for the tests.** In your repository folder (`ClassicPress`), copy `wp-tests-config-sample.php` to `wp-tests-config.php`, and enter your database credentials from the step above. *Use a separate database from any ClassicPress or WordPress installations on your computer*, because data in this database **will be deleted** with each test run. You may want to check everything works at this stage on your `localhost` by following a similar process using copying the `wp-config-sample.php` to `wp-config.php` and accessing the ClassicPress code locally.

4. **Install MySQL and create an empty MySQL database.** The test suite will **delete all data** from all tables for whichever MySQL database is configured. *Use a separate database from any ClassicPress or WordPress installations on your computer*.
5. **Install** the automated test files:

5. **Set up a config file for the tests.** In your repository folder (`ClassicPress`), copy `wp-tests-config-sample.php` to `wp-tests-config.php`, and enter your database credentials from the step above. *Use a separate database from any ClassicPress or WordPress installations on your computer*, because data in this database **will be deleted** with each test run.
composer install

You will need to have the [composer](https://getcomposer.org) available on your system first.

6. **Run the tests:**

```
phpunit
```
Once the dependencies are installed you can use the following commands:

- to run PHPUnit tests

`composer phpunit`

- to run coding standards checks on core files

`composer phpcs`

- to run coding standards checks on the test files

`composer phpcs-tests`

To execute only a particular test file (useful when debugging):
- to execute only particular test file, groups or specific test (useful when debugging):

```
phpunit tests/phpunit/tests/test_case.php
```
```
composer phpunit -- tests/phpunit/tests/date/query.php
composer phpunit -- --group=date
composer phpunit -- --filter=test_should_format_date
```

7. **Explore the existing tests** in the `tests/phpunit/tests` directory, look at how they work, edit them and break them, and write your own.

Expand Down

0 comments on commit c17928f

Please sign in to comment.