1. Go to this page and download the library: Download grazulex/laravel-tddraft library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
grazulex / laravel-tddraft example snippets
declare(strict_types=1);
/**
* TDDraft Test: User can register
*
* Reference: tdd-20250718142530-Abc123
* Type: feature
* Created: 2025-07-18 14:25:30
*/
it('user can register', function (): void {
// TODO: Implement your test scenario here
$response = $this->post('/register', [
'name' => 'John Doe',
'email' => '[email protected]',
'password' => 'password',
'password_confirmation' => 'password',
]);
$response->assertStatus(201);
$this->assertDatabaseHas('users', [
'email' => '[email protected]',
]);
})
->group('tddraft', 'feature', 'tdd-20250718142530-Abc123')
->todo('Implement the test scenario for: user can register');
return [
/**
* Test status tracking configuration
*
* Controls how test execution results are tracked and persisted.
* This is a key feature that enables professional TDD workflow management.
*/
'status_tracking' => [
// Enable or disable status tracking
'enabled' => env('LARAVEL_TDDRAFT_STATUS_TRACKING_ENABLED', true),
// File path where test statuses are saved (relative to Laravel base path)
'file_path' => env('LARAVEL_TDDRAFT_STATUS_FILE', 'tests/TDDraft/.status.json'),
// Keep history of status changes for each test
'track_history' => env('LARAVEL_TDDRAFT_TRACK_HISTORY', true),
// Maximum number of history entries to keep per test
'max_history_entries' => env('LARAVEL_TDDRAFT_MAX_HISTORY', 50),
],
];
declare(strict_types=1);
/**
* TDDraft Test: User registration workflow
*
* Reference: tdd-20250718142530-Abc123
* Type: feature
* Created: 2025-07-18 14:25:30
*/
it('should fail initially - this is normal for TDD red phase', function (): void {
// This test intentionally fails to demonstrate the TDD "red" phase
// Status will be tracked as 'failed' until implementation is complete
$response = $this->post('/register', [
'name' => 'John Doe',
'email' => '[email protected]',
'password' => 'password',
'password_confirmation' => 'password',
]);
$response->assertStatus(201);
$this->assertDatabaseHas('users', [
'email' => '[email protected]',
]);
})
->group('tddraft', 'feature', 'tdd-20250718142530-Abc123')
->todo('Implement user registration endpoint and validation');
it('can be promoted when ready and status shows consistent passing', function (): void {
// When this test consistently passes (shown in status tracking),
// it's ready for promotion to the main test suite
expect(true)->toBeTrue();
})
->group('tddraft', 'feature', 'tdd-20250718142530-Abc123');