Skip to content

Commit 3269840

Browse files
authored
Quick setup to run pgsql locally with tests (#3458)
1 parent ae1494c commit 3269840

3 files changed

Lines changed: 77 additions & 0 deletions

File tree

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,8 @@ docker-build-dev-image:
154154
docker build ./docker/dev -t lychee-dev:latest
155155

156156
docker-build-dev: docker-build-base-image docker-build-dev-image
157+
158+
test_pgsql_v2:
159+
docker compose -f docker-compose-pgsql.yaml up -d
160+
vendor/bin/phpunit --testsuite Feature_v2 --stop-on-failure --stop-on-error --no-coverage --log-junit report_v2.xml --configuration phpunit.pgsql.xml
161+
docker compose down

docker-compose-pgsql.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
services:
3+
# Label used to access the service container
4+
postgres:
5+
# Docker Hub image
6+
image: postgres
7+
# Provide the password for postgres
8+
environment:
9+
# PGUSER: user
10+
POSTGRES_PASSWORD: postgres
11+
POSTGRES_USER: user
12+
POSTGRES_DB: lychee
13+
14+
ports:
15+
# Maps tcp port 5432 on service container to the host
16+
- 5432:5432
17+
volumes:
18+
- ./pgdata:/var/lib/postgresql/data
19+
healthcheck:
20+
test: ["CMD-SHELL", "pg_isready", "-U", "user"]
21+
interval: 1s
22+
timeout: 5s
23+
retries: 10

phpunit.pgsql.xml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
3+
<coverage>
4+
<report>
5+
<clover outputFile="clover.xml"/>
6+
<text outputFile="php://stdout" showUncoveredFiles="false"/>
7+
</report>
8+
</coverage>
9+
<testsuites>
10+
<testsuite name="Unit">
11+
<directory suffix="Test.php">./tests/Unit</directory>
12+
<exclude>./tests/Unit/Http/Requests/Base/BaseRequestTest.php</exclude>
13+
</testsuite>
14+
<testsuite name="Feature_v2">
15+
<directory suffix="Test.php">./tests/Feature_v2</directory>
16+
<exclude>./tests/Feature_v2/Base/BaseApiTest.php</exclude>
17+
<exclude>./tests/Feature_v2/Base/BaseApiWithDataTest.php</exclude>
18+
<exclude>./tests/Feature_v2/ImageHandlers/BaseImageHandler.php</exclude>
19+
</testsuite>
20+
</testsuites>
21+
<extensions>
22+
<bootstrap class="Tests\BootExtension"/>
23+
</extensions>
24+
<logging/>
25+
<php>
26+
<env name="APP_ENV" value="testing"/>
27+
<env name="LYCHEE_UPLOADS_DIR" value="uploads/"/>
28+
<env name="DB_CONNECTION" value="pgsql"/>
29+
<env name="DB_HOST" value="localhost" />
30+
<env name="DB_PORT" value="5432" />
31+
<env name="DB_DATABASE" value="lychee"/>
32+
<env name="DB_USERNAME" value="user"/>
33+
<env name="DB_PASSWORD" value="postgres"/>
34+
<env name="DB_LOG_SQL" value="false"/>
35+
<env name="DB_LOG_SQL_EXPLAIN" value="false"/>
36+
<env name="BCRYPT_ROUNDS" value="4"/>
37+
<env name="CACHE_DRIVER" value="array"/>
38+
<env name="SESSION_DRIVER" value="array"/>
39+
<env name="QUEUE_CONNECTION" value="sync"/>
40+
<env name="MAIL_DRIVER" value="array"/>
41+
</php>
42+
<source>
43+
<include>
44+
<directory suffix=".php">
45+
./app
46+
</directory>
47+
</include>
48+
</source>
49+
</phpunit>

0 commit comments

Comments
 (0)