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
|**Codeception (WPUnit)**| Runs unit and integration tests |[View Workflow](../../actions/workflows/codeception.yml)|
96
+
97
+
98
+
>[!IMPORTANT]
99
+
> Test coverage for WP Unit Tests is **95%**. Any new code will require tests to be added in order to pass CI checks. This is set in [text](codeception.dist.yml) in the parameter `min_coverage`.
100
+
81
101
---
82
102
83
-
## GitHub Actions
103
+
## Setup Tests Locally
104
+
105
+
### Prerequisites
106
+
107
+
- Docker and Docker Compose installed and running
108
+
- Composer installed
109
+
- Node.js and npm installed (for E2E tests)
110
+
- Terminal/command line access
111
+
112
+
### Docker Setup
113
+
114
+
>[!NOTE]
115
+
> You need Docker running locally before setting up tests. Alternatively, you can copy `.env.dist` to `.env` and update the database details to point to your local database. However, this will make database changes, so we recommend using the Docker setup instead.
84
116
85
-
We have a few checks which run for a new PR being merged to main
| Codeception (WPUnit) | Runs unit and integration tests |[View Workflow](../../actions/workflows/codeception.yml)|
119
+
```shell
120
+
sh bin/local/setup-docker-env.sh
121
+
```
122
+
123
+
This script will automatically handle the complete Docker environment setup process.
124
+
125
+
### What the Setup Script Does
126
+
127
+
The setup script performs the following operations:
128
+
129
+
#### 1. Environment Verification
130
+
- ✅ Checks that Docker is running
131
+
- ✅ Verifies required files exist
132
+
133
+
#### 2. Configuration Setup
134
+
- 📁 Copies `bin/local/.env.local` to `.env`
135
+
- Uses local development configuration (different from `.env.dist`)
136
+
- Sets appropriate database credentials and WordPress settings
92
137
138
+
#### 3. Docker Container Management
139
+
- 🐳 Runs `composer run docker:build`
140
+
- Executes `sh bin/build-docker.sh` to create the Docker container
141
+
- Builds WordPress environment with PHP 8.2
142
+
- 🚀 Runs `docker compose up -d` to start the container in detached mode
143
+
- Creates container named `hwp-previews-wordpress-1`
144
+
- Sets up WordPress with test database
93
145
94
-
> **INFO:**
95
-
> All tests are automatically run on every pull request via GitHub Actions. You can review test results and logs directly in the "Checks" tab of your PR on GitHub.
146
+
#### 4. Code Coverage Setup
147
+
- 🔧 Installs and configures PCOV extension (preferred for performance)
148
+
- 🔄 Falls back to XDebug if PCOV installation fails
149
+
- ⚙️ Configures coverage settings automatically
150
+
- 🔄 Restarts container to ensure extensions are loaded
96
151
97
-
> **IMPORTANT:**
98
-
> Test coverage for WP Unit Tests is 95%. Any new code will require tests to be added in order to pass.
152
+
#### 5. WordPress Installation
153
+
- 📝 Installs WordPress if not already present
154
+
- 🔌 Activates the plugin automatically
155
+
- ✅ Verifies the installation is working correctly
156
+
157
+
### Running Tests Locally
158
+
159
+
Once setup is complete, you can run tests using Composer:
160
+
161
+
```shell
162
+
# Run unit tests with coverage
163
+
composer run test:unit:coverage
164
+
165
+
# Run all tests
166
+
composer run test
167
+
168
+
# Run E2E tests
169
+
composer run test:e2e
170
+
```
171
+
172
+
For a full list of available test commands, see the [Usage](#usage) section above.
0 commit comments