Update360Test.php in Lightning Media 8.4
File
tests/src/Functional/Update360Test.php
View source
<?php
namespace Drupal\Tests\lightning_media\Functional;
use Drupal\embed\Entity\EmbedButton;
use Drupal\entity_browser\Entity\EntityBrowser;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\lightning_media\Update\Update360;
use Drupal\user\Entity\Role;
use Prophecy\Argument;
use Symfony\Component\Console\Style\StyleInterface;
class Update360Test extends UpdatePathTestBase {
protected $defaultTheme = 'stark';
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../fixtures/Update360Test.php.gz',
];
}
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'test',
]);
\Drupal::service('module_installer')
->install([
'lightning_roles',
]);
}
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);
\Drupal::classResolver(Update360::class)
->cloneMediaBrowser($io
->reveal());
$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']);
$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');
}
private function assertPermissions($role_id) {
$role = Role::load($role_id);
$this
->assertInstanceOf(Role::class, $role);
$this
->assertTrue(Role::load($role_id)
->hasPermission('access ckeditor_media_browser entity browser pages'));
}
}
Classes
Name |
Description |
Update360Test |
Tests the optional configuration updates targeting Lightning Media 3.6.0. |