Search code examples
phpsqlitephpunittypo3functional-testing

How can I use SQLite for PHPUnit Functional Testing in TYPO3 9LTS


Since TYPO3 9.4 [1] there is support for SQLite in TYPO3, This is recommended for small websites, development environments or testing.

But I don't know how to use this in testing context, the MySQL I've used for ages like this TYPO3_PATH_WEB=$PWD/.Build/Web typo3DatabaseName=database typo3DatabaseHost=localhost typo3DatabaseUsername=root typo3DatabasePassword=root .Build/bin/phpunit -c config.xml Tests/Functional

I'm looking into this option with the hope of being able to speed up my functional testing, which I currently finds to slow.

1) https://docs.typo3.org/typo3cms/extensions/core/Changelog/9.4/Feature-85256-InstallTYPO3OnSQLite.html


Solution

  • You need sqlite on the server or in the docker container where you run your tests and then simply set

    typo3DatabaseDriver=pdo_sqlite
    

    as environment variable in front of your command. That's sufficient to run your tests with sqlite.

    I've written an article where I cover this too.