Codeception / Codeception/module-doctrine

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

Đang mở
#18 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
4
Fork
2
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu với module Doctrine2 và dependency Symfony của nó, sử dụng test flow được cung cấp với rebootable_client được bật để tái hiện các thay đổi về identity của entity giữa các request. Theo dõi vòng đời của entity manager và request, sau đó xác minh rằng entity instance được lấy ban đầu được tái sử dụng ở request thứ hai và các request tiếp theo mà không làm hỏng workaround re-grab đã được ghi chép.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
php
Lĩnh vực
databases, testing-qa
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.