alice icon indicating copy to clipboard operation
alice copied to clipboard

Referencing literal self variables

Open xDaizu opened this issue 2 years ago • 1 comments

This code works:

  teacher_community_2:
    __factory:
      from:
        id: ~
        forename: 'Joshua'
        surname: '<lastName()>'
        displayName: 'Dr. $surname'

But this one doesn't:

  teacher_community_2:
    __factory:
      from:
        id: ~
        forename: 'Joshua'
        surname: 'Potato'
        displayName: 'Dr. $surname'

It throws:

In UnresolvableValueExceptionFactory.php line 77:
                                         
  Could not find a variable "$surname".  

Apparently, the own variables are only available if they come from a Faker source; but not if they are defined as a literal.

@self->surname does not work either, since it throws:

In ObjectNotFoundExceptionFactory.php line 23:
                                                                                            
  Could not find the object "teacher_community_2" of the class "Teacher".  

Is this a bug or am I missing something in the documentation?

xDaizu avatar Feb 09 '22 11:02 xDaizu

No that definitely looks like a bug.

the own variables are only available if they come from a Faker source

That should not be the case

@self->surname

And this should work

theofidry avatar Feb 12 '22 10:02 theofidry