Posts

Showing posts with the label PHPUnit

Ten Second Guide to PHPUnit

Installing PHPUnit Downloading Directly $ wget https://phar.phpunit.de/phpunit-6.5.phar $ chmod +x phpunit-6.5.phar $ sudo mv phpunit-6.5.phar /usr/local/bin/ $ sudo ln -s /usr/local/bin/phpunit-6.5.phar /usr/local/bin/phpunit $ phpunit --version PHPUnit 6.5.14 by Sebastian Bergmann and contributors. Using Composer $ composer require --dev phpunit/phpunit ^6.5 $ vendor/phpunit/phpunit/phpunit --version Create Tests To test, in this example, the Calendar class, create a CalendarTest class with at least one function with a name starting with ‘ test ’: <?php require "Calendar.php"; use PHPUnit\Framework\TestCase; class CalendarTest extends TestCase {    // Tests must be written in a public functions with a name starting with test    public function testDayOfWeek() {                  $c = Calendar::parse("2019-10-01");         $c->setWeekdayInMonth( Calendar::THURSDAY, 3); ...