Getting started with PHPUnit testing. In this post, Jyothi of Valuebound has talked about the basics of PHPUnit as well as the ways you can write Unit test cases.
2. ❖ Types of Testing
❖ Why to write unit tests
❖ Introduction to PHPUnit
❖ Demo
Agenda
3. Types of Testing
1) Unit Testing
Testing the unit of code isolated from its
dependencies.
1) Functional Testing
Functional testing's goal is to exercise a medium-sized
object graph, without instantiating the whole
application, to a cover a full functionality and make
sure the classes adhere to the same contract.
4. Types of Testing
3) Integration Testing
It combines units of codes and tests the
combination works correctly.
4) Acceptance Testing
Acceptance tests are end-to-end tests, they
work on the end result of your work.
5. Why to write unit tests ?
● Higher quality
● More flexibility
● Faster time-to-market
6. Introduction to PHPUnit
Installation:
The easiest way to obtain PHPUnit is to download a PHP Archive (PHAR)
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
phpunit --version
With Composer
composer require --dev phpunit/phpunit