sebastianbergmann / dbunit

DbUnit port for PHP/PHPUnit.
https://phpunit.de/
Other
225 stars 186 forks source link

DBUnit with MsSQL #190

Closed chucky2305 closed 6 years ago

chucky2305 commented 7 years ago

I have a makefile that looks like this:

# Makefile
CONSOLE=bin/console
resetSchemaTest:
        php $(CONSOLE) doctrine:database:drop --if-exists --env=test --force
        php $(CONSOLE) doctrine:database:create --env=test
        php $(CONSOLE) doctrine:schema:create --env=test

runTests: resetSchemaTest
        php phpunit

My database is MsSQL. I have even tried to modify vendor/phpunit/dbunit/src/Operation/Truncate.php to execute $connection->getConnection()->query("EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'");

Before doing the TRUNCATE TABLE mytable.

But i still get the following error:

PHPUnit\DbUnit\Operation\Exception: COMPOSITE[TRUNCATE] operation failed on query:
                TRUNCATE TABLE mytable
             using args: Array
(
)
 [SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Die salutation-Tabelle kann nicht abgeschnitten werden, da eine FOREIGN KEY-Einschränkung auf sie verweist.]

Kind regards, Max

ScreamingDev commented 7 years ago

Documentation says:

PHPUnit will execute a TRUNCATE against all the tables you specified to reset their status to empty.

Now let's find out where to specify them. If you specify to drop none then you're good for now. Because your test drops them already.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had activity within the last 60 days. It will be closed after 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 6 years ago

This issue has been automatically closed because it has not had activity since it was marked as stale. Thank you for your contributions.