12

It's possible to describe fixture inheritance in Alice:

// template.yml
Nelmio\Entity\User:
    user (template):
        username: '<username()>'
        age: '<numberBetween(1, 20)>'

--

include:
  - template.yml

Nelmio\Entity\User:
    user1 (extends user):
        name: '<firstName()>'
        lastname: '<lastName()>'
        city: '<city()>'
        age: '<numberBetween(1, 50)>'

What about defining reusable collections of properties (similar to Traits)?

What if I want to be able to define a template with two properties, e.g.

createdAt: <(new \DateTime('2016-01-01'))>
updatedAt: <(new \DateTime('2016-01-02'))>

and then use those in any template without having to redefine these properties for each entity?

I know Alice supports multi-inheritance. e.g.:

Nelmio\Entity\User:
    user_bare (template):
        username: '<username()>'
    user_full (template, extends user_bare):
        name: '<firstName()>'
        lastname: '<lastName()>'
        city: '<city()>'

This, however, does not seem to be the way forward due to the fact that each template has to be defined under the same namespace (Nelmio\Entity\User), while Traits should be good to use in any namespace.

Is there a clean way to reuse groups of fixture properties in any namespace?

luqo33
  • 8,001
  • 16
  • 54
  • 107
  • 2
    Looks like a feature request, don't hesitate to submit your request on the github project https://github.com/nelmio/alice/issues – GiDo Sep 26 '17 at 22:58

0 Answers0