Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: CI
on:
push:
branches:
- 2.next-cake4
- 3.next-cake5
- 4.next-cake6

pull_request:
branches:
Expand All @@ -16,33 +15,29 @@ permissions:
jobs:
testsuite:
name: PHP ${{ matrix.php-version }}
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
strategy:
fail-fast: false
matrix:
# composer.json declares php >=8.1 and cakephp/cakephp ^5.0.
# CakePHP 5.0-5.2 allow PHP 8.1; 5.3+ requires PHP 8.2, so on 8.1
# composer resolves 5.2.x and on 8.2+ the latest 5.x. Test the whole
# declared range: 8.1 (min) -> 8.5 (newest).
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']
# composer.json declares php >=8.5 and cakephp/cakephp ^6.0 (6.x-dev until 6.0.0 is tagged).
php-version: ['8.5']

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, apcu, sqlite3, pdo_sqlite
ini-values: apc.enable_cli=1
extensions: mbstring, intl, sqlite3, pdo_sqlite
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache composer dependencies
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}
Expand All @@ -58,18 +53,18 @@ jobs:
- name: Run integration tests
run: composer test-integration

cs:
name: Coding Standard
runs-on: ubuntu-24.04
cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-26.04

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, apcu
php-version: '8.5'
extensions: mbstring, intl, sqlite3, pdo_sqlite
coverage: none

- name: Install dependencies
Expand All @@ -78,7 +73,5 @@ jobs:
- name: Run PHP CodeSniffer
run: composer cs-check

# NOTE: phpstan/psalm are pinned to 1.10.14 / 5.10.0 in .phive/phars.xml;
# those versions do not run on PHP 8.2+ (fatal in better-reflection) and
# report pre-existing findings. Modernize the pins in a separate change
# before wiring them back into CI as a blocking step.
- name: Run PHPStan
run: composer stan -- --no-progress
5 changes: 0 additions & 5 deletions .phive/phars.xml

This file was deleted.

17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
Changelog
=========

Releases for CakePHP 6.0
------------------------
* 4.0.0 (unreleased, tracks `cakephp/cakephp` `6.x-dev` until 6.0.0 is tagged; verified against core commit `421c644`, PHPUnit 13.4.6, PHP 8.5.12)
* **Breaking (requirements)** — PHP 8.5+, CakePHP 6.0 (`^6.0`, resolves `6.x-dev`: applications need `minimum-stability: dev` and `prefer-stable: true`), PHPUnit 13.
* **Breaking (API)** — the protected members of `BaseEngine`, `MysqlEngine`, `PostgresEngine`, `ExecuteTrait` and `FixtureManager` lost their underscore prefix, following CakePHP 6 and the `cakephp/cakephp-codesniffer` 6 standard: `_execute()` -> `execute()`, `_getBaseArguments()` -> `getBaseArguments()`, `_setPassword()` -> `setPassword()`, `__importTestSkeleton()` -> `importTestSkeleton()`, `_ensureFolder()` -> `ensureFolder()`, `$_verbose` -> `$verbose`, `$_database` -> `$database`. Subclasses must rename their overrides.
* **Breaking (API)** — `BaseEngine::isSuccess()` accepts `?int` (a `null` exit status is a failure).
* Fix: the `verbose` extension parameter is optional and parsed as a boolean string (`"false"` used to enable verbose logging, a missing parameter threw `ParameterDoesNotExistException`); `PHPUnitExtension::isVerbose()` is public
* Fix: engines build the CLI arguments from the keys the datasource defines (`host`, `port`, `username`, `password`) instead of raising `Undefined array key`; `PGPASSWORD` is only exported when a password is configured; a datasource without `database` throws `InvalidArgumentException` at engine construction
* Fix: `db_test` help text names `config/sql`; docs: verbose mode and plugin loading examples updated
* Fix: `fixture_import` reports a missing `test_template` datasource with its error message instead of an uncaught `MissingDatasourceConfigException`
* Fix: the MySQL password is shell-escaped (`escapeshellarg()`); a password containing a quote no longer breaks the command
* `DbTestCommand` and `FixtureImportCommand` follow the CakePHP 6 command shape: parameterless `execute()` reading `$this->args` and `$this->io`.
* Note — name `host`, `username`, `password` and `database` on the `test` and `test_template` connections (and `schema` on PostgreSQL when `createSchema()` should run): the engines read the raw datasource array (`Connection::config()`), the driver defaults (`localhost`, the default port, `public`) are never applied to it.
* Chore: `phpunit.xml.dbtest` migrated to the PHPUnit 13 schema (the `apc.enable_cli` ini line is gone: it is `PHP_INI_SYSTEM` and PHPUnit 12.5+ warns on it).
* Chore: the plugin's own suites fail on deprecations, notices and warnings; PHPStan 2 level 8 over `src/` and `tests/` without a baseline (only `missingType.iterableValue` is ignored by identifier) replaces the phive-installed PHPStan 1.10 and Psalm 5.10; `composer stan` runs it, `composer check` runs cs-check, stan and the unit suite.
* CI: PHP 8.5, coding standard and PHPStan job, `4.next-cake6` branch.

