phpunitHow to use PHPUnit assertcontains?
PHPUnit assertContains is a method used to check if a given value is contained in an array. It takes two parameters, the first being the expected value and the second being the array to search.
Example code
$array = array('a', 'b', 'c');
$this->assertContains('b', $array);
Output example
OK (1 test, 1 assertion)
Code explanation
$array
: An array containing the values to search.assertContains()
: The method used to check if a given value is contained in an array.'b'
: The expected value to search for.
Helpful links
More of Phpunit
- How to skip a PHPUnit test?
- How to run tests in parallel with PHPUnit?
- How to use hooks in PHPUnit?
- What are PHPUnit required extensions
- How to use the PHPUnit Framework TestCase?
- How to run PHPUnit in quiet mode?
- How to show warnings in PHPUnit?
- How to load fixtures with PHPUnit?
- How to use a listener with PHPUnit?
- How to stop PHPUnit on failure?
See more codes...