Second and next requests in tests reloads entities from doctrine entity manager
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- php
- 領域
- databases, testing-qa
調査の方向性
Doctrine2 モジュールとその Symfony 依存関係から始め、rebootable_client を有効にした提供済みのテストフローを使用して、リクエスト間でエンティティの同一性が変化することを再現します。entity manager とリクエストのライフサイクルを追跡し、最初に取得したエンティティインスタンスが 2 回目以降のリクエストで再利用されることを確認します。その際、文書化されている再取得の workaround を壊さないようにします。
索引モデルが issue の本文から書いたものです。
説明
What are you trying to achieve?
All requests should use same instances of entities during the test.
What do you get instead?
Second and subsequent requests reloads entities which causes instances within test to be different from those that are used within those requests.
<?php
public function test(\Codeception\Actor $tester)
{
$instance = $tester->grabEntityFromRepository(Foo::class, ['id' => 1]); // spl_object_hash: 000000006cf7be51000000007baa4f48
$tester->sendPUT('/foo'); // spl_object_hash: 000000006cf7be51000000007baa4f48 same as first
$tester->sendPUT('/foo'); // spl_object_hash: 000000006cf7b6b0000000007baa4f48 different than previous
$tester->sendPUT('/foo'); // spl_object_hash: 000000006cf7b5c0000000007baa4f48 different than previous
// $instance here has different values than those used within second and any subsequent request
}
Workaround
In order to get latest version of the entity we have to "re-grab" it from repository:
<?php
$instance = $tester->grabEntityFromRepository(Foo::class, ['id' => 1]); // spl_object_hash: 000000006cf7b5c0000000007baa4f48 is same as in last request
But it would be better to reuse the first instance the same way first request does.
Details
- Codeception version: 2.5.1
- PHP Version: 7.1.24
- Operating System: Linux
- Installation type: Composer
- Suite configuration:
modules:
enabled:
- Asserts: ~
- Symfony:
cache_router: true
rebootable_client: true
- REST:
url: /api
depends: Symfony
- Doctrine2:
depends: Symfony
- \Helper\Api: ~
disabled:
- PhpBrowser
- WebDriver
- 主要言語
- PHP
- スター
- 4
- フォーク
- 2
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Codeception/module-doctrine のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Codeception/module-doctrine#2 · コメント 1 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
Codeception/module-doctrine#6 · コメント 1 件 ·
Codeception/module-doctrine の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
[Sync EN] Fix session read handler docs: false reports a failure, not a missing session (#5902)オープンsync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[Sync EN] Fix session read handler docs: false reports a failure, not a missing session (#5902)オープンsync-en
難易度 2/5 1〜2日 初心者へのやさしさ 84/100
メンテナーはふだん 2 日以内に返信
-
feature-request needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
aws/aws-sdk-php#3365 ·
メンテナーはふだん 1 日以内に返信