Reputation: 5172
I have a Laravel project.
I want test it on my develop machine + Travis/Scrutinizer with SQLite, plus I want test on another machine with MySQL.
This is my PHPUnit file that works like a charme
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<logging>
<!-- and this is where your report will be written -->
<log type="coverage-clover" target="./logs/clover.xml"/>
</logging>
<php>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="MAIL_DRIVER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
</php>
</phpunit>
I'm asking: is there a possibility to launch on a linux shell command a similar command (pseudocode, of course):
./vendor/bin/phpunit --db_connection=mysql
?
Upvotes: 1
Views: 355
Reputation: 8719
It is not possible to edit the phpunit.xml
file dynamically from the command line by default, but you can set the DB_CONNECTION
environment variable (and other variables) like this:
DB_CONNECTION=mysql ./vendor/bin/phpunit
You can view more options for setting environment variables in this answer.
Upvotes: 1