Syntax :
assertClassNotHasStaticAttribute (string $attributeName, string $className, string $message = ’’])
Parameters : This function takes three parameters as shown in the above syntax. The parameters are described below: $attributeName : This parameter is an attributeName that is not an attribute of the class in the array. $className : This parameter is the name of the class for which the assert function will check if it contains an attribute or not. $message : This parameter accepts a string value. When the test case failed, this string message was displayed as an error message. The following programs illustrate the assertClassNotHasStaticAttribute() function: Program 1 : use
PHPUnitFrameworkTestCase;
// test class
Class testClass {
public
static
$engineer
=
"test attribute"
;
}
class
GeeksPhpunitTestCase
extends
TestCase
{
public
function
testNegativeTestcaseForClassNotHasStaticAttribute()
{
// assert function for checking if ’ engineer ’ the testclass attribute
$this
-> assertClassNotHasStaticAttribute (
’engineer’
,
" testClass "
,
"testClass has engineer as static attribute"
);
}
}
?>
Output:PHPUnit 6.5. 5 by Sebastian Bergmann and contributors. F 1/1 (100%) Time: 46 ms, Memory: 4.00MB There was 1 failure: 1) GeeksPhpunitTestCase::testNegativeTestcaseForClassNotHasStaticAttribute testClass has engineer as static attribute Failed asserting that class "testClass" does not have static attribute "engineer". /home/shivam/Documents/engineer/phpunit/abc.php:14 FAILURES! Tests: 1, Assertions: 1, Failures: 1.
Program 2 : use
PHPUnitFrameworkTestCase;
// test class
Class testClass {
public
static
$attribute
=
"test attribute"
;
}
class
GeeksPhpunitTestCase
extends
TestCase
{
public
function
testPositiveTestcaseForClassNotHasStaticAttribute()
{
// assert function for checking if ’ engineer ’ the testclass attribute
$this
-> assertClassNotHasStaticAttribute (
’engineer’
,
" testClass "
,
"testClass has engineer as static attribute"
);
}
}
?>
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 steps follows from here .