Provides additional asserts to be used in PHPUnit tests. The asserts are provided using Traits so no changes are needed in the hierarchy of test classes.
The additional asserts are provided through the Traits:
- FileExistsTrait
Replaces the PHPUnitassertFileExistsmethod. This assert does not pass if there is a directory rather than a file. - FileSystemAssertTrait
Provides asserts for testing directories, files and symbolic links. - ScalarAssertTrait
Provides asserts for testing of scalars such as integer, float, etc. - XMLAssertTrait
Additional PHPUnit asserts for testing XML based logic.
See Traits and asserts listing for more details.
PHP 5.4 (PHP7 supported). Optional HHVM support >= 3.9. PHPUnit >= 3.5.0
The package can be installed using Composer.
Add the package to your composer.json.
"require-dev": {
"gecko-packages/gecko-php-unit" : "1.0"
}
Please note we hint -dev here because typically you only need tests during development.
Example usage of FileSystemAssertTrait.
class myTest extends \PHPUnit_Framework_TestCase
{
use \GeckoPackages\PHPUnit\Asserts\FileSystemAssertTrait;
public function testFilePermissionsOfThisFile()
{
$this->assertFileHasPermissions('lrwxrwxrwx', __FILE__);
}
}Replacement for PHPUnits assertFileExists and assertFileNotExists.
Asserts when the filename exists and is a regular file, i.e. directories do not pass.
(Note. Since this changes the default behaviour of the PHPUnit assert this has been placed in a separate trait)
Requires PHPUnit >= 3.0.0 (https://phpunit.de/).
Assert the filename exists and is a regular file.
The inverse assertion
Assert the filename does not exists or is not a regular file.
Additional PHPUnit asserts for testing file (system) based logic.
Requires PHPUnit >= 3.0.0 (https://phpunit.de/).
Assert that a directory exists and is empty.
The inverse assertion
Assert that a directory exists and is not empty.
Assert that a directory exists.
The inverse assertion
Assert that a filename does not exists as directory.
Asserts that a file permission matches, for example: 'drwxrwxrwx' or '0664'.
Assert that a file is a symbolic link.
The inverse assertion
Assert that a file is not a symbolic link.
Asserts that a file permission matches mask, for example: '0007'.
The inverse assertion
Asserts that a file permission does not matches mask, for example: '0607'.
Additional shorthand PHPUnit asserts to test (for) scalar types.
Requires PHPUnit >= 3.5.0 (https://phpunit.de/).
Assert value is an array.
The inverse assertion
Assert value is not an array.
Assert value is a bool (boolean).
The inverse assertion
Assert value is not a bool (boolean).
Assert value is a float (double, real).
The inverse assertion
Assert value is not a float (double, real).
Assert value is an int (integer).
The inverse assertion
Assert value is not an int (integer).
Assert value is a scalar.
The inverse assertion
Assert value is not a scalar.
Assert value is a string.
The inverse assertion
Assert value is not a string.
Assert value is a string and is empty.
The inverse assertion
Assert value is a string and is not empty.
Assert value is a string and only contains white space characters (" \t\n\r\0\x0B").
The inverse assertion
Assert value is a string and not only contains white space characters (" \t\n\r\0\x0B").
Requires:
- PHPUnit >= 3.0.0 (https://phpunit.de/)
- libxml (https://secure.php.net/manual/en/book.libxml.php)
Assert string is XML formatted as defined by the XML Schema Definition.
Assert string is valid XML.
The project is released under the MIT license, see the LICENSE file.