MediaTypeResourceTestBase.php

Same filename in other branches
  1. 9 core/modules/media/tests/src/Functional/Rest/MediaTypeResourceTestBase.php
  2. 8.9.x core/modules/media/tests/src/Functional/Rest/MediaTypeResourceTestBase.php
  3. 8.9.x core/modules/rest/tests/src/Functional/EntityResource/MediaType/MediaTypeResourceTestBase.php
  4. 11.x core/modules/media/tests/src/Functional/Rest/MediaTypeResourceTestBase.php

Namespace

Drupal\Tests\media\Functional\Rest

File

core/modules/media/tests/src/Functional/Rest/MediaTypeResourceTestBase.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\media\Functional\Rest;

use Drupal\media\Entity\MediaType;
use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase;
abstract class MediaTypeResourceTestBase extends ConfigEntityResourceTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'media',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected static $entityTypeId = 'media_type';
    
    /**
     * @var \Drupal\media\MediaTypeInterface
     */
    protected $entity;
    
    /**
     * {@inheritdoc}
     */
    protected function setUpAuthorization($method) {
        $this->grantPermissionsToTestedRole([
            'administer media types',
        ]);
    }
    
    /**
     * {@inheritdoc}
     */
    protected function createEntity() {
        // Create a "Camelids" media type.
        $camelids = MediaType::create([
            'label' => 'Camelids',
            'id' => 'camelids',
            'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
            'source' => 'file',
        ]);
        $camelids->save();
        return $camelids;
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getExpectedNormalizedEntity() {
        return [
            'dependencies' => [],
            'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
            'field_map' => [],
            'id' => 'camelids',
            'label' => 'Camelids',
            'langcode' => 'en',
            'source' => 'file',
            'queue_thumbnail_downloads' => FALSE,
            'new_revision' => FALSE,
            'source_configuration' => [
                'source_field' => '',
            ],
            'status' => TRUE,
            'uuid' => $this->entity
                ->uuid(),
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getNormalizedPostEntity() {
        // @todo Update in https://www.drupal.org/node/2300677.
        return [];
    }

}

Classes

Title Deprecated Summary
MediaTypeResourceTestBase

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.