Because migrations are publish-only, a package built on the toolkit must run its own migrations explicitly in its test suite — for example in an Orchestra Testbench TestCase:
use Orchestra\Testbench\TestCase as Orchestra;
abstract class TestCase extends Orchestra
{
protected function getPackageProviders($app): array
{
return [CommentsServiceProvider::class];
}
protected function defineDatabaseMigrations(): void
{
// Migrations are publish-only — the package's own suite loads them explicitly.
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
}
}Register your provider there too, so the builder, macros and directives boot exactly as they do in a host application. Then assert through the public API — config guards throw, the LIKE macro treats wildcards literally, Blade conditionals render the right branch:
use Illuminate\Support\Facades\Blade;
use RoundlyConsulting\PackageToolkit\Exceptions\InvalidConfigurationException;
use RoundlyConsulting\PackageToolkit\Support\Config;
it('rejects an out-of-range page size', function (): void {
config()->set('comments.per_page', 500);
Config::integer('comments.per_page', 20, min: 1, max: 100);
})->throws(InvalidConfigurationException::class, 'between 1 and 100');
it('treats user wildcards literally', function (): void {
Comment::query()->create(['body' => 'hello world']);
Comment::query()->create(['body' => 'he%lo there']);
expect(Comment::query()->whereLikeEscaped('body', '%lo')->pluck('body')->all())
->toBe(['he%lo there']);
});
it('renders the else branch of the conditional directive', function (): void {
$output = Blade::render('@commentsEnabled($flag) on @else off @endcommentsEnabled', ['flag' => false]);
expect(trim($output))->toBe('off');
});The toolkit’s own suite runs with composer test, against a fixture package that exercises every builder method and opt-in trait.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.