Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,22 @@ Pull requests very welcome, please try to maintain stylistic, structural and nam

### Testing

There are currently two separate test suites: one, in `tests/Mf2`, is written in phpunit, containing many microformats parsing examples as well as internal parser tests and regression tests for specific issues over php-mf2’s history. Run it with `./vendor/bin/phpunit`. If you do not have a live internet connection, you can exclude tests that depend on it: `./vendor/bin/phpunit --exclude-group internet`.

The other, in `tests/test-suite`, is a custom test harness which hooks up php-mf2 to the cross-platform [microformats test suite](https://github.com/microformats/tests). To run these tests you must first install the tests with `./composer.phar install`. Each test consists of a HTML file and a corresponding JSON file, and the suite can be run with `php ./tests/test-suite/test-suite.php`.

Currently php-mf2 passes the majority of it’s own test case, and a good percentage of the cross-platform tests. Contributors should ALWAYS test against the PHPUnit suite to ensure any changes don’t negatively impact php-mf2, and SHOULD run the cross-platform suite, especially if you’re changing parsing behaviour.

Run `composer install` and `composer check-and-tests`. This will run `phpcs`, the php-mf2 tests, and the cross-platform [microformats/tests](https://github.com/microformats/tests) (excluding mf1; more details below).

The php-mf2 tests are in `/tests/Mf2` and contain many parsing examples, internal parser tests, and regression tests for specific issues over its history. If you need to run tests without an internet connection, run `composer tests-no-internet`.

`microformats/tests` are included via `MicroformatsTestSuiteTest.php`. It has tests for mf2 and mf1. php-mf2 will fail some of the mf1 tests, so the `check-and-tests` script will skip them currently. It **is** a goal to pass those mf1 tests, so you can run them with `composer microformats-tests-mf1`. There are additional composer scripts listed below for running parts of this test suite on their own.

**Composer scripts**
Comment thread
gRegorLove marked this conversation as resolved.
- phpcs: run with `composer cs-check`
- php-mf2 tests + microformats/tests, except mf1: run with `composer tests`
- same, but exclude tests that require internet: `composer tests-no-internet`
- microformats/tests suite:
- run mf1 tests with `composer microformats-tests-mf1`
- run mf2 tests with `composer microformats-tests-mf2`
Comment thread
gRegorLove marked this conversation as resolved.
- run mixed tests with `composer microformats-tests-mixed`
- phpcs + php-mf2 tests + microformats/tests, except mf1: run `composer check-and-test`
- phpcs + all tests: run `composer check-and-test-all`

## License

Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@
"scripts": {
"cs-check": "phpcs",
"tests": "XDEBUG_MODE=coverage ./vendor/bin/phpunit tests --coverage-text --whitelist Mf2",
"test-mf1": "./vendor/bin/phpunit --group microformats/tests/mf1",
"tests-no-internet": "@tests --exclude-group internet,microformats/tests/mf1",
"microformats-tests-mf1": "./vendor/bin/phpunit --group microformats/tests/mf1",
"microformats-tests-mf2": "./vendor/bin/phpunit --group microformats/tests/mf2",
"microformats-tests-mixed": "./vendor/bin/phpunit --group microformats/tests/mixed",
"test-mf1": "@microformats-tests-mf1",
"check-and-test": [
"@cs-check",
"@tests"
],
"check-and-test-all": [
"@check-and-test",
"@test-mf1"
"@microformats-tests-mf1"
]
},
"autoload": {
Expand Down
Loading