This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
PHP Unit is built on assertions. These are actions that state something forcefully. Assertions is just a fancy way of saying true or false. These assertions describe how the code-under-test is supposed to be working. The vast majority of tests you write using PHPUnit will be using assertions.
Step 1
Install PHPUnit
composer require --dev phpunit/phpunit ^8
Step 2
Create a test folder and add your first test file, ending with Test.php
tests/FirstTest.php
Step 3
Add a class that extends from the PHPUnit\Framework\TestCase class.
class FirstTest extends PHPUnit\Framework\TestCase
{
}
Step 4
Add a test function, either named with "test" at the beginning, or using the @test annotation.
/** @test */
function firstAssertion()
{
$this->assertTrue(false);
}
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up