You are here

public function Update360Test::test in Lightning Media 8.3

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/Update360Test.php \Drupal\Tests\lightning_media\Functional\Update360Test::test()

Tests the update.

File

tests/src/Functional/Update360Test.php, line 82

Class

Update360Test
Tests the update to Lightning Media 3.6.0.

Namespace

Drupal\Tests\lightning_media\Functional

Code

public function test() {
  $io = $this
    ->prophesize(StyleInterface::class);
  $io
    ->confirm(Argument::type('string'))
    ->shouldBeCalledOnce()
    ->willReturn(TRUE);
  $io
    ->ask(Argument::type('string'), Argument::any())
    ->shouldBeCalledTimes(2)
    ->willReturnArgument(1);

  // For reasons unclear, using $this->container to get the class resolver
  // will only work if $this->resetAll() is called when installing Lightning
  // Roles in setUp(). So, basically, a functional test can either use
  // $this->container or \Drupal, but not both.
  \Drupal::classResolver(Update360::class)
    ->cloneMediaBrowser($io
    ->reveal());

  /** @var \Drupal\entity_browser\EntityBrowserInterface $browser */
  $browser = EntityBrowser::load('ckeditor_media_browser');
  $this
    ->assertInstanceOf(EntityBrowser::class, $browser);
  $this
    ->assertSame('Media browser (CKEditor)', $browser
    ->label());
  $this
    ->assertSame('iframe', $browser
    ->getDisplay()
    ->getPluginId());
  $settings = EmbedButton::load('media_browser')
    ->getTypeSettings();
  $this
    ->assertSame('ckeditor_media_browser', $settings['entity_browser']);

  /** @var \Drupal\entity_browser\DisplayInterface $browser_display */
  $browser_display = EntityBrowser::load('media_browser')
    ->getDisplay();
  $this
    ->assertSame('modal', $browser_display
    ->getPluginId());
  $settings = $browser_display
    ->getConfiguration();
  $this
    ->assertEmpty($settings['width']);
  $this
    ->assertEmpty($settings['height']);
  $this
    ->assertSame('Add media', $settings['link_text']);
  $this
    ->assertFalse($settings['auto_open']);
  $this
    ->assertPermissions('media_creator');
  $this
    ->assertPermissions('media_manager');
  $this
    ->assertPermissions('test_creator');
}