Comments (10)
Cannot confirm as I'm using sqlite cache & reference extensively.
Maybe you can share more code?
from liiptestfixturesbundle.
I also get this error when testing fixtures who have a composite primary key (multiple fields combined are the primary key).
/** @Entity */
class OrderItem {
/** @Id @ManyToOne(targetEntity="Order") */
private $order;
/** @Id @ManyToOne(targetEntity="Product") */
private $product;
/** @Column(type="integer") */
private $amount = 1;
/** @Column(type="decimal") */
private $offeredPrice;
public function __construct(Order $order, Product $product, $amount = 1) {
$this->order = $order;
$this->product = $product;
$this->offeredPrice = $product->getCurrentPrice();
}
}
from liiptestfixturesbundle.
@alexislefebvre thank you for the answer! I will check tomorrow if this solves my problem.
from liiptestfixturesbundle.
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 Liip\FunctionalTestBundle\Test\WebTestCase
with the following setup(taken from the class)
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
static::$fixtures = $this->loadFixtures([TestFixtures::class])
, and by the looks of it, only when trying to recreate it from the cached db files
from liiptestfixturesbundle.
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 setUp
and tell us if the error is still present.
from liiptestfixturesbundle.
Same happens to me. Stack trace:
Array to string conversion
/var/www/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:3036
/var/www/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:491
/var/www/symfony/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/ProxyReferenceRepository.php:78
/var/www/symfony/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/ProxyReferenceRepository.php:105
/var/www/symfony/vendor/liip/test-fixtures-bundle/src/Services/DatabaseBackup/SqliteDatabaseBackup.php:68
/var/www/symfony/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php:52
/var/www/symfony/vendor/liip/test-fixtures-bundle/src/Test/FixturesTrait.php:87
from liiptestfixturesbundle.
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 doctrine:fixtures:load --env=test
where i have the sqlite driver configred it generates proper Uuid id's in the sqlite database file. When I debug the test exception with xdebug, I can see that in Doctrine\Common\DataFixtures\ProxyReferenceRepository::unserialize()
the variable $serializedData
comes with such values:
{"references":{"breakfast":["App\\Recipe\\Domain\\Entity\\Category",{"id":{}}],"main course":["App\\Recipe\\Domain\\Entity\\Category",{"id":{}}],"snack":["App\\Recipe\\Domain\\Entity\\Category",{"id":{}}],"ingredient_0":["App\\Recipe\\Domain\\Entity\\Ingredient",{"id":{}}],"ingredient_1":
This indicates that there might be some problem wtith id's during backup and restore of sqlite files or serialization.
from liiptestfixturesbundle.
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.
from liiptestfixturesbundle.
@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"
from liiptestfixturesbundle.
Also when I try to implement my own Backup with \Liip\TestFixturesBundle\Services\DatabaseBackup\DatabaseBackupInterface
and connect it according to docs, the library still doesn't use it. Completely nothing happens there as it falled back to default.
from liiptestfixturesbundle.
Related Issues (20)
- Split tests on CI
- Error: Call to undefined method ClassMetadataFactory#getCacheDriver HOT 2
- Use issue form
- Excessive memory consuption due to DatabaseToolCollection service HOT 3
- PDOException: There is no active transaction HOT 8
- API Stability HOT 2
- Schema public cannot be recreated HOT 5
- [question] Using one database state for all tests HOT 4
- Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it. HOT 4
- UserPasswordHasherInterface injection in fixtures HOT 10
- [Bug]: Nonexistant service for DB backup does not fail HOT 1
- chore: improve ci for symfony 4.4 HOT 1
- [Feature Request]: Add support of Behat
- [Bug]: Multiple entity managers per connection OR entity manager name does not match connection name HOT 5
- Drop support of PHP 7.2 and 7.3? HOT 1
- [Bug]: keep_database_and_schema config is ignored it is always false with SQL Server HOT 2
- facing issue in new pimcore version 10.6 HOT 5
- [Feature Request]: Add LoadFixtureGroup method HOT 2
- Deprecated DBAL APIs still in use HOT 1
- Question: cached database with GitLab CI pipeline HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liiptestfixturesbundle.