maks3w/phpunit-methods-trait
PHP trait exposing PHPUnit TestCase helper methods for use inside reusable test traits. Lets traits call mocking, expectations, and other TestCase APIs without extending TestCase directly; assertions are via PHPUnit\Framework\Assert.
TestCase (via Illuminate\Foundation\Testing\TestCase) already provides PHPUnit methods, but this package could help third-party traits (e.g., custom test utilities) access them cleanly.use the trait in custom test traits.TestCase methods, it won’t conflict with Laravel’s test helpers (e.g., create(), assertDatabaseHas()).DatabaseTestsTrait, ApiAuthTrait) where developers need to call PHPUnit methods like getMockBuilder() or assert*().assertSeeInResponse()), which are domain-specific.TestCase.assertDatabaseHas() is Laravel-specific, not PHPUnit).TestCase already exposes these methods; the trait adds no runtime value.TestCase directly?
TestCase can be extended or used via parent::method(). This package adds no runtime benefit.TestCase in a base trait.TestCase directly in traits (requires use PHPUnit\Framework\TestCase).SharedTestMethods, MockingTrait) where PHPUnit methods are needed.assertRedirect(), assertSession()).use PHPUnit\Framework\TestCase).use TestCase; use Assert; with a single trait).use PHPUnit\Framework\TestCase with the trait in custom traits.TestCase or feature tests (redundant).use PHPUnit\Framework\TestCase.composer.json as a dev dependency.
composer require --dev maks3w/phpunit-methods-trait
use statements in custom traits:
// Before
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Assert;
// After
use Maks3w\PhpUnitMethodsTrait\Framework\TestCaseTrait;
README note warning about the package’s limited lifespan and IDE-only value.TestCase::any() instead of PHPUnit\Framework\TestCase::any()).assertDatabaseHas()).assertTrue() instead of assertSee()).use statements.How can I help you explore Laravel packages today?