Open lsv opened 3 years ago
You can use that setting to disable the automatic creation of tables:
liip_test_fixtures:
keep_database_and_schema: true
I actually thinks this is the reason. https://github.com/symfony/symfony/pull/40336
Ill try and test it at a later point.
@lsv Did the fix in Symfony solved your problem?
@alexislefebvre I have same problem if I use automatic creation of tables.
@kolotov I don't have any other solution right one than using keep_database_and_schema: true
.
Here's my research into this.
I have a set of tests, the first test runs fine, and then the next test blows up trying to create messenger_messages, which already exists.
ORMSqliteDatabaseTool - lines 92-94 - dropDatabase and createSchema are not symmetrical (createSchema has a "create table messenger_messages", but dropDatabase doesn't have a corresponding drop table line)
Looks like these SchemaSubscribers were added to symfony/doctrine-bridge in 5.1 (SchemaListener directory appears at 5.1) https://github.com/symfony/doctrine-bridge/tree/4.4 https://github.com/symfony/doctrine-bridge/tree/5.1
Not much I can do to workaround - this is caused by code in symfony/doctrine-bridge, and behaviour could be adjusted if I could hook into SchemaTool, but that's in doctrine/orm.
I'm going to have to do the whole keep_databases_and_schema thing, right? :/
@WubbleWobble thanks for the detailed report!
Calling setExcludedDoctrineTables(['messenger_messages'])
may help here, please see the doc: https://github.com/liip/LiipTestFixturesBundle/blob/2.x/doc/database.md#exclude-some-tables-
Update: actually it looks like it's only used when purging the tables, it may not help here.
@alexislefebvre Thanks - I found that method, but as you say - it didn't actually help :)
I would open a bug report with doctrine and/or symfony, but honestly I'm quite confused by many aspects of it, and where the "blame" (for lack of a better word) lies. It's going to take some more investigation I think!
I ended up using keep_databases_and_schema: true, and used a phpunit bootstrap file to run the various Symfony console commands needed to set up the test database.
You can use that setting to disable the automatic creation of tables:
liip_test_fixtures: keep_database_and_schema: true
Sorry but I'm not sure where should I put this yaml configuration - should I create a new file config/packages/liip.yaml? Because I don't see any yaml regarding liip configuration under config/packages.
@Ceriusz yes, there is an example of path here: https://github.com/liip/LiipTestFixturesBundle/blob/2.x/doc/configuration.md
Hello,
I have the same problem.
As a workaround, I deleted the global transport configuration and added it only to the dev and prod environments.
For testing I used test://.
example
## Configuration messenger
## Commun environment configuration
framework:
messenger:
routing:
'App\Message\AsyncMessageInterface': async
buses:
command_bus:
middleware:
- router_context
transports:
async:
options:
queue_name: aqueuename
# prod environment
when@prod:
framework:
messenger:
transports:
async: 'doctrine://default'
# Test environment
when@test:
framework:
messenger:
transports:
async: 'test://'
I hope this can help someone.
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 ofliip/test-fixtures-bundle
Some dependencies that have been upgraded is
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 configSo to fix my
table already exists
I had to add the following to my doctrine test yaml fileAnd 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.