Skip to content

Commit

Permalink
Add medialibrary update in bulk test
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioribeiro authored and ifox committed Nov 18, 2019
1 parent 2c2ea3e commit 094a9fa
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions tests/integration/MediaLibraryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public function testCanSingleUpdateMedia()

$data = [
'alt_text' => 'Black Normal 1200x800',
'fieldsRemovedFromBulkEditing' => '[]',
'fieldsRemovedFromBulkEditing' => [],
'id' => $media->id,
'tags' => 'avatar',
'tags' => 'avatar,photo',
];

$crawler = $this->ajax(
Expand All @@ -93,5 +93,53 @@ public function testCanSingleUpdateMedia()
$crawler->assertStatus(200);

$media->refresh();

$this->assertEquals(
$this->now->format('Y-m-d H:i'),
$media->created_at->format('Y-m-d H:i')
);

$this->assertEquals(
$media->tags
->pluck('slug')
->sort()
->toArray(),
['avatar', 'photo']
);
}

public function testCanUpdateInBulk()
{
$medias = collect();

$medias->push($this->createMedia());
$medias->push($this->createMedia());
$medias->push($this->createMedia());

$data = [
'ids' => $medias->pluck('id')->implode(','),
'fieldsRemovedFromBulkEditing' => [],
'tags' => collect(
$tagsArray = ['avatar', 'image', 'media', 'photo']
)->implode(','),
];

$crawler = $this->ajax(
'/twill/media-library/medias/bulk-update',
'PUT',
$data
);

$crawler->assertStatus(200);

$tags = collect(
$medias->reduce(function ($carry, $media) use ($medias) {
return $carry + $media->tags->pluck('slug')->toArray();
}, [])
)
->sort()
->toArray();

$this->assertEquals($tags, $tagsArray);
}
}

0 comments on commit 094a9fa

Please sign in to comment.