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

haveInRepository gives constructor parameter missing? #5

Open
blueblakk opened this issue Jul 17, 2023 · 0 comments
Open

haveInRepository gives constructor parameter missing? #5

blueblakk opened this issue Jul 17, 2023 · 0 comments

Comments

@blueblakk
Copy link

/**
 * @ORM\Entity
 * @ORM\Table("processes")
 */
class Process extends Entity
{
    /**
     * @ORM\ManyToOne(inversedBy="processes")
     * @ORM\JoinColumn(nullable=false)
     */
    private QueueItem $queueItem;

    public function __construct(QueueItem $queueItem)
    {
        $this->queueItem = $queueItem;
    }
}

In test:

$processId = $this->tester->haveInRepository(Process::class, [
    'queueItem' => ['name' => 'queue item name']
]);

Throws exception:

InvalidArgumentException : Constructor parameter "queueItem" missing

If I read the documentation correctly for haveInRepository:

Alternatively, constructor arguments can be passed by name. Given User constructor signature is __constructor($arg), the example above could be rewritten like this: $I->haveInRepository(User::class, ['arg' => $arg, 'name' => 'davert']);

It should actually instantiate the QueueItem and pass it as the argument into the Process constructor or does it only work with scalar types?

@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