Skip to content

Commit 71bf165

Browse files
committed
Split adapters into separate tests for better maintainability
1 parent 81aba34 commit 71bf165

15 files changed

Lines changed: 470 additions & 303 deletions

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
TEST_APPSIGNAL_KEY=
2+
TEST_LOGOWL_KEY=
3+
TEST_RAYGUN_KEY=
4+
TEST_SENTRY_KEY=
5+
TEST_SENTRY_PROJECT_ID=
6+
TEST_SENTRY_HOST=

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ notifications:
1111
before_script: composer install --ignore-platform-reqs
1212

1313
script:
14-
- vendor/bin/phpunit --configuration phpunit.xml
15-
- vendor/bin/psalm --show-info=true
14+
- composer check
15+
- composer test

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,20 @@ Below is a list of supported adapters, and thier compatibly tested versions alon
9090

9191
## Tests
9292

93-
To run all unit tests, use the following Docker command:
93+
If you need to install dependencies, run:
9494

9595
```bash
96-
docker run --rm -e TEST_RAYGUN_KEY=KKKK -e TEST_APPSIGNAL_KEY=XXXX -e TEST_SENTRY_KEY=YYYY -e TEST_SENTRY_PROJECT_ID=ZZZZ -v $(pwd):$(pwd):rw -w $(pwd) php:8.0-cli-alpine sh -c "vendor/bin/phpunit --configuration phpunit.xml tests"
96+
docker run --rm --interactive --tty \
97+
--volume $PWD:/app \
98+
composer update --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts --prefer-dist
99+
```
100+
101+
To run all unit tests, prepare the `.env` file using `.env.example` as a template. Then, run:
102+
103+
```bash
104+
docker run --rm --interactive --tty --env-file .env \
105+
--volume $PWD:/app \
106+
composer test
97107
```
98108

99109
> Make sure to replace `TEST_SENTRY_KEY` and `TEST_SENTRY_PROJECT_ID` environment variables value with actual keys from Sentry. If your Sentry DSN is `https://something@otherthing.ingest.sentry.io/anything`, then `TEST_SENTRY_KEY=something` and `TEST_SENTRY_PROJECT_ID=anything`.
@@ -106,7 +116,9 @@ docker run --rm -e TEST_RAYGUN_KEY=KKKK -e TEST_APPSIGNAL_KEY=XXXX -e TEST_SENTR
106116
To run static code analysis, use the following Psalm command:
107117

108118
```bash
109-
docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) php:8.0-cli-alpine sh -c "vendor/bin/psalm --show-info=true"
119+
docker run --rm --interactive --tty \
120+
--volume $PWD:/app \
121+
composer check
110122
```
111123

112124
## System Requirements

composer.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,23 @@
77
"scripts": {
88
"check": "./vendor/bin/phpstan analyse --level max src tests",
99
"lint": "./vendor/bin/pint --test",
10-
"format": "./vendor/bin/pint"
10+
"format": "./vendor/bin/pint",
11+
"test-unit": "./vendor/bin/phpunit --configuration phpunit.xml --testsuite unit --debug",
12+
"test-e2e": "./vendor/bin/phpunit --configuration phpunit.xml --testsuite e2e --debug",
13+
"test": [
14+
"@test-unit",
15+
"@test-e2e"
16+
]
1117
},
1218
"autoload": {
1319
"psr-4": {"Utopia\\Logger\\": "src/Logger"}
1420
},
21+
"autoload-dev": {
22+
"psr-4": {
23+
"Utopia\\Tests\\E2E\\":"tests/e2e",
24+
"Utopia\\Tests\\Unit\\":"tests/unit"
25+
}
26+
},
1527
"require": {
1628
"php": ">=8.0"
1729
},

0 commit comments

Comments
 (0)