crudly/testly
A simple test package placeholder for crudly/testly. Currently contains minimal scaffolding and documentation (“This is a test”) and may be used for experimentation or as a starting point for future CRUD-related tooling.
Installation
composer require crudly/testly --dev
Add to composer.json under require-dev if not auto-detected.
First Use Case Test a simple Laravel route with a basic assertion:
use Testly\Testly;
Testly::test('GET /api/users', function () {
$response = $this->get('/api/users');
$response->assertStatus(200);
});
Where to Look First
Testly::test() and Testly::assert() methods in vendor/crudly/testly/src/Testly.php.tests/ or examples/ in the package directory (if provided).Basic HTTP Testing
Testly::test('User login', function () {
$response = $this->post('/login', ['email' => '[email protected]', 'password' => 'password']);
$response->assertRedirect('/dashboard');
});
Database Testing
Testly::test('Create user', function () {
$user = User::factory()->create();
$this->assertDatabaseHas('users', ['email' => $user->email]);
});
Integration with Laravel Testing
Use alongside Laravel’s built-in testing tools (e.g., Http, DatabaseMigrations traits):
use Illuminate\Foundation\Testing\RefreshDatabase;
Testly::test('User creation with refresh', function () {
$this->actingAs(User::factory()->create());
$this->post('/api/users', ['name' => 'John']);
$this->assertDatabaseCount('users', 2);
})->uses(RefreshDatabase::class);
Custom Assertions Extend Testly’s assertions (if supported):
Testly::assertJsonContains('key', 'expected_value');
create(), factory(), or assertJson() for richer tests.Testly::group() (if available) to organize related tests:
Testly::group('User', function () {
Testly::test('Create user');
Testly::test('Update user');
});
Mockery or partialMock within Testly tests:
Testly::test('Mocked service', function () {
$mock = Mockery::mock('alias:Service');
$mock->shouldReceive('process')->once();
// Test logic...
});
Outdated Package
composer.json for Laravel version constraints or fork the package.Limited Documentation
src/ for undocumented features (e.g., hidden assertion methods).No Built-in Test Runner
phpunit.xml, Testly may not integrate with Laravel’s test runner.php artisan test or manually via Testly::run().Stateful Tests
RefreshDatabase or withoutMiddleware() as needed.Testly::debug(true); // If supported; check package source.
Testly::test('Debug test', function () {
\Log::info('Test context', ['response' => $this->response->getContent()]);
});
php artisan test --debug
Custom Assertions
Extend the package by adding methods to Testly:
// In a service provider or trait:
Testly::macro('assertCustom', function ($condition) {
if (!$condition) {
throw new \Exception('Custom assertion failed');
}
});
Hooks
If Testly supports hooks (e.g., before, after), use them for setup/teardown:
Testly::before(function () {
$this->withoutExceptionHandling();
});
Configuration
Check for a config/testly.php file (if provided) to tweak behavior:
'default_headers' => [
'Accept' => 'application/json',
],
HttpTests for granular assertions.$this->get('/route')->assertOk(); // Native Laravel syntax.
How can I help you explore Laravel packages today?