Second and next requests in tests reloads entities from doctrine entity manager
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- php
- Ambito
- databases, testing-qa
Direzione di ricerca
Inizia con il modulo Doctrine2 e la relativa dipendenza Symfony, utilizzando il flusso di test fornito con rebootable_client abilitato per riprodurre i cambiamenti dell’identità dell’entità tra le richieste. Traccia il ciclo di vita dell’entity manager e della richiesta, quindi verifica che l’istanza dell’entità recuperata inizialmente venga riutilizzata nella seconda richiesta e in quelle successive senza rompere il workaround documentato di nuovo recupero.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- PHP
- Stelle
- 4
- Fork
- 2
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Codeception/module-doctrine
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Codeception/module-doctrine#2 · 1 commento · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
Codeception/module-doctrine#6 · 1 commento ·
Tutte le issue di Codeception/module-doctrine
Issue simili
-
tooling
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
ProfessionalWiki/NeoWiki#1525 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
OpenConext/OpenConext-engineblock#2122 ·
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Automattic/safe-publish#594 ·