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 show warnings in PHPUnit?
- How to run tests in parallel with PHPUnit?
- How to stop PHPUnit on failure?
- How to mock a static method with PHPUnit?
- How to skip a PHPUnit test?
- What are PHPUnit required extensions
- How to order tests with PHPUnit?
- How to mock a method with different arguments in PHPUnit?
- How to disable color output in PHPUnit?
- How to mock a method with PHPUnit?
See more codes...