php-forge / support
Support library tests for PHP
Installs: 27 452
Dependents: 43
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- phpunit/phpunit: ^10.5
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-21 14:53:27 UTC
README
Support.
Installation
The preferred way to install this extension is through composer.
Either run
composer require --prefer-dist php-forge/support
or add
"php-forge/support": "^0.1"
to the require-dev section of your composer.json
file.
Usage
Equals without line ending
<?php declare(strict_types=1); namespace PHPForge\Support\Tests; use PHPForge\Support\Assert; Assert::equalsWithoutLE( <<<Text Foo Bar Text, "Foo\nBar" );
Inaccessible property
<?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'));
Invoke method
<?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'));
Set inaccessible property
<?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'));
Remove files from directory
<?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');
Support versions
Testing
Check the documentation testing to learn about testing.
Our social networks
License
The MIT License. Please see License File for more information.