Begueradj   Archives  About

PHP Unit Testing

These are the steps to install and set the necessary tools to run unit tests in PHP projects:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
{   
    "require-dev": {
        "phpunit/phpunit": "^7"
    }
}
./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/EmailTest.php 
./vendor/bin/phpunit  --coverage-html . tests/EmailTest.php 
find -not -path './vendor/*'
./tests/EmailTest.php
./test.php
./composer.json
./composer.lock
./vendor
./src
./src/Email.php
./phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php">
    <testsuites>
        <testsuite name='begueradj'>
            <directory>./tests/</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist>
            <directory suffix=".php">./src/</directory>
        </whitelist>
    </filter>
</phpunit>

Written on Aug 20, 2018.