private function MediaEntitySlideshowTest::createMediaImageCollection in Media entity slideshow 8
Creates an array of media images to be used in testing.
Parameters
int $count: (optional) The number of items to create. Defaults to 3.
Return value
MediaInterface[] An indexed array of fully-loaded media objects of bundle image.
1 call to MediaEntitySlideshowTest::createMediaImageCollection()
- MediaEntitySlideshowTest::setUp in src/
Tests/ MediaEntitySlideshowTest.php - Sets up a Drupal site for running functional and integration tests.
File
- src/
Tests/ MediaEntitySlideshowTest.php, line 133
Class
- MediaEntitySlideshowTest
- Tests for media entity slideshow.
Namespace
Drupal\media_entity_slideshow\TestsCode
private function createMediaImageCollection($count = 3) {
$collection = [];
for ($i = 1; $i <= $count; $i++) {
$media = Media::create([
'bundle' => $this->imageMediaBundle
->id(),
'name' => 'Image media ' . $i,
'uid' => '1',
'langcode' => Language::LANGCODE_DEFAULT,
'status' => Media::PUBLISHED,
]);
$image = $this
->getTestFile('image');
$media->field_imagefield->target_id = $image
->id();
$media
->save();
$collection[] = $media;
}
return $collection;
}