• Installing Composer on Ubuntu 16.04 LTS
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
  • Installing PHPUnittest
{   
    "require-dev": {
        "phpunit/phpunit": "^7"
    }
}
  • Installing xdebug on Ubuntu 16.04 LTS

  • Run the tests

./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/EmailTest.php 
  • Run the code coverage
./vendor/bin/phpunit  --coverage-html . tests/EmailTest.php 
  • Setting phpunit.xml file I created the phpunit.xml file in the root directory of the project:
find -not -path './vendor/*'

Result:

./tests/EmailTest.php
./test.php
./composer.json
./composer.lock
./vendor
./src
./src/Email.php
./phpunit.xml

This is its content:

<?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>

Billal Begueradj

Information Security, Pentesting, Software Development.