> For the complete documentation index, see [llms.txt](https://docs.acpt.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acpt.io/developers/ci-pipeline.md).

# CI pipeline

Overview of the ACPT automated test and code quality CI pipeline.

{% hint style="info" %}
The CI pipeline configuration described here reflects ACPT 2.1.0. Pipeline details may evolve between releases.
{% endhint %}

ACPT ships with a GitHub Actions CI pipeline that runs on every push and pull request. The pipeline enforces code quality, type safety, and functional correctness.

## Trigger conditions

The pipeline runs automatically on:

* **Push** to branches: `main`, `master`, `develop`, `feature/*`, `cct`
* **Pull requests** targeting: `main`, `master`, `develop`

## Jobs

### 1. PHPStan static analysis

Runs PHP static analysis at **level 7** with PHP 7.4 compatibility mode.

**Scope:** `src/` and `functions/` directories.

**Key settings:**

* `phpVersion: 70400` — all code must be compatible with PHP 7.4
* Memory limit: 2 GB
* Baseline: **empty** — no suppressed errors. All issues must be fixed at the source.

A second PHPStan run analyses the `tests/` directory at PHP 8.0 compatibility (`continue-on-error: true` — test suite may use PHP 8 features).

To run locally:

```bash
./vendor/bin/phpstan analyse
```

### 2. PHPUnit tests

Runs the full PHPUnit test suite against a real MySQL 8.0 database.

**Environment:**

* PHP 8.3
* MySQL 8.0 service (root password: `root`, database: `wordpress_test`)
* WordPress test library set up via `bin/install-wp-tests.sh`

**Excluded tests:**

Tests tagged `@group external` are skipped in CI because they make real network calls:

```bash
./vendor/bin/phpunit --exclude-group external
```

To run all tests locally (including external):

```bash
./vendor/bin/phpunit
```

To run a single test file:

```bash
./vendor/bin/phpunit tests/api/v1/TableRecordControllerTest.php
```

## Test suites

| Directory             | Coverage                                                        |
| --------------------- | --------------------------------------------------------------- |
| `tests/api/`          | REST API v1 controllers                                         |
| `tests/commands/`     | CQRS Command and Query classes (31+ files)                      |
| `tests/data/`         | Data handling and serialisation                                 |
| `tests/functions/`    | PHP helper functions and settings                               |
| `tests/integrations/` | Page builder integrations (Gutenberg, Elementor, Bricks)        |
| `tests/models/`       | Entity model unit tests                                         |
| `tests/objects/`      | Value object tests                                              |
| `tests/repo/`         | Repository layer tests                                          |
| `tests/shortcodes/`   | WordPress shortcode output                                      |
| `tests/unit/`         | Low-level unit tests (CCT field rendering, value normalization) |

## CCT-specific tests

ACPT 2.1.0 introduces dedicated test coverage for Custom Content Types:

| File                                                           | Description                                                                                    |
| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| `tests/api/v1/TableRecordControllerTest.php`                   | 77+ integration tests for the CCT REST API                                                     |
| `tests/api/v1/TableControllerTest.php`                         | Table management endpoints                                                                     |
| `tests/commands/SaveTableGroupCommandTest.php`                 | Table group CQRS commands                                                                      |
| `tests/models/TableModelCreateTableTest.php`                   | Schema creation                                                                                |
| `tests/models/TableModelPermissionsTest.php`                   | Permission trait (10 tests)                                                                    |
| `tests/models/TableModelVisibilityTest.php`                    | Visibility rules                                                                               |
| `tests/functions/values/fields/single/CCT*FieldValuesTest.php` | Per-field-type value handling (Address, Currency, Date, Media, Number, Phone, Relations, Text) |
| `tests/unit/CCTFieldRenderTest.php`                            | Field rendering                                                                                |
| `tests/unit/CCTValueNormalizerTest.php`                        | Value normalization                                                                            |

## PHPStan level 7 — zero baseline

`vendor/bin/phpstan analyse` runs clean with **zero errors** and an empty `phpstan-baseline.neon`. Do not add new entries to the baseline — fix issues at the source.

See [CLAUDE.md](https://github.com/mauretto78/advanced-custom-post-type/blob/master/CLAUDE.md) in the plugin repository for detailed patterns used to fix common level-7 errors (string|false returns, WP API unions, dynamic class instantiation, etc.).

## Running the full quality check locally

```bash
# Static analysis
./vendor/bin/phpstan analyse

# Tests (exclude network calls)
./vendor/bin/phpunit --exclude-group external

# All tests (requires local MySQL and WP test setup)
./vendor/bin/phpunit
```
