Skip to content

Commit 1fc139b

Browse files
committed
Add current requirements section, import note, and upgrade checklist
1 parent 5aed5da commit 1fc139b

2 files changed

Lines changed: 48 additions & 2 deletions

File tree

docs/en/appendices/phpunit-upgrade.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# PHPUnit Upgrade
22

3-
CakePHP 5 supports PHPUnit 11 and 12. This guide covers migrating from older PHPUnit versions.
3+
This guide covers the PHPUnit version requirements and migration steps for CakePHP 5.x applications.
4+
5+
## Current Requirements
6+
7+
CakePHP 5.x requires **PHPUnit ^11.5.3 or ^12.1.3**. This means:
8+
9+
- PHPUnit 11.5.3+ requires **PHP 8.2** or later
10+
- PHPUnit 12.1.3+ requires **PHP 8.3** or later
11+
12+
> [!NOTE]
13+
> PHPUnit 10 is no longer supported in CakePHP 5.x. If you are still on PHPUnit 10,
14+
> you must upgrade to PHPUnit 11 or 12.
415
516
## phpunit.xml Adjustments
617

@@ -99,6 +110,8 @@ Common attribute replacements:
99110
| `@covers` | `#[CoversClass(ClassName::class)]` |
100111
| `@test` | `#[Test]` |
101112

113+
Remember to import the attribute classes from `PHPUnit\Framework\Attributes`.
114+
102115
### Test Doubles for Abstract Classes Deprecated
103116

104117
Methods for creating mock objects for abstract classes and traits are hard-deprecated. Testing traits in isolation from the classes that use them is discouraged.
@@ -152,3 +165,13 @@ vendor/bin/rector process tests/
152165
```
153166

154167
Configure Rector with PHPUnit rulesets to handle data provider static conversion, annotation to attribute migration, and other changes automatically.
168+
169+
## Upgrade Checklist
170+
171+
Before upgrading PHPUnit versions, ensure:
172+
173+
1. Your test suite runs without deprecation warnings on your current PHPUnit version
174+
2. All data providers are `public static` methods
175+
3. You are using attributes instead of annotations (required for PHPUnit 12)
176+
4. Mock expectations only use `createMock()`, not `createStub()`
177+
5. Run `vendor/bin/phpunit --migrate-configuration` after upgrading

docs/ja/appendices/phpunit-upgrade.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# PHPUnit アップグレード
22

3-
CakePHP 5 は PHPUnit 11 および 12 をサポートしています。このガイドでは、古いバージョンの PHPUnit からの移行について説明します。
3+
このガイドでは、CakePHP 5.x アプリケーションの PHPUnit バージョン要件と移行手順について説明します。
4+
5+
## 現在の要件
6+
7+
CakePHP 5.x は **PHPUnit ^11.5.3 または ^12.1.3** が必要です:
8+
9+
- PHPUnit 11.5.3+ は **PHP 8.2** 以降が必要です
10+
- PHPUnit 12.1.3+ は **PHP 8.3** 以降が必要です
11+
12+
> [!NOTE]
13+
> CakePHP 5.x では PHPUnit 10 はサポートされなくなりました。まだ PHPUnit 10 を使用している場合は、
14+
> PHPUnit 11 または 12 にアップグレードする必要があります。
415
516
## phpunit.xml の調整
617

@@ -96,6 +107,8 @@ public function testSomething(): void
96107
| `@covers` | `#[CoversClass(ClassName::class)]` |
97108
| `@test` | `#[Test]` |
98109

110+
アトリビュートクラスは `PHPUnit\Framework\Attributes` からインポートして下さい。
111+
99112
### 抽象クラスのテストダブルが非推奨に
100113

101114
抽象クラスおよびトレイトのモックオブジェクトを作成するメソッドが非推奨になりました。トレイトを使用するクラスから分離してテストすることは推奨されません。
@@ -149,3 +162,13 @@ vendor/bin/rector process tests/
149162
```
150163

151164
Rector の PHPUnit ルールセットを設定することで、data provider の static 変換、アノテーションからアトリビュートへの移行などの変更を自動的に処理できます。
165+
166+
## アップグレードチェックリスト
167+
168+
PHPUnit のバージョンをアップグレードする前に、以下を確認して下さい:
169+
170+
1. 現在の PHPUnit バージョンでテストスイートが非推奨の警告なしに実行できること
171+
2. すべての data provider が `public static` メソッドであること
172+
3. アノテーションではなくアトリビュートを使用していること(PHPUnit 12 で必須)
173+
4. モックのエクスペクテーションが `createStub()` ではなく `createMock()` のみを使用していること
174+
5. アップグレード後に `vendor/bin/phpunit --migrate-configuration` を実行すること

0 commit comments

Comments
 (0)