draw/data-tester
Lightweight PHP data testing helper for validating arrays/objects against expected shapes and values. Useful for unit tests and quick assertions, with simple matchers and readable failure messages to spot mismatches fast.
Illuminate\Support\Facades\Validator or Assert methods, offering a more expressive syntax for complex assertions.symfony/property-access, which is already used by Laravel (via symfony/property-access v4+). No additional dependencies conflict with Laravel’s ecosystem.PHPUnit\Framework\TestCase or Illuminate\Foundation\Testing\TestCase).Assert or packages like spatie/laravel-test-factory may offer similar functionality with better maintenance.symfony/property-access v5+ that affect this package?Assert or Validator for common use cases (e.g., validating a User model)?tests/Feature/) or unit tests (e.g., tests/Unit/) where data validation is critical.TestCase classes.Laravel\Factory or spatie/laravel-test-factory.Benchmark or custom scripts.composer require draw/data-tester --dev
php artisan test).// Before (Laravel Assert)
$this->assertEquals('John', $user->name);
$this->assertTrue($user->email_verified_at instanceof \DateTime);
$this->assertArrayHasKey('id', $user->toArray());
// After (data-tester)
$this->assertData($user)
->hasField('name', 'John')
->hasField('email_verified_at', function ($value) {
return $value instanceof \DateTime;
})
->hasKeys(['id', 'created_at']);
tests/TestTraits/DataAssertions.php).phpunit.xml config aligns with the package’s requirements (e.g., no conflicting extensions).$model->toArray() vs. $model->attributes).$response->json() vs. raw data).assertData() for model validation").Post resource).Assert if the package fails.| Risk | Impact | Mitigation |
|---|---|---|
| PHPUnit Incompatibility | Tests fail silently or throw errors. | Fork and update dependencies. |
| Undiscovered Bugs | False positives/negatives in tests. | Pair test assertions with manual review. |
| Abandoned Package | No future updates. | Maintain a private fork. |
| Overhead | Tests run slower. | Benchmark and optimize assertions. |
| Misuse | Overly complex assertions. | Enforce coding standards/reviews. |
Assert.DataTesterExampleTest.php in the test suite.Assert with data-tester.How can I help you explore Laravel packages today?