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

Method haveInRepository() does not work with readonly property in Embeddable #2

Open
2ur1st opened this issue Oct 17, 2023 · 0 comments

Comments

@2ur1st
Copy link

2ur1st commented Oct 17, 2023

Hi, thanks for good library
How I can use method haveInRepository() with readonly property,
Example: simple entity with embeddable property

#[Entity]
class User
{
    public function __construct(
         #[Embedded(class: Address::class)] private Address $address
   ) {
   }
    
   public function getAddres(): Address 
   {
        return $this->address;
   }
}

#[Embeddable]
class Address
{
    #[Column(type: "string")]
    private readonly string $street;

    #[Column(type: "string")]
    private readonly string $city;
}

I want use method haveInRepository() for creating test entities like this

$I->haveInRepository(new User(
     address: new Address(
            street: 'Test street',
            city: 'Toronto'
     );
);

But got error after run Cest:

[LogicException] Attempting to change readonly property Address::$street.

How I can fix it? Thanks

@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