ghostwriter / psr-phpunit-assertions
This package is abandoned and no longer maintained.
The author suggests using the ghostwriter/phpunit-assertions package instead.
Additional assertions for PHPUnit
Package info
github.com/ghostwriter/psr-phpunit-assertions
pkg:composer/ghostwriter/psr-phpunit-assertions
Fund package maintenance!
0.1.0
2026-05-27 19:00 UTC
Requires
- php: ~8.4.0 || ~8.5.0
- ext-mbstring: *
- phpunit/phpunit: ^13.1.13
Requires (Dev)
- ext-xdebug: *
- boundwize/structarmed: ^0.8.0
- ghostwriter/coding-standard: dev-main
- ghostwriter/testify: ^0.1.2
- mockery/mockery: ^1.6.12
- symfony/var-dumper: ^8.0.8
README
Additional assertions for PHPUnit
Installation
You can install the package via composer:
composer require ghostwriter/phpunit-assertions --dev
Star ⭐️ this repo if you find it useful
You can also star (🌟) this repo to find it easier later.
Usage
<?php declare(strict_types=1); namespace Tests\Unit; use PHPUnit\Framework\TestCase; use Ghostwriter\PHPUnitAssertions\Trait\ClassAssertionsTrait; final class ExampleTest extends TestCase { use ClassAssertionsTrait; public function testClassAssertions(): void { self::assertClassHasMethod('invoke', ExampleChild::class); self::assertClassDoesNotHaveMethod('missing', ExampleChild::class); self::assertClassExtendsClass(ExampleChild::class, ExampleBase::class); self::assertClassExtendsClasses(ExampleChild::class, [ExampleBase::class, ExampleRoot::class]); self::assertClassImplementsInterface(ExampleChild::class, ExampleInterface::class); self::assertClassImplementsInterfaces(ExampleChild::class, [ExampleInterface::class, ExampleExtraInterface::class]); self::assertClassUsesTrait(ExampleChild::class, ExampleTraitA::class); self::assertClassUsesTraits(ExampleChild::class, [ExampleTraitA::class, ExampleTraitB::class]); } } interface ExampleInterface {} interface ExampleExtraInterface {} interface ExampleCompositeInterface extends ExampleInterface, ExampleExtraInterface {} trait ExampleTraitA {} trait ExampleTraitB {} class ExampleRoot {} class ExampleBase extends ExampleRoot { use ExampleTraitA; public function invoke(): void {} } class ExampleChild extends ExampleBase implements ExampleCompositeInterface { use ExampleTraitB; }
Trait methods
ClassAssertionsTrait
ClassAssertionsTrait::assertClassHasMethodClassAssertionsTrait::assertClassDoesNotHaveMethodClassAssertionsTrait::assertClassExtendsClassClassAssertionsTrait::assertClassExtendsClassesClassAssertionsTrait::assertClassImplementsInterfaceClassAssertionsTrait::assertClassImplementsInterfacesClassAssertionsTrait::assertClassUsesTraitClassAssertionsTrait::assertClassUsesTraits
Credits
Changelog
Please see CHANGELOG.md for more information on what has changed recently.
License
Please see LICENSE for more information on the license that applies to this project.
Security
Please see SECURITY.md for more information on security disclosure process.