I followed the points of the site Testing Symfony applications using a one-time database . I added Fixtures to my test folder and no errors appear during SetUp. If I add an error to Fixtures (for example, leaving the nullable = false field blank), an error message will appear, so this code will definitely be executed.
My configuration:
doctrine: dbal: default_connection: memory connections: memory: driver: pdo_sqlite memory: true charset: UTF8
My SetUp in my WebTestCase:
protected function setUp() { parent::setUp(); self::bootKernel(); DatabasePrimer::prime(self::$kernel); $this->loadFixtures([ 'AppBundle\DataFixtures\ORM\UserData', 'AppBundle\DataFixtures\ORM\ArtistData' ]); }
However, in my WebTestCase it seems that there are no tables. The result throws a Doctrine exception because my table does not exist.
SQLSTATE[HY000]: General error: 1 no such table: my_user_table
If I switch to sql_lite in the file, everything will work fine without any changes:
dbal: default_connection: file connections: file: driver: pdo_sqlite path: %kernel.cache_dir%/test.db charset: UTF8
Has anyone been successful in this tutorial or used db sqlite memory for unit tests and had any hints or ideas?
Update: I changed my installation to this to ensure that the kernel will not be closed between them. It did not help:
parent::setUp(); $this->client = $this->getClient(); MemoryDbPrimer::prime(self::$kernel); $this->loadFixtures([ 'AppBundle\DataFixtures\ORM\UserData', 'AppBundle\DataFixtures\ORM\ArtistData' ]);
sqlite symfony phpunit doctrine functional-testing
Andresch serj
source share