Coder Social home page Coder Social logo

liip / liiptestfixturesbundle Goto Github PK

View Code? Open in Web Editor NEW
162.0 6.0 46.0 1.04 MB

This bundles enables efficient loading of Doctrine fixtures in functional test-cases for Symfony applications

Home Page: https://liip.ch

License: MIT License

PHP 99.53% Dockerfile 0.47%
php symfony-bundle testing database rdbms mongodb

liiptestfixturesbundle's Introduction

liiptestfixturesbundle's People

Contributors

aerendir avatar ajessu avatar alexislefebvre avatar arthurhall avatar barthuttinga avatar beberlei avatar chris53897 avatar chris8934 avatar colinfrei avatar dbu avatar gordalina avatar jean85 avatar jeanmonod avatar jmclean avatar jonotron avatar kniziol avatar lapistano avatar lsmith77 avatar magnetik avatar maximgubar avatar mbabker avatar mmenozzi avatar ndench avatar rvanlaak avatar sane4ek-2 avatar seldaek avatar soullivaneuh avatar sven-ahrens avatar tackerm avatar vishalmelmatti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

liiptestfixturesbundle's Issues

Throw exception for invalid cache service ID

Is your feature request related to a problem? Please describe.

I took part lately in upgrading a project to newer version of Symfony which also included upgrading the version of LiipFunctionalTestBundle and usage of newer LiipTestFixturesBundle. Our tests started to suffer from really bad performance. It turned out that we've made a typo in config Yaml for parameter liip_test_fixtures.cache_db.sqlite. The AbstractDatabaseTool::getBackupService() method loads the service only if it exists and silently disables all cache when it does not exist. So our project stopped using fixtures cache and we weren't aware of that up until we investigated the problem with Xdebug.

Describe the solution you'd like

I would like to know when there is an ID of non-existent service used in my configuration. I would expect the cache warmup or tests to raise an exception in this case.

CI: the job “--prefer-lowest” is slow

The job “--prefer-lowest” is slow, composer update --prefer-lowest takes 2 minutes while composer install takes 10 seconds.

It was slow on my local environment too.

Something from #124 is causing issues when Composer resolve the dependencies:

Preconditions

No.

Steps to reproduce

Run composer update --prefer-lowest

Expected result

This job shouldn't take more time that the other jobs.

Actual result

It's slow.

Make this working with in memory sqlite db to make tests faster

After setting the sqlite connection to:

sqlite:
    driver:   pdo_sqlite
    memory:   true

it gives troubles saying "undefined index: dbname in Test/WebTestCase.php on line 201", I've tried to hard set that value but in that case the tables are not created within the tests and ever query returns unknown table.

Would be a nice feature to add.

ORMDatabaseTool#enableForeignKeyChecksIfApplicable() does not enable FOREIGN_KEY_CHECKS

Due to typo in SQL statement in ORMDatabaseTool#enableForeignKeyChecksIfApplicable() foreign key check remains deactivated

Preconditions

  1. Whenever you load fixtures (Alice or Doctrine) the foreign key check for current connection remains deactivated.

Steps to reproduce

  1. Load fixtures
  2. Execute following $this->getContainer()->get('doctrine')->getManager()->getConnection()->fetchAll('SELECT @@GLOBAL.foreign_key_checks, @@SESSION.foreign_key_checks')

Expected result

  1. The value of @@GLOBAL.foreign_key_checks is 1
  2. The value of @@SESSION.foreign_key_checks is 1

Actual result

  1. The value of @@GLOBAL.foreign_key_checks is 1
  2. The value of @@SESSION.foreign_key_checks is 0

cannot installation

sorry...my English is not good
what wrong is it??
I want install for my symfony 4.4

[root@localhost vincent_yang]# composer require --dev liip/test-fixtures-bundle:^1.0.0

Do not run Composer as root/super user! See https://getcomposer.org/root for details
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.4.*"
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install liip/test-fixtures-bundle 1.9.1
    - Conclusion: don't install liip/test-fixtures-bundle 1.9.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.8.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.7.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.6.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.5.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.4.1
    - Conclusion: don't install liip/test-fixtures-bundle 1.4.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.3
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.2
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.1
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.2.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.2
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.1
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.0.1
    - Conclusion: remove doctrine/cache 1.10.2
    - Conclusion: don't install doctrine/cache 1.10.2
    - doctrine/common 2.2.1 conflicts with doctrine/cache[1.10.2].
    - doctrine/common 2.2.2 conflicts with doctrine/cache[1.10.2].
    - doctrine/common 2.2.3 conflicts with doctrine/cache[1.10.2].
    - doctrine/common 2.3.0 conflicts with doctrine/cache[1.10.2].
    - Conclusion: don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.9.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.9.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.9.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.9.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.9.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.9.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.9.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.9.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.8.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.8.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.8.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.8.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.7.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.7.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.7.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.7.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.6.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.6.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.6.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.6.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.5.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.5.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.5.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.5.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.4.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.4.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.4.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.4.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.4.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.4.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.4.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.4.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.3|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.3|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.3|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.3|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.2|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.2|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.2|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.2|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.3.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.2.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.2.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.2.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.2.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.2|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.2|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.2|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.2|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.0|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.1.0|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.0.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.0.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Installation request for doctrine/cache (locked at 1.10.2) -> satisfiable by doctrine/cache[1.10.2].
    - Conclusion: don't install liip/test-fixtures-bundle 1.0.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Conclusion: don't install liip/test-fixtures-bundle 1.0.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - Installation request for liip/test-fixtures-bundle ^1.0.0 -> satisfiable by liip/test-fixtures-bundle[1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.1.2, 1.2.0, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0, 1.4.1, 1.5.0, 1.6.0, 1.7.0, 1.8.0, 1.9.0, 1.9.1].
    - Conclusion: remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
    - liip/test-fixtures-bundle 1.0.0 requires doctrine/common ^2.0 -> satisfiable by doctrine/common[2.1.3, 2.1.4, 2.12.0, 2.13.0, 2.13.1, 2.13.2, 2.13.3, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.3.0, v2.10.0, v2.11.0, v2.4.0, v2.4.1, v2.4.2, v2.4.3, v2.5.0, v2.5.1, v2.5.2, v2.5.3, v2.6.0, v2.6.1, v2.6.2, v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.8.0, v2.8.1, v2.9.0].
    - Can only install one of: doctrine/common[2.13.0, 3.0.2].
    - Can only install one of: doctrine/common[2.13.1, 3.0.2].
    - Can only install one of: doctrine/common[2.13.2, 3.0.2].
    - Can only install one of: doctrine/common[2.13.3, 3.0.2].
    - Can only install one of: doctrine/common[2.1.3, 3.0.2].
    - Can only install one of: doctrine/common[2.1.4, 3.0.2].
    - Can only install one of: doctrine/common[2.12.0, 3.0.2].
    - Can only install one of: doctrine/common[2.2.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.10.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.11.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.4.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.4.1, 3.0.2].
    - Can only install one of: doctrine/common[v2.4.2, 3.0.2].
    - Can only install one of: doctrine/common[v2.4.3, 3.0.2].
    - Can only install one of: doctrine/common[v2.5.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.5.1, 3.0.2].
    - Can only install one of: doctrine/common[v2.5.2, 3.0.2].
    - Can only install one of: doctrine/common[v2.5.3, 3.0.2].
    - Can only install one of: doctrine/common[v2.6.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.6.1, 3.0.2].
    - Can only install one of: doctrine/common[v2.6.2, 3.0.2].
    - Can only install one of: doctrine/common[v2.7.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.7.1, 3.0.2].
    - Can only install one of: doctrine/common[v2.7.2, 3.0.2].
    - Can only install one of: doctrine/common[v2.7.3, 3.0.2].
    - Can only install one of: doctrine/common[v2.8.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.8.1, 3.0.2].
    - Can only install one of: doctrine/common[v2.9.0, 3.0.2].
    - Installation request for doctrine/common (locked at 3.0.2) -> satisfiable by doctrine/common[3.0.2].


