guy-fawkes / FriendlyContexts

Some Behat contexts
MIT License
0 stars 0 forks source link

Ensure all specified Alice associations are complete #11

Open dankempster opened 4 years ago

dankempster commented 4 years ago

When alice fixture files are loaded out of order, this ensures all the generated models have their required associations after Alice is finished generating.

For example: When there are two fixture files and one references models from the other like

# ./feature/fixtures/products.yml
Product:
  product-a:
    name: Product A
    category '@category-a'
#./features/fixtures/categories.yml
Category:
  category:
    category-a:
      name: Category A

If AliceContext ends up loading them out of order i.e. $aliceLoader->loadFiles(['product.yml', 'category.yml']) the models are still generated without error; But, the Product model's category is NULL.

My example above is very much simplified but should describe the problem. I've only experienced this issue when using multiple @alice() tags with large & complex dependencies defined in behat.yml.

This PR adds an additional 'pass' that searches the generated models for associations in the spec that have NULL values and corrects them.