您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit断言-assertIsReadable
发布时间:2021-10-04 16:44:40编辑:雪饮阅读()
assertIsReadable用于断言一个文件或者目录可读。
IsReadableTest.php:
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class IsReadableTest extends TestCase
{
public function testFailure(): void
{
$this->assertIsReadable('/path/to/unreadable');
}
public function testSuccess(): void
{
$this->assertIsReadable("D:\software\FormatFactory_5.3.0_PortableSoft\FormatFactoryPortable\Data");
}
}
use PHPUnit\Framework\TestCase;
final class IsReadableTest extends TestCase
{
public function testFailure(): void
{
$this->assertIsReadable('/path/to/unreadable');
}
public function testSuccess(): void
{
$this->assertIsReadable("D:\software\FormatFactory_5.3.0_PortableSoft\FormatFactoryPortable\Data");
}
}
运行结果:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.4.3nts\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\IsReadableTest.php
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
F. 2 / 2 (100%)
Time: 00:00.009, Memory: 6.00 MB
There was 1 failure:
1) IsReadableTest::testFailure
Failed asserting that "/path/to/unreadable" is readable.
C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests\IsReadableTest.php:8
FAILURES!
Tests: 2, Assertions: 2, Failures: 1.
关键字词:phpunit,assertIsReadable