You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This directory contains Docker configuration for testing the Stream Chat PHP SDK in an isolated environment.
4
+
5
+
## Requirements
6
+
7
+
- Docker installed on your system
8
+
- Make (usually pre-installed on macOS and Linux)
9
+
10
+
## Quick Start
11
+
12
+
1. Build the Docker image:
13
+
```
14
+
make docker-build
15
+
```
16
+
17
+
2. Run all tests:
18
+
```
19
+
make docker-test
20
+
```
21
+
This will automatically create a `.env` file from `.env.example` if it doesn't exist.
22
+
23
+
3. Run tests with test environment:
24
+
```
25
+
make docker-test-with-test-env
26
+
```
27
+
This will use `.env.test` for environment variables.
28
+
29
+
4. Run only unit tests:
30
+
```
31
+
make docker-test-unit
32
+
```
33
+
34
+
5. Run only integration tests:
35
+
```
36
+
make docker-test-integration
37
+
```
38
+
39
+
## Available Commands
40
+
41
+
All Docker-related commands are prefixed with `docker-` to distinguish them from local commands:
42
+
43
+
-`make docker-build` - Build the Docker image
44
+
-`make docker-test` - Run all tests
45
+
-`make docker-test-with-test-env` - Run all tests with test environment
46
+
-`make docker-test-unit` - Run unit tests
47
+
-`make docker-test-integration` - Run integration tests
48
+
-`make docker-lint` - Check code style with PHP CS Fixer
49
+
-`make docker-lint-fix` - Fix code style issues
50
+
-`make docker-analyze` - Run static analysis with Phan
51
+
-`make docker-shell` - Start a shell in the Docker container
52
+
-`make docker-clean` - Remove Docker container and image
53
+
-`make docker-install` - Install dependencies
54
+
-`make docker-update` - Update dependencies
55
+
56
+
## Environment Variables
57
+
58
+
The project includes a `.env.example` file with commented example values. When you run tests, the Makefile will:
59
+
60
+
1. Create a `.env` file from `.env.example` if it doesn't exist
61
+
2. Create a `.env.test` file from `.env.example` when running `make docker-test-with-test-env`
62
+
63
+
You can also use environment-specific files in the `env/` directory:
64
+
65
+
```
66
+
make docker-test-[environment_name]
67
+
```
68
+
69
+
### Environment File Hierarchy
70
+
71
+
-`.env` - Default environment file for general testing
72
+
-`.env.test` - Environment file specifically for test environments
73
+
-`env/*.env` - Environment files for specific test scenarios
74
+
75
+
## Accessing Host Machine from Docker
76
+
77
+
When running tests in Docker, the container's `localhost` refers to the container itself, not the host machine. To access services running on your host machine (like a local server on port 3030), use `host.docker.internal` instead of `localhost`.
78
+
79
+
For example, in your `.env` file:
80
+
```
81
+
STREAM_HOST=http://host.docker.internal:3030
82
+
```
83
+
84
+
The Makefile includes the `--add-host=host.docker.internal:host-gateway` flag to ensure this works across different Docker environments.
85
+
86
+
## Customizing PHP Version
87
+
88
+
You can specify a different PHP version when building the Docker image:
89
+
```
90
+
make docker-build PHP_VERSION=8.3
91
+
```
92
+
93
+
## Additional PHPUnit Options
94
+
95
+
You can pass additional options to PHPUnit:
96
+
```
97
+
make docker-test PHPUNIT_FLAGS="--verbose --filter=testSpecificMethod"
98
+
```
99
+
100
+
Or use the filter directly:
101
+
```
102
+
make docker-test PHPUNIT_FILTER="testSpecificMethod"
0 commit comments