Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seeInRepository does not work with values from multiple relations #7

Open
wazum opened this issue Aug 24, 2022 · 0 comments
Open

seeInRepository does not work with values from multiple relations #7

wazum opened this issue Aug 24, 2022 · 0 comments

Comments

@wazum
Copy link

wazum commented Aug 24, 2022

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

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

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

        $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 #16

@TavoNiievez TavoNiievez transferred this issue from Codeception/module-doctrine2 Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant