AssetManagerTest.php in PhotoSwipe 3.x
File
tests/src/Kernel/AssetManagerTest.php
View source
<?php
namespace Drupal\Tests\photoswipe\Kernel;
use Drupal\KernelTests\KernelTestBase;
class AssetManagerTest extends KernelTestBase {
protected static $modules = [
'photoswipe_assets_test',
'photoswipe',
];
protected $assetManager;
protected function setUp() : void {
parent::setUp();
$this
->installConfig([
'photoswipe',
]);
$this->assetManager = \Drupal::service('photoswipe.assets_manager');
}
public function testPhotoswipeJsOptionsHook() {
\Drupal::service('theme_installer')
->install([
'photoswipe_test_theme',
]);
$manager = \Drupal::service('theme.manager');
$manager
->setActiveTheme(\Drupal::service('theme.initialization')
->initTheme('photoswipe_test_theme'));
$dummy = [
'#markup' => 'dummy',
];
$this->assetManager
->attach($dummy);
$options = $dummy['#attached']['drupalSettings']['photoswipe']['options'];
$this
->assertEquals(FALSE, (bool) $options['loop']);
$this
->assertEquals('Test', $options['errorMsg']);
}
}