Releases for CakePHP 5.0
------------------------
* 3.1.0
Expand Down
15 changes: 12 additions & 3 deletions Docs/Documentation/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ Composer
composer require cakedc/cakephp-db-test
```

Until CakePHP 6.0.0 is tagged the plugin resolves against `cakephp/cakephp` `6.x-dev`, so the application's
`composer.json` needs `"minimum-stability": "dev"` and `"prefer-stable": true`.

Load the plugin
---------------

```
bin/cake plugin load CakeDC/DbTest
```
Note you'll need this plugin loaded in the `cli` section of your `Application::bootstrap`, around the line loading
Bake Plugin: `$this->addPlugin('DbTestPlugin');`
Or load it from `Application::bootstrap()` next to the other CLI-only plugins (Bake, Migrations):
`$this->addPlugin('CakeDC/DbTest');`

Configuration
-------------
Expand Down Expand Up @@ -43,9 +46,15 @@ Add the next configuration setting into app.php
// ...
```

Name `host`, `username`, `password` and `database` explicitly on both the `test` and the `test_template`
connections: the plugin reads the raw datasource array (`Connection::config()`), the driver defaults are never
applied to it, and the values go to `mysql`/`mysqladmin`/`mysqldump` or `psql`/`pg_dump`/`pg_restore` on the
command line. On PostgreSQL also name `schema` when the test database needs a `CREATE SCHEMA` after it is
recreated; without the key no schema is created.

PHPUnit
-------
Copy https://github.com/CakeDC/cakephp-db-test/blob/master/phpunit.xml.dbtest as phpunit.xml.dist in your
Copy https://github.com/CakeDC/cakephp-db-test/blob/4.next-cake6/phpunit.xml.dbtest as phpunit.xml.dist in your
project (modify if needed)

Fixture database
Expand Down
12 changes: 10 additions & 2 deletions Docs/Documentation/Workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,13 @@ Copy phpunit.xml.dbtest as phpunit.xml.dist in your project (modify if needed) a

Debug Test Suite
-------------------
Verbose mode enabled by second parameter of FixtureInjector set to true.
It is defined in phpunit.xml.dist in arguments section of FixtureInjector listener.
Verbose mode logs every shell command the engines run and its output (`Log::info()`). Enable it with the `verbose`
parameter of the extension in `phpunit.xml.dist` (`"true"`, `"1"`, `"on"` or `"yes"`; omitted or `"false"` is off):

```xml
<extensions>
<bootstrap class="CakeDC\DbTest\TestSuite\Fixture\Extension\PHPUnitExtension">
<parameter name="verbose" value="true"/>
</bootstrap>
</extensions>
```
6 changes: 3 additions & 3 deletions Docs/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ The **DbTest** plugin enables developers to speeding up tests running on MySQL o
Requirements
------------

* CakePHP 5.0+
* PHP 8.1+
* CakePHP 6.0 (6.x-dev until 6.0.0 is tagged; `minimum-stability: dev` and `prefer-stable: true` in the application `composer.json`)
* PHP 8.5+
* MySQL database with InnoDb engine
* PostgreSQL database
* Phpunit 10.*
* PHPUnit 13.*

