What is PHPUnit?
4 min read Quiz at the end
Introduction to PHPUnit: the standard PHP testing framework for unit, integration, and TDD.
What is PHPUnit? PHPUnit is the standard testing framework for PHP. It enables Test-Driven Development (TDD), unit testing, integration testing, and mock-based testing.
Automatic test discovery Rich assertion library Mock objects and stubs Code coverage reports Data providers for parametric tests composer require --dev phpunit/phpunit
./vendor/bin/phpunit --version
./vendor/bin/phpunit tests/
Topic Quiz · 4 questions
Test your understanding before moving on
1. Which command installs PHPUnit?
A. npm install phpunit
B. composer require phpunit/phpunit
C. apt install phpunit
D. pip install phpunit
💡 PHPUnit is installed via Composer: composer require --dev phpunit/phpunit.
2. Test methods must start with what?
A. test_
B. Test
C. test
D. PHPTest
💡 PHPUnit discovers test methods by finding public methods starting with test.
3. What class do PHPUnit test classes extend?
A. TestCase
B. PHPUnitTest
C. UnitTestCase
D. BaseTest
💡 All PHPUnit test classes must extend PHPUnitFrameworkTestCase.
4. What does TDD stand for?
A. Test Driven Data
B. Type Definition Document
C. Test Driven Development
D. Total Development Design
💡 TDD is Test-Driven Development — write tests first then code to pass them.
Submit answers