0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【CakePHP3】"Test code or tested code did not (only) close its own output buffers"エラーの対処

Last updated at Posted at 2021-06-08

何が起きたか

コントローラのテストのとあるケースで risky 判定されてました
その時の表示メッセージが以下

Test code or tested code did not (only) close its own output buffers

バージョン

  • CakaPHP 3.8.13
  • PHPUnit 6.5.14

原因調査

コントローラで新規にエンティティ作って

Controller
$this->set('ent', $this->Sample->newEntity());

フォームに突っ込むケースで発生してるっぽい

Template
<?= $this->Form->create($ent) ?>

・・・別に変な使い方ではないはず

ということでCakePHPのリリースノートをあさってみると

Fix output buffers not being closed when view templates or blocks are being rendered. This fixes tests being marked as risky in PHPUnit.

CakePHP 3.9.2 のバグ修正内容と今回の症状が合致してました

早速バージョン上げてテスト

PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

.                                                                   1 / 1 (100%)

Time: 683 ms, Memory: 22.00MB

OK (1 test, 2 assertions)

通りましたね

結論

CakePHPのバージョンを3.9.2以上にすれば解決

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?