Installation failed, reverting ./composer.json to its original content.```

InvalidArgumentException: "App\DataFixtures\UserFixtures" is not a registered fixture

I'm using Symfony 5. I installed "LiipTestFixturesBundle" with composer require --dev liip/test-fixtures-bundle.

I created this fixture :

<?php

namespace App\DataFixtures;

use App\Entity\user\User;
use App\Entity\user\Profile;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;

class UserFixtures extends AbstractFixture implements FixtureInterface
{
 
    private $encoder;
 
    public function __construct(UserPasswordEncoderInterface $encoder)
    {

        $this->encoder = $encoder;

    }
    public function load(ObjectManager $manager)
    {

        for($i = 0; $i < 10; $i++) 
        {

            $user = new User();
            $profile = new Profile();
            $hash = $this->encoder->encodePassword($user, 'roadtripr12');

            $user
                ->setName('username' . $i)
                ->setFirstname('firstname' . $i)
                ->setEmail('username' . $i . '@roadtripr.com')
                ->setRoles(['ROLE_USER'])
                ->setPassword($hash)
                ->setUserName('username' . $i)
                ->setProfile($profile)
            ;

        }

        for($i = 0; $i < 10; $i++) 
        {

            $user = new User();
            $profile = new Profile();
            $hash = $this->encoder->encodePassword($user, 'roadtripr12');

            $user
                ->setName('ownerUsername' . $i)
                ->setFirstname('ownerFirstname' . $i)
                ->setEmail('ownerUsername' . $i . '@roadtripr.com')
                ->setRoles(["ROLE_OWNER","ROLE_USER"])
                ->setPassword($hash)
                ->setUserName('ownerUsername' . $i)
                ->setProfile($profile)
            ;

        }

        for($i = 0; $i < 5; $i++) 
        {

            $user = new User();
            $profile = new Profile();
            $hash = $this->encoder->encodePassword($user, 'roadtripr12');

            $user
                ->setName('adminrUsername' . $i)
                ->setFirstname('adminFirstname' . $i)
                ->setEmail('ownerUsername' . $i . '@roadtripr.com')
                ->setRoles(["ROLE_ADMIN","ROLE_USER"])
                ->setPassword($hash)
                ->setUserName('adminUsername' . $i)
                ->setProfile($profile)
            ;

        }

    }

}

I created this test :

<?php

namespace App\tests\Repository\user;

use App\DataFixtures\UserFixtures;
use App\Repository\user\UserRepository;
use Liip\TestFixturesBundle\Test\FixturesTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class UserRepositoryTest extends WebTestCase
{

    use FixturesTrait;

    public function testCount()
    {

        self::bootKernel();
        $this->loadFixtures(array(UserFixtures::class));

        $users = self::$container->get(UserRepository::class)->count([]);

        $this->assertEquals(25, $users);

    }
    
}

When I run php bin/phpunit, I have this error :

InvalidArgumentException: "App\DataFixtures\UserFixtures" is not a registered fixture

Improve the documentation

Is your feature request related to a problem? Please describe.
This page has much text, and could be made easier to read.

Describe the solution you'd like
On the top of the page, it should mention the methods provided by the bundle to ease its usage, with links to explain the different arguments of the methods.

It should include the method added in #115 done in #117 ✔️

Describe alternatives you've considered
.

Additional context
.

"doctrine/doctrine-fixtures-bundle must be installed to use this method."

Getting the above error when running my tests even though the bundle is installed.

Preconditions

  1. Symfony 3.4.36
  2. doctrine/doctrine-fixtures-bundle 3.1.1
  3. liip/functional-test-bundle 3.2.0
  4. liip/test-fixtures-bundle1.6.0
  5. PHP 7.2.25

Steps to reproduce

Not sure, still investigating

Expected result

It should detect that I have doctrine/doctrine-fixtures-bundle installed

Actual result

It doesn't detect it.

Fixture refs and sqlite caching

It seems that loading fixtures and setting references are not working when the sqlite caching is enabled. It gives an array to string conversion error.

/app/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:3034
/app/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:491
/app/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/ProxyReferenceRepository.php:78
/app/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/ProxyReferenceRepository.php:105
/app/vendor/liip/test-fixtures-bundle/src/Services/DatabaseBackup/SqliteDatabaseBackup.php:68
/app/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php:52
/app/vendor/liip/test-fixtures-bundle/src/Test/FixturesTrait.php:110

The identifier id is missing for a query of ...

Every thing was working great, until I enabled the cache_db configuration:

liip_test_fixtures:
    cache_db:
        sqlite: liip_test_fixtures.services_database_backup.sqlite

This is the stack trace of the exception I'm getting, any help would be appreciated:


1) App\Tests\Api\EmployeeTest::testExportCollection
Doctrine\ORM\ORMException: The identifier id is missing for a query of App\Entity\Evaluation\Employee
/builds/oppbtp/oppbtp_qcm_elec_api/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php:309
/builds/oppbtp/oppbtp_qcm_elec_api/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:488
/builds/oppbtp/oppbtp_qcm_elec_api/var/cache/test/ContainerWI1DfLB/EntityManager_9a5be93.php:142
/builds/oppbtp/oppbtp_qcm_elec_api/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/ProxyReferenceRepository.php:82
/builds/oppbtp/oppbtp_qcm_elec_api/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/ProxyReferenceRepository.php:115
/builds/oppbtp/oppbtp_qcm_elec_api/vendor/liip/test-fixtures-bundle/src/Services/DatabaseBackup/SqliteDatabaseBackup.php:68
/builds/oppbtp/oppbtp_qcm_elec_api/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php:52
/builds/oppbtp/oppbtp_qcm_elec_api/vendor/liip/test-fixtures-bundle/src/Test/FixturesTrait.php:86
/builds/oppbtp/oppbtp_qcm_elec_api/src/Test/CustomApiTestCase.php:51

This a small vision about my dependencies:

doctrine/data-fixtures                       1.4.2   Data Fixtures for al...
doctrine/doctrine-fixtures-bundle            3.3.0   Symfony DoctrineFixt...
liip/test-fixtures-bundle                    1.7.0   This bundles enables.

SQLite schema is not instantiated for non-test environment

When running the test suite via a different environment as test, the tests fail because the sqlite database does not seem to get instantiated (migrations do not get executed first?).

Changing \Liip\TestFixturesBundle\Test\FixturesTrait::$environment to the expected environment manually fixes the below.

Preconditions

  1. php 7.3
  2. symfony 4.3
  3. LiipTestFixturesBundle 1.3.2
  4. for env test and int Doctrine configuration is setup with pdo_sqlite driver and "%kernel.cache_dir%/test.db" as path
  5. am running phpunit via docker:

docker run --rm -v $(DIR):/app -w /app -e APP_ENV=int composer bin/phpunit --configuration phpunit.integration.xml

Steps to reproduce

  1. write a functional test that loads a fixture
  2. running on app environment test works fine
  3. changing app environment to int and run tests

Expected result

Tests should pass when running on different environment. Fixtures should get loaded

Actual result

  • Tests fail, table does not seem to be there.

image

  • The "test.db" file does get written to the /cache/int folder, but the db file is empty. The db file for environment test is not empty, it seems to be instantiated ok

  • The connection seems ok. After copying the above instantiated test.db to the int cache folder, and running the tests again, the fixture can get created.

  • phpunit.integration.xml is an identical copy of a normal phpunit.xml.dist, but with APP_ENV set to int

Option memory of SQLite not working

Hello, in Symfony 3.4, I tried using the memory option in order to make my tests faster but an error occurred:

1) Tests\AppBundle\Controller\DefaultControllerTest::testIndex
copy(mydb): failed to open stream: No such file or directory

My test config is the following:

imports:
    - { resource: config_dev.yml }

framework:
    test: ~
    session:
        storage_id: session.storage.mock_file
        name: MOCKSESSION
    profiler:
        collect: false

web_profiler:
    toolbar: false
    intercept_redirects: false

swiftmailer:
    disable_delivery: true

liip_functional_test:
    cache_db:
        sqlite: liip_functional_test.services_database_backup.sqlite

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver:   pdo_sqlite
                memory:   true
security:
    firewalls:
        main:
            http_basic: ~

Thank you.

Call to undefined method Doctrine\ODM\MongoDB\SchemaManager::createDatabases()

Trying to load some ODM fixtures gives the title error.

Preconditions

version 1.6.0 with mongodb-dom 2.0.3

Steps to reproduce

    $this->loadFixtures([], false, 'default', 'doctrine_mongodb', false);

Expected result

Happy fixtures loaded

Actual result

No fixtures loaded and unhappy "Call to undefined method Doctrine\ODM\MongoDB\SchemaManager::createDatabases()" error.

SQLSTATE[HY000]: General error: 1 table messenger_messages already exists

After an upgrade from symfony 4.4 to symfony 5.1 with all the doctrine dependencies, and also an remove of liip/functional-test-bundle and instead install of liip/test-fixtures-bundle

Some dependencies that have been upgraded is

doctrine/doctrine-migrations-bundle
doctrine/doctrine-fixtures-bundle
symfony/messenger

My tests began to output a lot of SQLSTATE[HY000]: General error: 1 table messenger_messages already exists all over the place.

Now for my migrations to not add messenger_messages table I have the following doctrine config

# config/packages/doctrine.yaml
doctrine:
    dbal:
        connections:
            default:
                schema_filter: ~^(?!messenger_messages)~

So to fix my table already exists I had to add the following to my doctrine test yaml file

# config/packages/test/doctrine.yaml

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                schema_filter: ~

And now my tests are running fine.

Im not actually sure this is a bug in either doctrine or liip, but just wanted to add it somewhere, so it can be googled - because I had no relevant google results coming up.

Semantical Error with PHPUnit annotations

Hi,

i try to load fixtures in my test cases but i want to tell phpunit that this test does not perform assertions because is mark it as risky.
But when i added the @doesNotPerformAssertions PHPUnit intercept AnnotationException like below.

Preconditions

  1. Symfony 5.0.1
  2. PHPUnit 8.3.5
  3. LiipTestFixturesBundle 1.6.0

Steps to reproduce

  1. Create a simple test like with two tests, one with the loadFixtures and the @doesNotFerfomAssertions comment and another with one assertion.
<?php

namespace App\Tests\Controller;

use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;
use Liip\TestFixturesBundle\Test\FixturesTrait;

class TradePostCollectionTest extends ApiTestCase
{
    use FixturesTrait;

    /**
     * @doesNotPerformAssertions
     */
    public function testInjectFixtures()
    {
        $this->loadFixtures(array(
            'App\DataFixtures\UserTestFixtures'
        ));
    }

    public function testAssert()
    {
        $this->assertEquals(0,0);
    }
}
  1. Launch tests php bin/phpunit --filter TradePostCollectionTest
  2. Check the results

Expected result

PHPUnit 8.3.5 by Sebastian Bergmann and contributors.

Testing Project Test Suite
..                                                                  2 / 2 (100%)

Time: 7.82 seconds, Memory: 32.00 MB

OK (1 tests, 1 assertions)

Actual result

PHPUnit 8.3.5 by Sebastian Bergmann and contributors.

Testing Project Test Suite
E.                                                                  2 / 2 (100%)

Time: 1.97 seconds, Memory: 26.00 MB

There was 1 error:

1) App\Tests\Controller\TradePostCollectionTest::testInjectFixtures
Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@doesNotPerformAssertions" in method App\Tests\Controller\TradePostCollectionTest::testInjectFixtures() was never imported. Did you maybe forget to add a "use"
statement for this annotation?

/var/www/symfony/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:54
/var/www/symfony/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php:732
/var/www/symfony/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php:661
/var/www/symfony/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php:354
/var/www/symfony/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php:282
/var/www/symfony/vendor/liip/test-fixtures-bundle/src/Services/DatabaseToolCollection.php:71
/var/www/symfony/vendor/liip/test-fixtures-bundle/src/Services/DatabaseToolCollection.php:61
/var/www/symfony/vendor/liip/test-fixtures-bundle/src/Test/FixturesTrait.php:83
/var/www/symfony/tests/App/Tests/Controller/TradePostCollectionTest.php:18

ERRORS!
Tests: 2, Assertions: 1, Errors: 1.

Invalid orm schema handling after migration from test bundle 1.x -> 3.x and multiple entity managers

We use postgres and manage our database schema with custom migrations, not with schema tool (schema:update)

We have two separate connections and EMs pointing (for tests for sure) to the same database (using different sets of tables)

For the 1.x branch database structure was only purged for SQLite DB driver, so we have no issues

https://github.com/liip/LiipFunctionalTestBundle/blob/45cac28b3fafeb75aebc58c4a2cf74dd1e093569/Test/WebTestCase.php#L403-L449

But after migrating to 3.x with fixtures bundle (and I confirmed 2.x had the same code) schema is updated forcibly either with drop/create or update schema tool.

https://github.com/liip/LiipFunctionalTestBundle/blob/7b4e40176c8a4fb359f28c27b1f71d33296a6aa9/src/Services/DatabaseTools/ORMDatabaseTool.php#L122-L132

// TODO: handle case when using persistent connections. Fail loudly?
$schemaTool = new SchemaTool($this->om);
if (count($this->excludedDoctrineTables) > 0 || true === $append) {
if (!empty($this->getMetadatas())) {
$schemaTool->updateSchema($this->getMetadatas());
}
} else {
$schemaTool->dropDatabase();
if (!empty($this->getMetadatas())) {
$schemaTool->createSchema($this->getMetadatas());
}
}

Since we have two EMs and two connection we got a strange situation while loading all sets of fixtures for both:

first EM drops the whole database and restores only own metadatas.
Same does the second

We result with non-consistent database setup where not all tables present, thus tests fail

Upgrade to 1.8/1.9.1 creates Kernel boot error

I have updated fixtures-bundle from 1.7 to 1.8/1.9.1. After this update the following error is shown when I run controller-tests:

LogicException : Cannot access the container on a non-booted kernel. Did you forget to boot it?
vendor/symfony/framework-bundle/Test/TestContainer.php:144
vendor/symfony/framework-bundle/Test/TestContainer.php:152
vendor/symfony/framework-bundle/Test/TestContainer.php:106
vendor/liip/test-fixtures-bundle/src/Test/FixturesTrait.php:85
tests/App/Controller/AbstractFunctionalTestCase.php:70

Preconditions

  1. SF 4.4.8
  2. LiipTestFixturesBundle 1.8

Steps to reproduce

We have implemented a AbstractFunctionalTestCase class which implements the setUp() method to do all fixtures-load stuff for our controller-tests.

The method looks like this:

public function setUp()
{
     $this->client = $this->makeAuthenticatedClient();

     $fixtures = [
         // ...
     ];

     // ...

     $this->references = $this->loadFixtures($fixtures)->getReferenceRepository();

     // ...
}

Add PHP-CS-Fixer test to GitHub Actions

Is your feature request related to a problem? Please describe.
Add PHP-CS-Fixer

Describe the solution you'd like

Something like this:

docker run -i -t --rm --volume $PWD:/app --workdir /app jakzal/phpqa:php7.4-alpine \
php-cs-fixer fix --rules=@PhpCsFixer src/ --dry-run

Describe alternatives you've considered
.

Additional context
.

Ability to load fixtures once before test class

Currently we can load fixtures:

Only the possibility to load fixtures once before test class is missing (like we do with PHPUnit setupBeforeClass()).

So, I would like to add this ability by implementing a simple flag and a $once parameter in methods like loadFixtureFiles() as follows:

public function loadFixtureFiles(array $paths = array(), $append = false, $omName = null, $registryName = 'doctrine', $once = false)

What do you think?

How to change the default fixtures directory?

The default fixtures directory is src/DataFixtures.

I want this folder in my src/tests folder.

Where I can configure the library to load the fixture from src/tests/DataFixtures?

PHP Fatal error: Uncaught Error: Class 'Liip\TestFixturesBundle\LiipTestFixturesBundle' not found

Hello, when installing vendors in the production environment i get this error:

[RuntimeException]                                                                                                                               
                                                                                                                                                     
    An error occurred when executing the "'cache:clear --no-warmup'" command:                                                                      
                                                                                                                                                     
    PHP Fatal error:  Uncaught Error: Class 'Liip\TestFixturesBundle\LiipTestFixturesBundle' not found

Preconditions

This is my composer.json file:

{
    "license": "proprietary",
    "type": "project",
    "autoload": {
        "psr-4": {
            "AppBundle\\": "src/AppBundle"
        },
        "classmap": [
            "app/AppKernel.php",
            "app/AppCache.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        },
        "files": [
            "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
        ]
    },
    "require": {
        "php": ">=5.5.9",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-fixtures-bundle": "^3.0",
        "doctrine/orm": "^2.5",
        "friendsofsymfony/rest-bundle": "^2.3",
        "greenskies/web-log-viewer-bundle": "^0.0.8",
        "incenteev/composer-parameter-handler": "^2.0",
        "jms/serializer-bundle": "^2.4",
        "kunicmarko/sonata-annotation-bundle": "^1.1",
        "nelmio/api-doc-bundle": "^3.4",
        "php-translation/symfony-bundle": "^0.8.1",
        "sensio/distribution-bundle": "^5.0.19",
        "sensio/framework-extra-bundle": "^5.0.0",
        "sonata-project/admin-bundle": "^3.35",
        "sonata-project/doctrine-orm-admin-bundle": "^3.6",
        "sonata-project/easy-extends-bundle": "^2.5",
        "sonata-project/media-bundle": "^3.13",
        "sonata-project/user-bundle": "^4.1",
        "stof/doctrine-extensions-bundle": "^1.3",
        "symfony/monolog-bundle": "^3.1.0",
        "symfony/polyfill-apcu": "^1.0",
        "symfony/swiftmailer-bundle": "^2.6.4",
        "symfony/symfony": "3.4.*",
        "twig/twig": "^1.0||^2.0"
    },
    "require-dev": {
        "johnkary/phpunit-speedtrap": "^3.1",
        "joshtronic/php-loremipsum": "^1.0",
        "liip/functional-test-bundle": "^3.0.0",
        "liip/test-fixtures-bundle": "^1.0.0",
        "phpstan/phpstan": "^0.9.2",
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^4.1"
    },
    "scripts": {
        "symfony-scripts": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-install-cmd": [
            "@symfony-scripts"
        ],
        "post-update-cmd": [
            "@symfony-scripts"
        ]
    },
    "config": {
        "sort-packages": true
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-bin-dir": "bin",
        "symfony-var-dir": "var",
        "symfony-web-dir": "web",
        "symfony-tests-dir": "tests",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": null
    }
}

And this is my AppKernel file:

<?php

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),

            // Sonata dependencies
            new Sonata\CoreBundle\SonataCoreBundle(),
            new Sonata\BlockBundle\SonataBlockBundle(),
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
            new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
            new Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle(),

            // SonataAdminBundle
            new Sonata\AdminBundle\SonataAdminBundle(),

            // SonataUserBundle
            new FOS\UserBundle\FOSUserBundle(),
            new Sonata\UserBundle\SonataUserBundle(),

            // StofDoctrineExtensionsBundle
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),

            // FOSRestBundle
            new FOS\RestBundle\FOSRestBundle(),
            new JMS\SerializerBundle\JMSSerializerBundle(),

            // SonataMediaBundle
            new Sonata\MediaBundle\SonataMediaBundle(),

            // TranslationBundle
            new Translation\Bundle\TranslationBundle(),

            // WebLogViewerBundle
            new Greenskies\WebLogViewerBundle\WebLogViewerBundle(),

            // SonataAnnotationBundle
            new KunicMarko\SonataAnnotationBundle\SonataAnnotationBundle(),

            // NelmioApiDocBundle
            new Nelmio\ApiDocBundle\NelmioApiDocBundle(),

            // DoctrineFixturesBundle
            new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),

            // LiipTestFixturesBundle
            new Liip\TestFixturesBundle\LiipTestFixturesBundle(),

            // this should always be the last bundle
            new AppBundle\AppBundle(),
        ];

        if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();

            if ('dev' === $this->getEnvironment()) {
                $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
                $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
            }

            if ('test' === $this->getEnvironment()) {
                $bundles[] = new Liip\FunctionalTestBundle\LiipFunctionalTestBundle();
            }
        }

        return $bundles;
    }

    public function getRootDir()
    {
        return __DIR__;
    }

    public function getCacheDir()
    {
        return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
    }

    public function getLogDir()
    {
        return dirname(__DIR__).'/var/logs';
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load(function (ContainerBuilder $container) {
            $container->setParameter('container.autowiring.strict_mode', true);
            $container->setParameter('container.dumper.inline_class_loader', true);

            $container->addObjectResource($this);
        });
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
    }
}

I am using Symfony 3.4 with PHP 7.2.

Thanks!

Fails to connect into mysql database when database not created

Source: liip/LiipFunctionalTestBundle#470


Hello,

This library fails to connect into mysql database when database not created with error An exception occurred in driver: SQLSTATE[HY000] [1049] Unknown database 'test'

Place where error occurs:
https://github.com/liip/LiipFunctionalTestBundle/blob/2.0.0-alpha10/src/Services/DatabaseTools/ORMDatabaseTool.php#L63 or commit to be exact fails because used dbal library performs connect https://github.com/doctrine/dbal/blob/b45ed5e13e4834f64fbc56bfdc0344430cecae63/lib/Doctrine/DBAL/Connection.php#L358 into database despite unset($params['dbname']); in your class ORMDatabaseTool in 61 line

Steps to reproduce

class MyClassTest extends \Liip\FunctionalTestBundle\Test\WebTestCase
{
    protected function setUp(): void
    {
        self::bootKernel();
        $this->loadFixtures([
            LoadEntities::class,
        ]);
        parent::setUp();
    }
}

and

"doctrine/dbal": "^2.8",
"liip/functional-test-bundle": "~2.0@alpha",

InvalidArgumentException : "App\Tests\DataFixtures\UserFixtures1" is not a registered fixture

Hi,

This is probably not a but, maybe a configuration issue or something similar.
If the fixtures are not in use App\DataFixtures directory then I get the following error message:

InvalidArgumentException : "App\Tests\DataFixtures\UserFixtures1" is not a registered fixture
 D:\Projects\espos\repos\s55-demo\vendor\doctrine\data-fixtures\lib\Doctrine\Common\DataFixtures\Loader.php:135
 D:\Projects\espos\repos\s55-demo\vendor\liip\test-fixtures-bundle\src\Services\SymfonyFixturesLoaderWrapper.php:19
 D:\Projects\espos\repos\s55-demo\vendor\liip\test-fixtures-bundle\src\Services\FixturesLoaderFactory.php:44
 D:\Projects\espos\repos\s55-demo\vendor\liip\test-fixtures-bundle\src\Services\DatabaseTools\ORMSqliteDatabaseTool.php:75
 D:\Projects\espos\repos\s55-demo\vendor\liip\test-fixtures-bundle\src\Test\FixturesTrait.php:86
 D:\Projects\espos\repos\s55-demo\tests\Controller\SomeControllerTest.php:20

Any suggestion how to register App\Tests\DataFixtures\UserFixtures1 as fixture?

Symfony 5 error during installation

Hi,
When i try to install the bundle, i get an error with symfony 5.

composer require liip/test-fixtures-bundle --dev

Problem 1

  • Conclusion: don't install liip/test-fixtures-bundle 1.9.1
  • Conclusion: remove doctrine/cache 1.10.2
  • Conclusion: don't install doctrine/cache 1.10.2
  • doctrine/common 2.2.1 conflicts with doctrine/cache[1.10.2].
  • doctrine/common 2.2.2 conflicts with doctrine/cache[1.10.2].
  • doctrine/common 2.2.3 conflicts with doctrine/cache[1.10.2].
  • doctrine/common 2.3.0 conflicts with doctrine/cache[1.10.2].
  • Conclusion: don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
  • Conclusion: don't install liip/test-fixtures-bundle 1.9.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
  • Conclusion: don't install liip/test-fixtures-bundle 1.9.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
  • Installation request for doctrine/cache (locked at 1.10.2) -> satisfiable by doctrine/cache[1.10.2].
  • Conclusion: don't install liip/test-fixtures-bundle 1.9.1|remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
  • Conclusion: don't install liip/test-fixtures-bundle 1.9.1|don't install doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
  • Installation request for liip/test-fixtures-bundle ^1.9 -> satisfiable by liip/test-fixtures-bundle[1.9.0, 1.9.1].
  • Conclusion: remove doctrine/common 3.0.2|install doctrine/common 2.2.1|install doctrine/common 2.2.2|install doctrine/common 2.2.3|install doctrine/common 2.3.0
  • liip/test-fixtures-bundle 1.9.0 requires doctrine/common ^2.0 -> satisfiable by doctrine/common[2.1.3, 2.1.4, 2.12.0, 2.13.0, 2.13.1, 2.13.2, 2.13.3, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.3.0, v2.10.0, v2.11.0, v2.4.0, v2.4.1, v2.4.2, v2.4.3, v2.5.0, v2.5.1, v2.5.2, v2.5.3, v2.6.0, v2.6.1, v2.6.2, v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.8.0, v2.8.1, v2.9.0].
  • Can only install one of: doctrine/common[2.13.0, 3.0.2].
  • Can only install one of: doctrine/common[2.13.1, 3.0.2].
  • Can only install one of: doctrine/common[2.13.2, 3.0.2].
  • Can only install one of: doctrine/common[2.13.3, 3.0.2].
  • Can only install one of: doctrine/common[2.1.3, 3.0.2].
  • Can only install one of: doctrine/common[2.1.4, 3.0.2].
  • Can only install one of: doctrine/common[2.12.0, 3.0.2].
  • Can only install one of: doctrine/common[2.2.0, 3.0.2].
  • Can only install one of: doctrine/common[v2.10.0, 3.0.2].
  • Can only install one of: doctrine/common[v2.11.0, 3.0.2].
  • Can only install one of: doctrine/common[v2.4.0, 3.0.2].
  • Can only install one of: doctrine/common[v2.4.1, 3.0.2].
  • Can only install one of: doctrine/common[v2.4.2, 3.0.2].
  • Can only install one of: doctrine/common[v2.4.3, 3.0.2].
  • Can only install one of: doctrine/common[v2.5.0, 3.0.2].
  • Can only install one of: doctrine/common[v2.5.1, 3.0.2].
  • Can only install one of: doctrine/common[v2.5.2, 3.0.2].
  • Can only install one of: doctrine/common[v2.5.3, 3.0.2].
  • Can only install one of: doctrine/common[v2.6.0, 3.0.2].
  • Can only install one of: doctrine/common[v2.6.1, 3.0.2].
  • Can only install one of: doctrine/common[v2.6.2, 3.0.2].
  • Can only install one of: doctrine/common[v2.7.0, 3.0.2].
  • Can only install one of: doctrine/common[v2.7.1, 3.0.2].
  • Can only install one of: doctrine/common[v2.7.2, 3.0.2].
  • Can only install one of: doctrine/common[v2.7.3, 3.0.2].
  • Can only install one of: doctrine/common[v2.8.0, 3.0.2].
  • Can only install one of: doctrine/common[v2.8.1, 3.0.2].
  • Can only install one of: doctrine/common[v2.9.0, 3.0.2].
  • Installation request for doctrine/common (locked at 3.0.2) -> satisfiable by doctrine/common[3.0.2].

Installation failed, reverting ./composer.json to its original content.

Any help for that ?

Thanks.

Serialized data is instead json_encoded in ProxyReferenceRepository causing tests to fail

Edit 2: In the absence of any acknowledgement of this issue I poked at it some. Discovered that the data to be unserialized in Doctrine\Common\DataFixtures\ProxyReferenceRepository was json_encode()ed instead. Changing line 74 in that class to $repositoryData = json_decode($serializedData, true); allowed the test to run & pass. It is outside of my skill set to determine where & why nominally serialized data has become json_encoded data.

On updating a project from Symfony 5.0.2 to 5.0.3, test classes that include $this->loadFixtures([...list of classes...]) fail with the error unserialize(): Error at offset 0 of 701 bytes. The stack trace shows, for example,

Edit: The issue continues with Symfony 5.0.4.

G:\Documents\workspace\cfwn\vendor\doctrine\data-fixtures\lib\Doctrine\Common\DataFixtures\ProxyReferenceRepository.php:74
G:\Documents\workspace\cfwn\vendor\doctrine\data-fixtures\lib\Doctrine\Common\DataFixtures\ProxyReferenceRepository.php:115
G:\Documents\workspace\cfwn\vendor\liip\test-fixtures-bundle\src\Services\DatabaseBackup\SqliteDatabaseBackup.php:68
G:\Documents\workspace\cfwn\vendor\liip\test-fixtures-bundle\src\Services\DatabaseTools\ORMSqliteDatabaseTool.php:52
G:\Documents\workspace\cfwn\vendor\liip\test-fixtures-bundle\src\Test\FixturesTrait.php:86
G:\Documents\workspace\cfwn\tests\Pages\SearchTest.php:27

Test classes that do not include $this->loadFixtures() do not show the error.

Example test class:

use Liip\TestFixturesBundle\Test\FixturesTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class NonprofitControllerTest extends WebTestCase
{

    use FixturesTrait;

    public function setup(): void
    {
        $this->fixtures = $this->loadFixtures([
                    'App\DataFixtures\Test\OptionsFixture',
                    'App\DataFixtures\Test\NonprofitFixture',
                ])
                ->getReferenceRepository();
        $this->client = static::createClient();
        $this->client->followRedirects();
    }
...
}

Example fixture:

use App\Entity\Focus;
use App\Entity\Skill;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Bundle\FixturesBundle\ORMFixtureInterface;

/**
 * Loads focus & skill data.
 */
class OptionsFixture extends AbstractFixture implements OrderedFixtureInterface, ORMFixtureInterface
{
    /**
     * Load fixtures.
     *
     * @param \Doctrine\Common\Persistence\ObjectManager $manager
     */
    public function load(ObjectManager $manager)
    {
        $manager->clear();
        gc_collect_cycles(); // Could be useful if you have a lot of fixtures

        $focusSeniors = new Focus();
        $focusSeniors->setFocus('Seniors');
        $focusSeniors->setEnabled(true);
        $manager->persist($focusSeniors);
        $this->setReference('focus_seniors', $focusSeniors);

        $focusEducation = new Focus();
        $focusEducation->setFocus('Education');
        $focusEducation->setEnabled(true);
        $manager->persist($focusEducation);
        $this->setReference('focus_ed', $focusEducation);

        $focusHealth = new Focus();
        $focusHealth->setFocus('Health');
        $focusHealth->setEnabled(true);
        $manager->persist($focusHealth);
        $this->setReference('focus_health', $focusHealth);

        $skillAdministrative = new Skill();
        $skillAdministrative->setSkill('Administrative Support');
        $skillAdministrative->setEnabled(true);
        $manager->persist($skillAdministrative);
        $this->setReference('skill_admin', $skillAdministrative);

        $skillBoard = new Skill();
        $skillBoard->setSkill('Board Member');
        $skillBoard->setEnabled(true);
        $manager->persist($skillBoard);
        $this->setReference('skill_board', $skillBoard);

        $skillComputers = new Skill();
        $skillComputers->setSkill('Computers & IT');
        $skillComputers->setEnabled(true);
        $manager->persist($skillComputers);
        $this->setReference('skill_computers', $skillComputers);

        $manager->flush();
    }

    public function getOrder()
    {
        return 1; // the order in which fixtures will be loaded
    }
}

The kernel should only be booted once

Preconditions

  1. On a Symfony 5.3 app
  2. Using ^2.0.0-alpha4
  3. Following these docs: https://github.com/liip/LiipTestFixturesBundle/blob/2.0.0-alpha4/doc/database.md

Steps to reproduce

I updated one of my tests with these lines:

protected function setUp(): void {
    parent::setUp();
    $this->databaseTool = static::getContainer()->get(DatabaseToolCollection::class)->get(null, 'doctrine_mongodb');
}

And:

public function testSetup(): void {
    $client = static::createApiClient(); // This is basically `WebTestCase::createClient` with default values

    $this->databaseTool->loadAllFixtures(['tests']);

    $client->xmlHttpRequest('POST', '/api/setup');
    $this->assertResponseIsSuccessful();
}

Expected result

I would expect this test to run.

Actual result

I get the following error:

1) App\Tests\Controller\SetupTest::testSetup
LogicException: Booting the kernel before calling "Symfony\Bundle\FrameworkBundle\Test\WebTestCase::createClient()" is not supported, the kernel should only be booted once.

/app/vendor/symfony/framework-bundle/Test/WebTestCase.php:43
/app/tests/Controller/ApiTestCase.php:18
/app/tests/Controller/SetupTest.php:18

When only commenting the $this->databaseTool->loadAllFixtures(['tests']); line I get the same error. When also commenting the $this->databaseTool = (...) one, the test runs normally (but of course no fixture is called).

Did I get something wrong?
Thanks!

Is doctrine/doctrine-fixtures-bundle required when using theofidry/alice-data-fixtures?

Hi all,

I just installed and tried the new v2.0-alpha8 and got a question related to the doctrine/doctrine-fixtures-bundle dependency requirement.
Indeed when I'm using the theofidry/alice-data-fixtures it seems that it needs also the doctrine/doctrine-fixtures-bundle package which seems not really necessary as I think both bundles are doing the same thing.

From what I understand I can see that the requirement check is done when the loadAliceFixture calls the cleanDatabase method.
So my question is : Do we really need both bundles?
Thanks !

Configurable cached fixtures directory

Is your feature request related to a problem? Please describe.
We've switched from custom implementation to this library to leverage fixtures caching (thanks for extraction from liip/LiipFunctionalTestBundle!). Also we use paratest to speed up our sqlite tests execution. To guarantee that the used database is different for each thread, we use TEST_TOKEN provided by paratest and connection factory similar to the one provided in https://github.com/liip/LiipTestFixturesBundle/blob/2.x/src/Factory/ConnectionFactory.php (btw it looks broken now as getDbNameFromEnv is not used)

Unfortunately, we still end up in concurrency problems but in fixtures backup usage, being it loading or restoring from fixtures. In our custom implementation we solved it with similar to connection factory - use different folders for different threads. It's possible to maintain this behavior by overwriting service definition of \Liip\TestFixturesBundle\Services\DatabaseBackup\SqliteDatabaseBackup but will appreciate if configurability of cache folder makes it to upstream

Describe the solution you'd like
\Liip\TestFixturesBundle\Services\DatabaseBackup\SqliteDatabaseBackup::getBackupFilePath cache folder (for other providers it's the same) should be configurable and instead of using $this->container->getParameter('kernel.cache_dir') allow configuration to come from bundle configuration.

For backwards-compatibility this parameter can be %kernel.cache_dir% by default.

Describe alternatives you've considered
Alternatives are to keep overwritten service definition on our side, but it's prone to future breaking changes.

Additional context
I've tried to add more configuration to liip_test_fixtures.cache_db but it accepts only service id, so I don't see clear non-breaking change here. Looking for alternatives and up to implement it f it satisfies both maintainers and my use case.

[Doc] Schema creation with doctrine/orm < or > 2.6

Hi,

The doc for 2.x states:

The Bundle will not automatically create your schema for you unless you use SQLite or use doctrine/orm < 2.6.

But a few lines later, the option to resolve it is: composer require doctrine/orm:^2.6

So this should be "The bundle will not automatically create your schema for you unless you use SQLite or doctrine/orm >= 2.6" ?

[2.x] Remove FixturesTrait

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like

  • get rid of getContainer
  • show proper examples to boot a kernel before using the fixtures service.

Describe alternatives you've considered

Additional context

See #26

Caching mysql database with its data

While running all my e2e tests, the bundle caches the test database and restores it when it passes to another test. But it does not backup only the database schema, it also backup the test data. So when PHPUnit passes to another test, the database initializes with the previous tests' data. And occurs unexpected results.

Preconditions

Package versions

"liip/functional-test-bundle": "4.2.0",
"liip/test-fixtures-bundle": "1.9.1",
"doctrine/doctrine-bundle": "1.12.10",
"doctrine/common": "2.13.3",
"doctrine/dbal": "2.10.4",
"doctrine/orm": "2.7.4"

Steps to reproduce

My config

liip_functional_test: ~
liip_test_fixtures:
  cache_db:
    mysql: liip_test_fixtures.services_database_backup.mysql

My test case

class E2eTestCase extends TestCase
{
    use FixturesTrait;

    protected function setUp(): void
    {
        parent::setUp();
        $this->loadFixtures();
    }

    // ...
}

Expected result

I would expect the bundle to backup only database schema, not test data. How can I achieve this?

post and preFixtures or Reference returning self make it hard to use

Preconditions

Using this bundle 1.0 with FunctionalTestBundle 3.0

Steps to reproduce

I've added the trait to a BaseWebTestCase defined in my project (that allows to create client crafter for my needs).

Expected result

Due to the return self type hint, I cannot override the preReferenceSave (or postReferenceSave in a class extending by BaseWebTestCase.

Actual result

The result of this method is never used, so they can be declared as void.

#32 breaks postgres database fixtures loading

On 1.1.1 #32 when doing loadFixtures I get

Doctrine\DBAL\Exception\DriverException : An exception occurred while executing 'SET FOREIGN_KEY_CHECKS = 0;':

SQLSTATE[42704]: Undefined object: 7 ERROR:  unrecognized configuration parameter "foreign_key_checks"
 /data/www/payment-service/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php:79
 /data/www/payment-service/vendor/dama/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticDriver.php:98
 /data/www/payment-service/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:169
 /data/www/payment-service/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:145
 /data/www/payment-service/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:1063
 /data/www/payment-service/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMDatabaseTool.php:148
 /data/www/payment-service/vendor/liip/test-fixtures-bundle/src/Test/FixturesTrait.php:87
 /data/www/payment-service/tests/AppBundle/ApplicationAvailabilityFunctionalTest.php:78

I hope SET FOREIGN_KEY_CHECKS = 0 is only supported by MySQL and this should be checked there.

cc. @alexislefebvre

[RFC] Post Fixtures Database restore

Is your feature request related to a problem? Please describe.
I'd like to load some redis data that are related to fixtures.
I need the reference repository because the redis keys depends on the ID that are loaded.

When using the sqlite backup, the code of the fixtures is not loaded, so I cannot load my redis data.

Describe the solution you'd like

  1. Maybe having a postRestore method in each fixtures (with a TestFixturesBundle interface) that is called after restoring a backup?
  2. Maybe having an event when each fixture file is loaded?

I think I prefer the 1.

Describe alternatives you've considered
Sort of related to #21, I wanted to use the postFixtureBackupRestore method, but it only provides the backupFilePath (whereas the preFixtureBackupRestore provides the object manager & the reference repository).
So maybe I can do something if the referenceRepository is provided in the postFixturesBackupRestore call.

The table with name 'X ' already exists.

Hello,
I tried to use bundle but it give this error: The table with name 'X ' already exists.

Doctrine config

doctrine:
dbal:
driver: pdo_sqlite
path: "%kernel.cache_dir%/test.db"
url: null

I load fixture in each test.

Fatal Error with Symfony 5.3

When testing with Symfony 5.3, getting the below fatal error:

Fatal error: Cannot make static method Symfony\Bundle\FrameworkBundle\Test\KernelTestCase::getContainer() non static in class Liip\TestFixturesBundle\Test\FixturesTrait

Realizing the trait is removed (and inherently the issue addressed) on the 2.x branch after #26, this is still a blocker for apps trying to upgrade beyond Symfony 5.2 without either a patch for 1.x or 2.0 being released.

Specifying an entity manager when using the loadFixtures method

Is your feature request related to a problem? Please describe.
Hi team, I have two different bundles in my app and each one has their own entity manager. I am writing an integration test for a service in one of the bundles, but I need to load a fixture class from the second bundle. Is this currently possible?

Describe alternatives you've considered
I tried passing in the name of the entity manager for the fixture I'd like to load, in the $omName parameter of the loadFixtures method unsuccessfully. This was the main exception I kept getting:

InvalidArgumentException: Doctrine ORM Manager named "shared" does not exist.

I also tried different variations of the entity manager name but same outcome, eg:
"shared", "doctrine.orm.shared_entity_manager" and "shared_entity_manager":

Additional context
Here is part of my doctrine orm config with the two entity managers for more context:

orm:
    default_entity_manager: default
    auto_generate_proxy_classes: '%kernel.debug%'
    entity_managers:
        default:
            connection: client_database
            auto_mapping: true
        shared:
            connection: shared_database
            mappings:
                AdminBundle:
                    type: annotation
                    dir: '%kernel.project_dir%/src/AdminBundle/Entity'
                    prefix: AdminBundle\Entity

Thanks,
-Aleks

AnnotationException : "@covers" was never imported

If @Covers annotation is being used in a test function, then the following exception is being thrown:

Doctrine\Common\Annotations\AnnotationException : [Semantical Error] The annotation "@covers" in method App\Tests\Controller\SomeControllerTest::testSomeAction() was never imported. Did you maybe forget to add a "use" statement for this annotation?

Steps to reproduce

  1. Create a use-case which uses the FixturesTrait
  2. Run the test. Should be successful.
  3. In the test function comment use the @Covers annotation
  4. Run again. Exception is being displayed

<?php

namespace App\Tests\Controller;

use App\DataFixtures\UserFixtures;
use App\Model\SomeActions;
use Liip\TestFixturesBundle\Test\FixturesTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class SomeControllerTest extends WebTestCase
{

    use FixturesTrait;

    /**
     * @covers \App\Controller\SomeController::someAction
     */
    public function testSomeAction()
    {

        $this->loadFixtures([
            UserFixtures::class
        ]);

        $client = static::createClient();
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

Testing App\Tests\Controller\SomeControllerTest

Doctrine\Common\Annotations\AnnotationException : [Semantical Error] The annotation "@covers" in method App\Tests\Controller\SomeControllerTest::testSomeAction() was never imported. Did you maybe forget to add a "use" statement for this annotation?
 D:\Projects\espos\repos\s55-demo\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\AnnotationException.php:54
 D:\Projects\espos\repos\s55-demo\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\DocParser.php:732
 D:\Projects\espos\repos\s55-demo\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\DocParser.php:661
 D:\Projects\espos\repos\s55-demo\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\DocParser.php:354
 D:\Projects\espos\repos\s55-demo\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\AnnotationReader.php:282
 D:\Projects\espos\repos\s55-demo\vendor\liip\test-fixtures-bundle\src\Services\DatabaseToolCollection.php:71
 D:\Projects\espos\repos\s55-demo\vendor\liip\test-fixtures-bundle\src\Services\DatabaseToolCollection.php:61
 D:\Projects\espos\repos\s55-demo\vendor\liip\test-fixtures-bundle\src\Test\FixturesTrait.php:83
 D:\Projects\espos\repos\s55-demo\tests\Controller\SomeControllerTest.php:23
 

Screenshot_14

Upgrade doctrine/common to 3.0

doctrine/common, a dependency of this project, went out in late May in version 3.0. Would an upgrade create regressions or is it an easy thing to do?

Upgrading the dependency would be helpful since a lot of Doctrine and Symfony-related projects can use both doctrine/common 2.0 and 3.0 but the fact that liip/LiipTestFixturesBundle only supports version 2.0 prevents them from using the latest version.

Disabling / Enabling foreign key checks does not respect previous settings

If disabling of the foreign key checks was made in userland's code before calling loadFixtureFiles() the purging routine of the library enables it which leads to unexpected SQL errors.

Preconditions

  1. suppose to have fixtures defined in YAML files which require disabled foreign key checks for loading.

Steps to reproduce

  1. in your test disable foreign key checks before fixture loading.
  2. call loadFixtureFiles() with $append = false (default)
  3. Fixture cannot be loaded due to foreign key constraints - the foreign key checks is enabled just right after purging.

Expected result

  1. foreign key checks should be disabled

Actual result

  1. foreign key checks is enabled

Fix proposal: #41

Disabling/Enabling foreign key checks in Sqlite

Problem
We manually enable foreign key checks on Sqlite for tests, which causes problems when loading fixtures because the foreign key checks are not disabled when purging the database as they are with MyQL.

More details
By default, Sqlite has foreign key checks disabled and must be enabled at runtime if you want to enforce foreign key constraints. If you run MySQL in production and Sqlite in tests, you very likely want foreign key checks enabled, otherwise you will likely get errors in production which cannot be reproduced in tests.

We enable foreign key checks in a Symfony event listener shown in this stackoverflow question, which works great and has enabled us to catch quite a few issues in test before they make it to production.

Looking at ORMDatabaseTool::cleanDatabase() we can see that foreign key checks are disabled before purging and enabled again afterwards, however this only happens for MySQL databases. As such, when our Sqlite database is purged in test, foreign key checks are still enabled and it causes an exception.

Solution
I'd like the ORMSqliteDatabaseTool to support disabling and enabling foreign key checks if you have them enabled in the first place.

From the Sqlite docs, we can use the following queries:

  • Check if foreign key checks are enabled: PRAGMA foreign_keys
  • Enable foreign key checks: PRAGMA foreign_keys = 1
  • Disable foreign key checks: PRAGMA foreign_keys = 0

Alternatives I've considered
I've tried to implement this myself, both in LiipTestFixtures and in my own codebase by overriding the ORMSqliteDatabaseTool in the container but in both instances it's a lot harder than it needs to be, because the logic around enabling/disabling the checks in not extensible as a result of being declared private.

Proposal
This issue is an RFC for the best way to implement this feature. My proposal is:

  • Change disableForeignKeyChecksIfApplicable and enableForeignKeyChecksIfApplicable to protected instead of private
  • Override these methods in ORMSqliteDatabaseTool to implement Sqlite specific functionality

Add tests of MongoDB

Is your feature request related to a problem? Please describe.
The loading of MongoDB fixtures is not tested: #128 (comment)

Describe the solution you'd like
Add tests of MongoDB

Describe alternatives you've considered
.

Additional context
.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.