Images can be uploaded with alt text
This means associating images to notes via a pivot table, we also finish off the migration of medai from S3.
This commit is contained in:
parent
76db869af5
commit
9e788e0fe8
9 changed files with 200 additions and 19 deletions
|
|
@ -15,11 +15,18 @@ class MediaTest extends TestCase
|
|||
use RefreshDatabase;
|
||||
|
||||
#[Test]
|
||||
public function get_the_note_that_media_instance_belongs_to(): void
|
||||
public function media_can_belong_to_multiple_notes(): void
|
||||
{
|
||||
$media = Media::factory()->for(Note::factory())->create();
|
||||
$media = Media::factory()->create();
|
||||
$note1 = Note::factory()->create();
|
||||
$note2 = Note::factory()->create();
|
||||
|
||||
$this->assertInstanceOf(Note::class, $media->note);
|
||||
$note1->media()->attach($media->id, ['alt_text' => 'Alt text for note 1']);
|
||||
$note2->media()->attach($media->id, ['alt_text' => 'Alt text for note 2']);
|
||||
|
||||
$this->assertCount(2, $media->notes);
|
||||
$this->assertTrue($media->notes->contains($note1));
|
||||
$this->assertTrue($media->notes->contains($note2));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
|
|
|
|||
|
|
@ -434,4 +434,21 @@ class NotesTest extends TestCase
|
|||
|
||||
$this->assertSame($expected, $note->note);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function note_can_have_media_with_alt_text(): void
|
||||
{
|
||||
$note = Note::factory()->create();
|
||||
$media = Media::factory()->create();
|
||||
|
||||
$note->media()->attach($media->id, [
|
||||
'alt_text' => 'Test alt text',
|
||||
'order' => 0,
|
||||
]);
|
||||
|
||||
$note->refresh();
|
||||
|
||||
$this->assertCount(1, $note->media);
|
||||
$this->assertEquals('Test alt text', $note->media->first()->pivot->alt_text);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue