Skip to content

Commit

Permalink
Add bin/test helper scripts to execute unit tests (#1157)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Shust <[email protected]>
Co-authored-by: Michael Lehmkuhl <[email protected]>
Co-authored-by: Jenyamba <[email protected]>
Co-authored-by: Tu Van <[email protected]>
Co-authored-by: Cid Lopes <[email protected]>
  • Loading branch information
6 people authored Nov 13, 2024
1 parent 6e562ec commit fb56c6d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ It is recommended to keep your root docker config files in one repository, and y
- `bin/status`: Check the container status.
- `bin/stop`: Stop all project containers.
- `bin/stopall`: Stop all docker running containers
- `bin/test/unit`: Run unit tests for a specific path. Ex. `bin/test/unit my-dir`
- `bin/test/unit-coverage`: Generate unit tests coverage reports, saved to the folder `dev/tests/unit/report`. Ex. `bin/test/unit-coverage my-dir`
- `bin/test/unit-xdebug`: Run unit tests with Xdebug. Ex. `bin/test/unit-xdebug my-dir`
- `bin/update`: Update your project to the most recent version of `docker-magento`.
- `bin/xdebug`: Disable or enable Xdebug. Accepts argument `disable`, `enable`, or `status`. Ex. `bin/xdebug enable`

Expand Down
24 changes: 24 additions & 0 deletions compose/bin/test/unit
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

display_help() {
echo -e "Description:
Run unit tests
Usage:
bin/test/unit <unit_test_path>
Arguments:
<unit_test_path> Specify a path to your test or folder with tests Ex: bin/test/unit app/code/Vendor/Module
Options:
-h, --help Display help message"
}


if [[ $1 == "-h" || $1 == "--help" ]]; then
display_help
elif [[ -z $1 ]]; then
echo -e "Please specify a path to your test or folder with tests (ex. app/code/Vendor/Module)"
else
bin/php vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist /var/www/html/"$1"
fi
24 changes: 24 additions & 0 deletions compose/bin/test/unit-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

display_help() {
echo -e "Description:
Generate unit tests coverage report in folder: dev/tests/unit/report
Usage:
bin/test/unit-coverage <unit_test_path>
Arguments:
<unit_test_path> Specify a path to your test or folder with tests Ex: bin/test/unit-coverage app/code/Vendor/Module
Options:
-h, --help Display help message"
}

if [[ $1 == "-h" || $1 == "--help" ]]; then
display_help
elif [[ -z $1 ]]; then
echo -e "Please specify a path to your test or folder with tests (ex. app/code/Vendor/Module)"
else
bin/php -d xdebug.mode=coverage vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist --coverage-html ./dev/tests/unit/report /var/www/html/"$1"
echo -e "Report path: dev/tests/unit/report"
fi
24 changes: 24 additions & 0 deletions compose/bin/test/unit-xdebug
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

display_help() {
echo -e "Description:
Run unit tests with xdebug (you need to turn on xdebug in IDE as usual)
Usage:
bin/test/unit-xdebug <unit_test_path>
Arguments:
<unit_test_path> Specify a path to your test or folder with tests Ex: bin/test/unit-xdebug app/code/Vendor/Module
Options:
-h, --help Display help message"
}


if [[ $1 == "-h" || $1 == "--help" ]]; then
display_help
elif [[ -z $1 ]]; then
echo -e "Please specify a path to your test or folder with tests (ex. app/code/Vendor/Module)"
else
bin/php -d xdebug.start_with_request=yes vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist /var/www/html/"$1"
fi

0 comments on commit fb56c6d

Please sign in to comment.