PHPUnit assertNotEqualsIgnoringCase()函数
assertNotEqualsIgnoringCase()函数是 PHPUnit 中的内置函数,用于断言预期字符串是否不等于实际字符串但忽略大小写。如果实际字符串不等于预期字符串忽略大小写敏感性,则此断言将返回 true,否则返回 false。如果为真,则断言的测试用例通过,否则测试用例失败。
句法:
assertnotEqualsIgnoringCase(mixed $expected,
mixed $actual[, string $message = '']
参数:此函数接受三个参数,如上所述,如下所述:
- $expected:这个参数是一个字符串,代表预期的数据。
- $actual:这个参数是一个字符串,代表实际数据。
- $message:此参数采用字符串值。当测试用例失败时,此字符串消息显示为错误消息。
下面的程序说明了 assertnotEqualsIgnoringCase()函数:
示例 1:
PHP
assertNotEqualsIgnoringCase(
$actual,
$expected,
"expected string is equal to actual ignoring case" ) ;
}
}
?>
PHP
assertNotEqualsIgnoringCase(
$actual,
$expected,
"expected string is equal to actual ignoring case" ) ;
}
}
?>
输出:
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.
F 1 / 1 (100%)
Time: 91 ms, Memory: 10.00 MB
There was 1 failure:
1) GeeksPhpunitTestCase::testpositivTestcaseForAssertNotequalIgnoringCase
expected string is equal to actual ignoring case
Failed asserting that 'Geeks' is not equal to 'geEks'.
/home/lovely/Documents/php/test.php:17
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
示例 2:
PHP
assertNotEqualsIgnoringCase(
$actual,
$expected,
"expected string is equal to actual ignoring case" ) ;
}
}
?>
输出:
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 91 ms, Memory: 10.00 MB
OK (1 test, 1 assertion)