php-forge / support
PHP 的支持库测试
0.1.0
2024-01-21 10:27 UTC
Requires
- php: ^8.1
- phpunit/phpunit: ^10.5
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-21 14:31:59 UTC
README
支持
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
composer require --prefer-dist php-forge/support
或者在您的 composer.json
文件的 require-dev 部分添加:
"php-forge/support": "^0.1"
用法
等号后无换行符
<?php declare(strict_types=1); namespace PHPForge\Support\Tests; use PHPForge\Support\Assert; Assert::equalsWithoutLE( <<<Text Foo Bar Text, "Foo\nBar" );
不可访问属性
<?php declare(strict_types=1); namespace PHPForge\Support\Tests; use PHPForge\Support\Assert; $object = new class () { private string $foo = 'bar'; }; $this->assertSame('bar', Assert::inaccessibleProperty($object, 'foo'));
调用方法
<?php declare(strict_types=1); namespace PHPForge\Support\Tests; use PHPForge\Support\Assert; $object = new class () { protected function foo(): string { return 'foo'; } }; $this->assertSame('foo', Assert::invokeMethod($object, 'foo'));
设置不可访问属性
<?php declare(strict_types=1); namespace PHPForge\Support\Tests; use PHPForge\Support\Assert; $object = new class () { private string $foo = 'bar'; }; Assert::setInaccessibleProperty($object, 'foo', 'baz'); $this->assertSame('baz', Assert::inaccessibleProperty($object, 'foo'));
从目录中删除文件
<?php declare(strict_types=1); namespace PHPForge\Support\Tests; use PHPForge\Support\Assert; $dir = __DIR__ . '/runtime'; mkdir($dir); mkdir($dir . '/subdir'); touch($dir . '/test.txt'); touch($dir . '/subdir/test.txt'); Assert::removeFilesFromDirectory($dir); $this->assertFileDoesNotExist($dir . '/test.txt'); rmdir(__DIR__ . '/runtime');
支持版本
测试
查看测试文档 了解有关测试的信息。
我们的社交媒体
许可证
MIT 许可证。有关更多信息,请参阅 许可证文件。