PHPUnit | assertNotContains() function Last Updated : 19 Jul, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The assertNotContains() function is a builtin function in PHPUnit and is used to assert an array not having a value. This assertion will return true in the case if the array doesn't contain the provided value else return false and in case of true the asserted test case got passed else test case got failed. Syntax: assertNotContains(mixed $value, array $array, string $message = '']) Parameters: This function accepts three parameters as shown in the above syntax. The parameters are described below: $value: This parameter represents the value not to be contained in array. $array: This parameter is a array for which the assert function will check whether it contains value or not. $message: This parameter takes string value. When the testcase got failed this string message got displayed as error message. Below programs illustrate the assertNotContains() function: Program 1: php <?php use PHPUnit\Framework\TestCase; class GeeksPhpunitTestCase extends TestCase { public function testNegativeTestcaseForAssertNotContains() { $testArray = array("a"=>"value ba", "b" =>"value b"); $value = "value ba"; // assert function to test whether 'value' is a value of array $this->assertNotContains($value, $testArray, "testArray contains value as value") ; } } ?> Output: PHPUnit 6.5.5 by Sebastian Bergmann and contributors. F 1 / 1 (100%) Time: 21 ms, Memory: 4.00MB There was 1 failure: 1) GeeksPhpunitTestCase::testNegativeTestcaseForAssertNotContains testArray contains value as value Failed asserting that an array does not contain 'value ba'. /home/shivam/Documents/geeks/phpunit/abc.php:11 FAILURES! Tests: 1, Assertions: 1, Failures: 1. Program 2: php <?php use PHPUnit\Framework\TestCase; class GeeksPhpunitTestCase extends TestCase { public function testPositiveTestcaseForAssertNotContains() { $testArray = array("a"=>"value ba", "b" =>"value b"); $value = "value b"; // assert function to test whether 'value' is a value of array $this->assertNotContains($value, $testArray, "testArray contains value as value") ; } } ?> Output: PHPUnit 6.5.5 by Sebastian Bergmann and contributors. . 1 / 1 (100%) Time: 21 ms, Memory: 4.00MB OK (1 test, 1 assertion) Note : To run testcases with phpunit follow steps from here. Comment More infoAdvertise with us Next Article PHPUnit | assertContains() function S Shivam.Pradhan Follow Improve Article Tags : Web Technologies PHP PHP-PHPUnit Similar Reads PHPUnit | assertContains() function The assertContains() function is a builtin function in PHPUnit and is used to assert an array having a value. This assertion will return true in the case if the array contains the provided value else return false and in case of true the asserted test case got passed else test case got failed. Syntax 2 min read PHPUnit | assertNotContainsOnly() Function The assertNotContainsOnly() function is a builtin function in PHPUnit and is used to assert an array not to contain all its values as the given data type. This assertion will return true in the case if the array contains values apart from given data type else return false. In case of true the assert 2 min read PHPunit | aassertNotCount() Function The aassertNotCount() function is a builtin function in PHPUnit and is used to assert an array not to contain same number of elements as the given count value. This assertion will return true in the case if the array doesn't contain the exact number of elements as given count else return false. In c 2 min read PHPUnit | assertContainsOnly() Function The assertContainsOnly() function is a builtin function in PHPUnit and is used to assert an array to contain all its values as the given data type. This assertion will return true in the case if the array contains values of only given data type else return false and in case of true the asserted test 2 min read PHPUnit assertNan() Function The assertNan() function is a builtin function in PHPUnit and is used to assert whether the variable is NAN or not. This assertion will return true in the case if the variable is NAN else returns false. In case of true the asserted test case got passed else test case got failed. Syntax: assertNan(mi 2 min read PHPunit | assertCount() Function The assertCount() function is a builtin function in PHPUnit and is used to assert an array to contain same number of elements as the given count value. This assertion will return true in the case if the array contains only an exact number of elements as given count else return false. In case of true 2 min read Like