Codeception / Codeception/module-doctrine

Second and next requests in tests reloads entities from doctrine entity manager

Abierto
#18 3 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
PHP
Estrellas
4
Forks
2
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

#### 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
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
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:

```yml
modules:
enabled:
- Asserts: ~
- Symfony:
cache_router: true
rebootable_client: true
- REST:
url: /api
depends: Symfony
- Doctrine2:
depends: Symfony
- \Helper\Api: ~
disabled:
- PhpBrowser
- WebDriver
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Start with the Doctrine2 module and its Symfony dependency, using the provided test flow with rebootable_client enabled to reproduce the entity identity changes across requests. Trace the entity manager and request lifecycle, then verify that the initially grabbed entity instance is reused on the second and later requests without breaking the documented re-grab workaround.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
php
Área
databases, testing-qa
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.