diff --git a/_docs/developer/testing/install_php.md b/_docs/developer/testing/install_php.md index 7181fb33..9bc1ed4e 100644 --- a/_docs/developer/testing/install_php.md +++ b/_docs/developer/testing/install_php.md @@ -23,6 +23,10 @@ If you are missing extensions you can install them with `PECL` which will be installed automatically with PHP, but you should have everything required by default. +### Windows + +Download [php 8.1](https://windows.php.net/download/) as a zip file under the thread safe category. Then extract the contents of the zip to a folder, and add the path to that folder to your path system variable. It's suggested that one extracts the contents of the zip to a folder called `php`, which can be put at `C:\php` for simplicity. You can then add `C:\php` to your path system environment variable. + ------------- Verify you have PHP installed correctly, submitty requires a version greater than 7.0 diff --git a/_docs/developer/testing/linting_static_analysis.md b/_docs/developer/testing/linting_static_analysis.md index ff33e992..47fa50e9 100644 --- a/_docs/developer/testing/linting_static_analysis.md +++ b/_docs/developer/testing/linting_static_analysis.md @@ -58,7 +58,7 @@ The following instructions were tested for Windows: 1. First, you will need PHP installed on your host system first. See [Installing PHP](/developer/testing/install_php)* -2. Next, you will need [Composer](https://getcomposer.org/doc/00-intro.md) installed on your host system as well. +2. Next, you will need [Composer](https://getcomposer.org/download/) installed on your host system as well. During this install, you will need to change settings in a php.ini file. Change the settings the prompt recommends. 3. Run ``composer global require slevomat/coding-standard`` and ``composer global require "squizlabs/php_codesniffer=*"`` inside your terminal. diff --git a/_docs/developer/testing/php_unit_tests.md b/_docs/developer/testing/php_unit_tests.md index 56da8544..d548f365 100644 --- a/_docs/developer/testing/php_unit_tests.md +++ b/_docs/developer/testing/php_unit_tests.md @@ -6,36 +6,41 @@ category: Developer > Development Instructions > Continuous Integration Testing To validate the unit behavior of the site code, we utilize [phpunit](https://phpunit.readthedocs.io/en/latest). +*If tests are failing for you even on main, you may need to run `apt install php-sqlite3`, especially if you haven't vagrant upped from scratch in a while.* ### Running PHP Unit Tests -*You will need PHP installed on your host system first, see [Installing PHP](/developer/testing/install_php)* +*If you are running on WSL and are seeing errors, remove `php` from the following commands.* -To run the PHP unit test suite locally, `cd` to the `Submitty/site` directory and type: +To run the PHP unit test suite in VM use the alias -If you are running on WSL and are seeing errors, remove "`php`" from the following commands. +``` +submitty_test php-unit +``` + +or ``` -php vendor/bin/phpunit +sudo -u submitty_php php vendor/bin/phpunit ``` To run just an individual class or test, you can use the `--filter` flag on PHPUnit. For example, to run the function `testInvalidProperty` would be -`php vendor/bin/phpunit --filter testInvalidProperty` and running all +`sudo -u submitty_php php vendor/bin/phpunit --filter testInvalidProperty` and running all of `AccessControlTester` would be `php vendor/bin/phpunit--filter AccessControlTester`. Be aware, filter can match against partial strings, so if you have two tests `testFoo` and `testFooBar`, running `--filter testFoo` will run them both. Alternatively, you can also directly run `phpunit` against a specific class by passing the path to the test class directly to `phpunit`, for example -`php vendor/bin/phpunit tests/app/authentication/DatabaseAuthenticationTester.php` will run +`sudo -u submitty_php php vendor/bin/phpunit tests/app/authentication/DatabaseAuthenticationTester.php` will run only the test methods in `DatabaseAuthenticationTester.php`. The two concepts above can be combined to run a specific test function in a specific class by doing: ```bash -vendor/bin/phpunit --filter testFunction tests/app/path/to/TestClass.php +sudo -u submitty_php php vendor/bin/phpunit --filter testFunction tests/app/path/to/TestClass.php ``` You can pass in the `--debug` flag when using PHPUnit to see PHP output, this can be