You are here

final class FixtureContext in Lightning Media 8.3

Hierarchy

  • class \Drupal\Tests\lightning_media\FixtureContext extends \Drupal\Tests\lightning_core\FixtureBase

Expanded class hierarchy of FixtureContext

1 file declares its use of FixtureContext
MediaEntityContext.behat.inc in tests/contexts/MediaEntityContext.behat.inc

File

tests/src/FixtureContext.php, line 9

Namespace

Drupal\Tests\lightning_media
View source
final class FixtureContext extends FixtureBase {

  /**
   * @BeforeScenario
   */
  public function setUp() {
    $this
      ->installModule('image_widget_crop');
    $this
      ->installModule('lightning_page');

    // Ensure that the page content type and all related configuration will be
    // deleted when Lightning Page is uninstalled.

    /** @var \Drupal\node\NodeTypeInterface $node_type */
    $node_type = NodeType::load('page');
    $dependencies = $node_type
      ->getDependencies();
    $dependencies['enforced']['module'][] = 'lightning_page';
    $node_type
      ->set('dependencies', $dependencies)
      ->save();
    module_load_install('lightning_media_image');
    lightning_media_image_install();
    $config = Config::forModule('lightning_media')
      ->optional();

    /** @var \Drupal\user\RoleInterface $role */
    $role = $config
      ->getEntity('user_role', 'media_creator');
    $role
      ->grantPermission('access content')
      ->grantPermission('access content overview')
      ->grantPermission('access image_browser entity browser pages')
      ->grantPermission('create page content')
      ->grantPermission('edit own page content')
      ->grantPermission('use text format rich_text')
      ->grantPermission('view own unpublished content');
    $this
      ->save($role);
    $role = $config
      ->getEntity('user_role', 'media_manager');
    $this
      ->save($role);
    $this
      ->installTheme('bartik');
    $this
      ->installTheme('seven');
    $this
      ->config('system.theme')
      ->set('default', 'bartik')
      ->set('admin', 'seven')
      ->save();
    $this
      ->config('node.settings')
      ->set('use_admin_theme', TRUE)
      ->save();

    // Sentence-case the label of the media browser's embed code widget. Yes,
    // not doing this can cause tests to fail.
    $this
      ->config('entity_browser.browser.media_browser')
      ->set('widgets.8b142f33-59d1-47b1-9e3a-4ae85d8376fa.label', 'Create embed')
      ->save();

    // Cache the original view.
    $this
      ->config('views.view.media');
    $GLOBALS['install_state'] = [];

    /** @var \Drupal\views\ViewEntityInterface $view */
    $view = $this->container
      ->get('entity_type.manager')
      ->getStorage('view')
      ->load('media');
    lightning_media_view_insert($view);
    lightning_media_image_view_insert($view);
    unset($GLOBALS['install_state']);
  }

  /**
   * @AfterScenario
   */
  public function tearDown() {

    // This pointless if statement is here to evade a too-rigid coding standard.
    if (TRUE) {
      parent::tearDown();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FixtureContext::setUp public function @BeforeScenario
FixtureContext::tearDown public function @AfterScenario