Skip to content

Commit 04e6ffc

Browse files
martig7lavalleeale
andauthored
[Documentation:Developer] Improve php unit test instructions (#686)
It turns out that no one knows how to run the full php unit test suite and have it pass, so I investigated the php unit test instructions and Improved them. @lavalleeale has some changes at [https://github.com/Submitty/Submitty/pull/11802](url) to allow for the full suite to pass so these docs should match that. --------- Co-authored-by: Alex Lavallee <[email protected]>
1 parent b802f1c commit 04e6ffc

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

_docs/developer/testing/install_php.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ you will need to have PHP installed on your host machine first.
88

99
### Linux & WSL:
1010

11-
*If you're distro cannot find the correct package or installs the wrong version you may have to specify php7.0 in each package name*
11+
*If you're distro cannot find the correct package or installs the wrong version you may have to specify php8.1 in each package name*
1212

1313
```bash
1414
sudo apt-get update
@@ -23,6 +23,10 @@ If you are missing extensions you can install them with `PECL` which will be
2323
installed automatically with PHP, but you should have everything required by
2424
default.
2525

26+
### Windows
27+
28+
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.
29+
2630
-------------
2731

2832
Verify you have PHP installed correctly, submitty requires a version greater than 7.0

_docs/developer/testing/linting_static_analysis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The following instructions were tested for Windows:
5858

5959
1. First, you will need PHP installed on your host system first. See [Installing PHP](/developer/testing/install_php)*
6060

61-
2. Next, you will need [Composer](https://getcomposer.org/doc/00-intro.md) installed on your host system as well.
61+
2. Next, you will need [Composer](https://getcomposer.org/download/) installed on your host system as well.
6262
During this install, you will need to change settings in a php.ini file. Change the settings the prompt recommends.
6363

6464
3. Run ``composer global require slevomat/coding-standard`` and ``composer global require "squizlabs/php_codesniffer=*"`` inside your terminal.

_docs/developer/testing/php_unit_tests.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,37 @@ To validate the unit behavior of the site code, we utilize
99

1010
### Running PHP Unit Tests
1111

12-
*You will need PHP installed on your host system first, see [Installing PHP](/developer/testing/install_php)*
12+
*If you are running on WSL and are seeing errors, remove `php` from the following commands.*
1313

14-
To run the PHP unit test suite locally, `cd` to the `Submitty/site` directory and type:
14+
To run the PHP unit test suite in VM use the alias
1515

16-
If you are running on WSL and are seeing errors, remove "`php`" from the following commands.
16+
```
17+
submitty_test php-unit
18+
```
19+
20+
or
1721

1822
```
19-
php vendor/bin/phpunit
23+
sudo -u submitty_php php vendor/bin/phpunit
2024
```
2125

2226
To run just an individual class or test, you can use the `--filter` flag on PHPUnit.
2327
For example, to run the function `testInvalidProperty` would be
24-
`php vendor/bin/phpunit --filter testInvalidProperty` and running all
28+
`sudo -u submitty_php php vendor/bin/phpunit --filter testInvalidProperty` and running all
2529
of `AccessControlTester` would be
2630
`php vendor/bin/phpunit--filter AccessControlTester`. Be aware, filter
2731
can match against partial strings, so if you have two tests `testFoo` and `testFooBar`,
2832
running `--filter testFoo` will run them both. Alternatively, you can also directly run
2933
`phpunit` against a specific class by passing the path to the test class directly to
3034
`phpunit`, for example
31-
`php vendor/bin/phpunit tests/app/authentication/DatabaseAuthenticationTester.php` will run
35+
`sudo -u submitty_php php vendor/bin/phpunit tests/app/authentication/DatabaseAuthenticationTester.php` will run
3236
only the test methods in `DatabaseAuthenticationTester.php`.
3337

3438
The two concepts above can be combined to run a specific test function in a specific
3539
class by doing:
3640

3741
```bash
38-
vendor/bin/phpunit --filter testFunction tests/app/path/to/TestClass.php
42+
sudo -u submitty_php php vendor/bin/phpunit --filter testFunction tests/app/path/to/TestClass.php
3943
```
4044

4145
You can pass in the `--debug` flag when using PHPUnit to see PHP output, this can be

_docs/sysadmin/installation/version_notes/v20.08.00.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ requires the following edits:
1616

1717
1. Locate your `php.ini` file.
1818

19-
_It is probably something like `/etc/php/7.2/fpm/php.ini`._
19+
_It is probably something like `/etc/php/8.1/fpm/php.ini`._
2020

2121
Note: You can run this command to print your specific version of php:
2222

@@ -32,7 +32,7 @@ requires the following edits:
3232
3. Restart php fpm:
3333

3434
```
35-
sudo systemctl restart php7.2-fpm
35+
sudo systemctl restart php8.1-fpm
3636
```
3737

3838
Or more generally:

0 commit comments

Comments
 (0)