您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit断言-assertEqualsIgnoringCase
发布时间:2021-10-02 17:04:31编辑:雪饮阅读()
assertEqualsIgnoringCase断言呢,它也是断言期望值与实际值相等的,但是它主要是不区分大小写。
EqualsIgnoringCaseTest.php:
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class EqualsIgnoringCaseTest extends TestCase
{
public function testFailure()
{
$this->assertEqualsIgnoringCase('foo', 'BAR');
}
public function testSuccess()
{
$this->assertEqualsIgnoringCase('foo', 'FOO');
}
public function testThree()
{
$this->assertEqualsIgnoringCase('BAR', 'baR');
}
}
use PHPUnit\Framework\TestCase;
final class EqualsIgnoringCaseTest extends TestCase
{
public function testFailure()
{
$this->assertEqualsIgnoringCase('foo', 'BAR');
}
public function testSuccess()
{
$this->assertEqualsIgnoringCase('foo', 'FOO');
}
public function testThree()
{
$this->assertEqualsIgnoringCase('BAR', 'baR');
}
}
运行结果:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.3.4nts\php.exe C:\Users\Administrator\PhpstormProjects\untitled\vendor\phpunit\phpunit\phpunit -c C:\Users\Administrator\PhpstormProjects\untitled\organizing\phpunit.xml C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests\EqualsIgnoringCaseTest.php
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
F.. 3 / 3 (100%)
Time: 00:00.011, Memory: 4.00 MB
There was 1 failure:
1) EqualsIgnoringCaseTest::testFailure
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'foo'
+'BAR'
C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests\EqualsIgnoringCaseTest.php:8
FAILURES!
Tests: 3, Assertions: 3, Failures: 1.
关键字词:phpunit,assertEqualsIgnoringCase