Same name and namespace in other branches
  1. 8.x-4.x tests/src/Functional/Plugin/StyleSlideshowTest.php \Drupal\Tests\views_slideshow\Functional\Plugin\StyleSlideshowTest::testSlideshowWidgets()

Test slideshow control widgets.

File

tests/src/Functional/Plugin/StyleSlideshowTest.php, line 68

Class

StyleSlideshowTest
Tests the slideshow style views plugin.

Namespace

Drupal\Tests\views_slideshow\Functional\Plugin

Code

public function testSlideshowWidgets() {
    $this->drupalGet('test-style-slideshow');
    // Ensure no controls are displayed.
    $this->assertCount(0, $this->cssSelect('.views-slideshow-controls-top'));
    $this->assertCount(0, $this->cssSelect('.views-slideshow-controls-bottom'));
    // Test top widget position.
    $view = View::load('test_style_slideshow');
    $display =& $view->getDisplay('default');
    $display['display_options']['style']['options']['widgets'] = [
        'top' => [
            'views_slideshow_controls' => [
                'enable' => TRUE,
                'weight' => 1,
                'hide_on_single_slide' => 0,
                'type' => 'views_slideshow_controls_text',
            ],
        ],
    ];
    $view->save();
    $this->drupalGet('test-style-slideshow');
    $this->assertCount(1, $this->cssSelect('.views-slideshow-controls-top'));
    $this->assertCount(0, $this->cssSelect('.views-slideshow-controls-bottom'));
    // Test bottom widget position.
    $view = View::load('test_style_slideshow');
    $display =& $view->getDisplay('default');
    $display['display_options']['style']['options']['widgets'] = [
        'bottom' => [
            'views_slideshow_controls' => [
                'enable' => TRUE,
                'weight' => 1,
                'hide_on_single_slide' => 0,
                'type' => 'views_slideshow_controls_text',
            ],
        ],
        'top' => [],
    ];
    $view->save();
    $this->drupalGet('test-style-slideshow');
    $this->assertCount(0, $this->cssSelect('.views-slideshow-controls-top'));
    $this->assertCount(1, $this->cssSelect('.views-slideshow-controls-bottom'));
}