Skip to content

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

Description

@2ur1st

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions