You are here

public function SlickManagerTest::testSlickManagerMethods in Slick Carousel 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/SlickManagerTest.php \Drupal\Tests\slick\Kernel\SlickManagerTest::testSlickManagerMethods()

Tests cases for various methods.

@covers ::attach @covers ::attachSkin @covers ::getSkins @covers ::getConstantSkins @covers ::getSkinsByGroup @covers ::libraryInfoBuild

File

tests/src/Kernel/SlickManagerTest.php, line 81

Class

SlickManagerTest
Tests the Slick manager methods.

Namespace

Drupal\Tests\slick\Kernel

Code

public function testSlickManagerMethods() {
  $manager = $this->slickManager;
  $settings = [
    'media_switch' => 'media',
    'lazy' => 'ondemand',
    'mousewheel' => TRUE,
    'skin' => 'classic',
    'down_arrow' => TRUE,
    'thumbnail_effect' => 'hover',
    'slick_css' => TRUE,
    'module_css' => TRUE,
  ] + $this
    ->getFormatterSettings();
  $attachments = $manager
    ->attach($settings);
  $this
    ->assertArrayHasKey('slick', $attachments['drupalSettings']);

  // Tests for skins.
  $skins = $manager
    ->getSkins();
  $this
    ->assertArrayHasKey('skins', $skins);
  $this
    ->assertArrayHasKey('arrows', $skins);
  $this
    ->assertArrayHasKey('dots', $skins);

  // Verify we have cached skins.
  $cid = 'slick:skins';
  $cached_skins = $manager
    ->getCache()
    ->get($cid);
  $this
    ->assertEquals($cid, $cached_skins->cid);
  $this
    ->assertEquals($skins, $cached_skins->data);

  // Verify skins has thumbnail constant.
  $defined_skins = $manager::getConstantSkins();
  $this
    ->assertTrue(in_array('thumbnail', $defined_skins));

  // Verify libraries.
  $libraries = $manager
    ->libraryInfoBuild();
  $this
    ->assertArrayHasKey('slick.main.default', $libraries);
  $skins = $manager
    ->getSkinsByGroup('dots');
  $this
    ->assertArrayHasKey('dots', $skins);
}