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 mock a method with different arguments in PHPUnit?
- How to use hooks in PHPUnit?
- How to mock a property in PHPUnit?
- How to use the PHPUnit Framework TestCase?
- How to mock a query builder with PHPUnit?
- How to use named arguments in PHPUnit?
- How to increase memory limit in PHPUnit?
- How to disable color output in PHPUnit?
See more codes...