Implements Task 2: creates the Site model with fillable name, url, and description fields; the corresponding database migration; and a factory for generating test data. Includes TDD tests verifying model creation with and without optional description. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
26 lines
654 B
PHP
26 lines
654 B
PHP
<?php
|
|
|
|
use App\Models\Site;
|
|
|
|
test('a site can be created with name, url, and optional description', function () {
|
|
$site = Site::create([
|
|
'name' => 'My Blog',
|
|
'url' => 'https://example.com',
|
|
'description' => 'A blog about things',
|
|
]);
|
|
|
|
expect($site->fresh())
|
|
->name->toBe('My Blog')
|
|
->url->toBe('https://example.com')
|
|
->description->toBe('A blog about things');
|
|
});
|
|
|
|
test('a site can be created without a description', function () {
|
|
$site = Site::create([
|
|
'name' => 'My Blog',
|
|
'url' => 'https://example.com',
|
|
]);
|
|
|
|
expect($site->fresh()->description)->toBeNull();
|
|
});
|