Codeception / module-doctrine

Next gen Doctrine module for Codeception
MIT License
2 stars 1 forks source link

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

Open 2ur1st opened 8 months ago

2ur1st commented 8 months ago

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