protected function DownloadTest::createMediaEntity in Media Entity Download 8.2
Test media entity creation.
Parameters
bool $published: Published state of media entity.
\Drupal\Core\Session\AccountInterface $owner: Media entity owner.
Return value
\Drupal\media\Entity\Media The created media entity.
Throws
\Drupal\Core\Entity\EntityStorageException
3 calls to DownloadTest::createMediaEntity()
- DownloadTest::testAttachmentDownload in tests/
src/ Functional/ DownloadTest.php - Tests if attachment download option created correct HTTP response headers.
- DownloadTest::testMediaDownloadByAnonymous in tests/
src/ Functional/ DownloadTest.php - Tests download of media entity files for anonymous users.
- DownloadTest::testMediaDownloadByOwner in tests/
src/ Functional/ DownloadTest.php - Tests download of media entity files by it's owner.
File
- tests/
src/ Functional/ DownloadTest.php, line 80
Class
- DownloadTest
- Simple test to ensure that main page loads with module enabled.
Namespace
Drupal\Tests\media_entity_download\FunctionalCode
protected function createMediaEntity($published, AccountInterface $owner) {
$value = FileItem::generateSampleValue($this->defaultSourceField);
$media = Media::create([
'name' => 'test',
'bundle' => 'testing',
$this->defaultSourceField
->getName() => $value['target_id'],
'status' => $published,
]);
$media
->setOwnerId($owner
->id());
$media
->save();
return $media;
}