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.
<?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');
Check the documentation testing to learn about testing.
The MIT License. Please see License File for more information.