spawnia/phpunit-assert-directory

PHPUnit extension with assert methods for directories

v0.1.0 2019-09-11 21:01 UTC

README

CI Status codecov StyleCI Latest Stable Version Total Downloads

PHPUnit extension with assert methods for directories

Installation

Install through composer

composer require --dev spawnia/phpunit-assert-directory

Usage

Use the trait AssertDirectory in your test method.

<?php

declare(strict_types=1);

namespace Foo\Tests;

use PHPUnit\Framework;
+use Spawnia\PHPUnitAssertFiles\AssertDirectory;

class FooTest extends Framework\TestCase
{
+   use AssertDirectory;
}

You can then proceed the use the additional assertions just like you would use PHPUnit's built-in methods, such as assertSame.

assertDirectoryEquals

/**
 * Assert that two directories contain the same files with the same contents.
 *
 * @param  string  $expected Path to the expected directory
 * @param  string  $actual Path to the actual directory
 * @param  string  $message Optional error message in case of failure
 *
 * @throws ExpectationFailedException
 */
public static function assertDirectoryEquals(string $expected, string $actual, string $message = '')

Changelog

Please have a look at CHANGELOG.md.

Contributing

Please have a look at CONTRIBUTING.md.

License

This package is licensed using the MIT License.