Closed ScottA38 closed 4 years ago
EDIT: I need to amend this Issue - I did not read the input parameters of [Populator]->addEntity(), as the final parameter is $generateId
.
When using this parameter the issue I get a further error:
PHP Fatal error: Uncaught Error: Call to a member function toArray() on array in [base_path]/shopping_app_test/vendor/fzaninotto/faker/src/Faker/ORM/Doctrine/EntityPopulator.php:242
It is safe to say I have no idea what is function is doing, but the query within it returns an empty array. I already forked the repository but the composer.json doesn't include Doctrine thus I don't know how to proceed with altering.
Just to reiterate, when directly interfacing the EntityManager my sku generation works absolutely fine
Sorry to add this issue without doing the proper digging:
my sku generation works absolutely fine
...was absolutely untrue - I was checking a non-primary-key field for collisions within the repository
Summary
I am currently writing tests and seeding random data into entities and persisting using the Populator. The ID for my Doctrine objects is:
[1st 3 consonants of name property][number calculated as 1 greater than the count of existing name collisions][1st 2 consonants of entity class name]
For instance, in my Book class, with a name of 'Harry Potter', I would have:
HRR1BK
Versions
fzaninotto/faker
Self-enclosed code snippet for reproduction
N.B: look at 'populate' in this 'EntityPopulator' wrapper class - please ignore things such as the foreach loop
My doctrine sku generator:
Expected output
Actual output
When I persist and flush entities manually (such as in a previous version of my 'main.php' file as shown above, the incrementing of the SKU number when there would be a primary-key collision works fine, which leads me to believe that me specifying a 'batchSize' parameter of
1
in thePopulator
constructor is not causing a flush to the database on every entity.