I'm using api-platform and I write unittest with fixtures (https://api-platform.com/docs/distribution/testing/#testing-the-api). When I run test for specific class I got the same fixtures data but when I run all test I got some data random.
Here are my fixtures:
# one file
App\Entity\User:
user_{1..11}:
nickname: '<username()>'
avatar: '@image_user_<current()>'
firstname: '<firstname()>'
lastname: '<lastname()>'
user_{12..13}:
nickname: '<username()>'
avatar: null
firstname: '<firstname()>'
lastname: '<lastname()>'
# other file
App\Entity\Project:
project_{1..7}:
name: '<company()>'
author: '@user_<numberBetween(3, 13)>'
main_image: '@image_project_<current()>'
score: '<randomFloat(null, 0, 5)>'
created_at: <dateTime('2020-08-11 09:24')>
Nelmio_alice config looks like:
> bin/api debug:config nelmio_alice
Current configuration for extension with alias "nelmio_alice"
=============================================================
nelmio_alice:
functions_blacklist:
- current
- shuffle
- date
- time
- file
- md5
- sha1
locale: en_US
seed: 1
loading_limit: 5
max_unique_values_retry: 150
When I run test for one class every time they pass (all data are the same):
bin/api-test tests/Entity/UserTest
bin/api-test tests/Entity/ProjectTest
But when I want to run all tests I got random data for user
bin/api-test
When I clear cache I got random data for project too but with next run projects test pass, users not
bin/api cache:clear --env=test
bin/api-test
// some projects and users test fail
bin/api-test
// projects tests pass, users not
bin/api
is an alias fordocker-compose exec php bin/console
bin/api-test
is an alias fordocker-compose exec php bin/phpunit