-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixture refs and sqlite caching #19
Comments
Cannot confirm as I'm using sqlite cache & reference extensively. Maybe you can share more code? |
Not much code to share. So I'm using standard doctrine fixtures for a symfony app, set some references in there(I'm using value objects and custom doctrine types if relevant) call ->persist() and then ->setReference(...) Then in my tests, I have a base class web test case extending use FixturesTrait;
/** @var KernelBrowser */
protected $client;
/** @var ReferenceRepository */
protected static $fixtures;
public static function setUpBeforeClass()
{
static::$fixtures = null;
}
public function setUp()
{
$this->client = $this->makeClient();
// we load fixtures once per test suite so data is kept between tests
// might as well work with `@depends` annotations
if (!static::$fixtures) {
static::$fixtures = $this->loadFixtures([TestFixtures::class])
->getReferenceRepository();
}
} I keep fxtures static there and try to instantiate it only once for each test case. Pretty much else is standard functional tests. The doctrine test config is doctrine:
dbal:
driver: 'pdo_sqlite'
path: '%kernel.cache_dir%/test.db'
charset: utf8 Tests run fine as long as I use it without db cache, but once I add this to the config liip_functional_test: ~
liip_test_fixtures:
cache_db:
sqlite: liip_test_fixtures.services_database_backup.sqlite it will crash subsequent tests. I can see some files created in the cache directory(test_sqlite_somehash.db and .db.ser) The error is as described above and it happens on this line |
Please share the exception name. You only pasted the stack trace. Anyway, if you use the cache you don't need to load the fixtures only once. So, try to load fixtures in |
Same happens to me. Stack trace:
|
I use postgreSql with id as UuidType, and those id's are being somehow lost on backup and restore of cache. When I load the fixtures with
This indicates that there might be some problem wtith id's during backup and restore of sqlite files or serialization. |
Thanks for the information. The problem with uuid was also reported in liip/LiipFunctionalTestBundle#422 (comment) We need to add a test with fixtures that use uuid. |
I also get this error when testing fixtures who have a composite primary key (multiple fields combined are the primary key).
|
@alexislefebvre thank you for the answer! I will check tomorrow if this solves my problem. |
@alexislefebvre Unfortunately changing Uuid generation to auto and setting proper metadata doesn't work at all. I still get the exception "array to string conversion" |
Also when I try to implement my own Backup with |
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.
The text was updated successfully, but these errors were encountered: