Codeception / Codeception/module-doctrine

seeInRepository does not work with values from multiple relations

Đang mở
#7 0 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ả

Example: a one-to-many relation (uni-directional, so implemented as many-to-many with join table):

```php
#[ManyToMany(targetEntity: Ordination::class, cascade: ['all'], orphanRemoval: true)]
private Collection|ArrayCollection $ordinations;
```

Just for this example I save a `Doctor` entity with two `Ordination` relations with `haveInRepository` in my test.
But then there's no possibility to check for values of both ordinations
```php
$this->tester->seeInRepository(Doctor::class, [
'name.firstName' => 'Mauris',
'ordinations' => [
[
'externalReferenceId' => '3'
]
]
]);
```

This leads to
```
[Doctrine\ORM\Query\QueryException] [Syntax Error] line 0, col 140: Error: Expected Doctrine\ORM\Query\Lexer::T_IDENTIFIER, got '0'
```
because of the nested structure.
What works is a check for a single relation:

```php
$this->tester->seeInRepository(Doctor::class, [
'name.firstName' => 'Mauris',
'ordinations' => [
'externalReferenceId' => '3'
]
]);
```

(so as a workaround, I could call the `seeInRepository` multiple times with a different relation's values …)

The problem is in the method \Codeception\Module\Doctrine2::_buildAssociationQuery
but I'm not really sure how to fix this for a PR. Anyone with more knowledge on this?

I guess this issue is somehow related to Codeception/module-doctrine#16

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

Đánh giá

Issue này chưa được đánh giá.

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.