Skip to content

Instantly share code, notes, and snippets.

@AndrewSavetchuk
Last active August 27, 2024 03:20
Show Gist options
  • Save AndrewSavetchuk/a850d54ed911025375c384274dccc9dd to your computer and use it in GitHub Desktop.
Save AndrewSavetchuk/a850d54ed911025375c384274dccc9dd to your computer and use it in GitHub Desktop.
PHPUnit

PHPUnit Settings for Laravel

<?xml version="1.0" encoding="UTF-8"?>
<phpunit
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
  bootstrap="vendor/autoload.php"
  colors="true"
>
  <testsuites>
    <testsuite name="Unit">
      <directory>tests/Unit</directory>
    </testsuite>
    <testsuite name="Feature">
      <directory>tests/Feature</directory>
    </testsuite>
  </testsuites>
  <php>
    <env name="APP_ENV" value="testing"/>
    <env name="APP_MAINTENANCE_DRIVER" value="file"/>
    <env name="BCRYPT_ROUNDS" value="4"/>
    <env name="CACHE_DRIVER" value="array"/>
    <env name="DB_CONNECTION" value="mysql_testing"/>
    <env name="DB_DATABASE" value=":memory:"/>
    <env name="MAIL_MAILER" value="array"/>
    <env name="PULSE_ENABLED" value="false"/>
    <env name="QUEUE_CONNECTION" value="sync"/>
    <env name="SESSION_DRIVER" value="array"/>
    <env name="TELESCOPE_ENABLED" value="false"/>
  </php>
</phpunit>

Run PHPUnit for Laravel With Coverage Report

php artisan test --coverage-html --coverage-report
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment