I am trying to test media view displays via a test, which is based on the KernelTestBase class. I have also tried to inherit from Drupal\Tests\media\Kernel\MediaKernelTestBase, but got the same error from bellow:

LogicException: Missing bundle entity, entity type media_type, entity id image.

My test class looks like this:


namespace Drupal\Tests\degov_image_and_crop_styles\Kernel;

use Drupal\Core\Extension\ModuleHandler;
use Drupal\KernelTests\KernelTestBase;

class ModuleInstallationTest extends KernelTestBase {

   * {@inheritdoc}
  public static $modules = [

   * {@inheritdoc}
  protected function setUp() {
    $this->installSchema('system', ['sequences']);
    $this->installSchema('user', 'users_data');
    $this->installSchema('file', 'file_usage');
    $this->installSchema('node', ['node_access']);

  public function testSetup(): void {
     * @var ModuleHandler $moduleHandler
    $moduleHandler = \Drupal::service('module_handler');


Does anyone know, what I am missing here?

1 Answer 1


I could solve this via:


Also I inherited from MediaKernelTestBase.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.