Documentation
-------------
Expand Down
25 changes: 10 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"type": "cakephp-plugin",
"license": "MIT",
"require": {
"php": ">=8.1",
"cakephp/cakephp": "^5.0"
"php": ">=8.5",
"cakephp/cakephp": "^6.0"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
"cakephp/cakephp-codesniffer": "^4.0",
"phpunit/phpunit": "^13.0",
"cakephp/cakephp-codesniffer": "6.x-dev",
"phpstan/phpstan": "^2.1",
"ext-mbstring": "*"
},
"autoload": {
Expand All @@ -26,26 +27,20 @@
"scripts": {
"check": [
"@cs-check",
"@stan",
"@test"
],
"cs-check": "phpcs --colors --parallel=16 -p src/ tests/",
"cs-fix": "phpcbf --colors --parallel=16 -p src/ tests/",
"phpstan": "tools/phpstan analyse",
"psalm": "tools/psalm --show-info=false",
"stan": [
"@phpstan",
"@psalm"
],
"phpstan-tests": "tools/phpstan analyze -c tests/phpstan.neon",
"phpstan-baseline": "tools/phpstan --generate-baseline",
"psalm-baseline": "tools/psalm --set-baseline=psalm-baseline.xml",
"stan-setup": "phive install",
"stan": "phpstan analyse",
"test": "phpunit",
"test-integration": "phpunit -c phpunit.integration.xml"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
2 changes: 0 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0"?>
<ruleset name="DbTest plugin for CakePHP">
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer"/>

<rule ref="CakePHP"/>
</ruleset>
16 changes: 9 additions & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
parameters:
level: 8
treatPhpDocTypesAsCertain: false
checkGenericClassInNonGenericObjectType: false
bootstrapFiles:
- tests/bootstrap.php
paths:
- src/
level: 8
treatPhpDocTypesAsCertain: false
bootstrapFiles:
- tests/bootstrap.php
paths:
- src/
- tests/
ignoreErrors:
- identifier: missingType.iterableValue
31 changes: 25 additions & 6 deletions phpunit.integration.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2013 - 2023, Cake Development Corporation (https://www.cakedc.com)
~ Copyright 2013 - 2026, Cake Development Corporation (https://www.cakedc.com)
~
~ Licensed under The MIT License
~ Redistributions of files must retain the above copyright notice.
~
~ @copyright Copyright 2013 - 2023, Cake Development Corporation (https://www.cakedc.com)
~ @copyright Copyright 2013 - 2026, Cake Development Corporation (https://www.cakedc.com)
~ @license MIT License (http://www.opensource.org/licenses/mit-license.php)
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.4/phpunit.xsd"
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
cacheDirectory=".phpunit.cache"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
failOnDeprecation="true"
failOnPhpunitDeprecation="true"
failOnNotice="true"
failOnPhpunitNotice="true"
failOnWarning="true"
failOnRisky="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnPhpunitDeprecations="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnPhpunitNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerErrors="true">
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
<ini name="memory_limit" value="512M"/>
</php>

<testsuites>
Expand All @@ -30,9 +41,17 @@
<bootstrap class="CakeDC\DbTest\Test\TestSuite\Fixture\SqliteExtension"/>
</extensions>

<source>
<!--
Deprecations fail the run when the plugin triggers them or calls deprecated code of a dependency.
Deprecations raised inside the dependencies themselves (indirect) do not.
-->
<source ignoreIndirectDeprecations="true">
<include>
<directory suffix=".php">src/</directory>
</include>
<deprecationTrigger>
<function>Cake\Core\deprecationWarning</function>
<function>deprecationWarning</function>
</deprecationTrigger>
</source>
</phpunit>
14 changes: 5 additions & 9 deletions phpunit.xml.dbtest
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.4/phpunit.xsd"
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
cacheDirectory=".phpunit.cache"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
cacheDirectory=".phpunit.cache">
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
<ini name="memory_limit" value="512M"/>
</php>

<!-- Add any additional test suites you want to run here -->
Expand All @@ -22,8 +21,8 @@
<!-- Load extension for fixtures -->
<extensions>
<bootstrap class="CakeDC\DbTest\TestSuite\Fixture\Extension\PHPUnitExtension">
<!-- Optionaly enable verbosity -->
<parameter name="verbose" value="false" />
<!-- Optionally enable verbosity -->
<parameter name="verbose" value="false"/>
</bootstrap>
</extensions>

Expand All @@ -33,8 +32,5 @@
<directory suffix=".php">src/</directory>
<directory suffix=".php">plugins/*/src/</directory>
</include>
<exclude>
<file>src/Console/Installer.php</file>
</exclude>
</source>
</phpunit>
Loading