Mercurial > hg > isophonics-drupal-site
comparison modules/contrib/views_slideshow/src/Tests/Plugin/StyleSlideshowTest.php @ 5:c69a71b4f40f
Add slideshow module
author | Chris Cannam |
---|---|
date | Thu, 07 Dec 2017 14:46:23 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:8948ab6c87d2 | 5:c69a71b4f40f |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\views_slideshow\Tests\Plugin; | |
4 | |
5 use Drupal\views\Entity\View; | |
6 use Drupal\views\Tests\Plugin\PluginTestBase; | |
7 use Drupal\views\Tests\ViewTestData; | |
8 | |
9 /** | |
10 * Tests the slideshow style views plugin. | |
11 * | |
12 * @group views | |
13 */ | |
14 class StyleSlideshowTest extends PluginTestBase { | |
15 | |
16 /** | |
17 * Modules to enable. | |
18 * | |
19 * @var array | |
20 */ | |
21 public static $modules = [ | |
22 'views', | |
23 'views_slideshow', | |
24 'views_slideshow_cycle', | |
25 'views_test_config', | |
26 'views_slideshow_test', | |
27 ]; | |
28 | |
29 /** | |
30 * Views used by this test. | |
31 * | |
32 * @var array | |
33 */ | |
34 public static $testViews = ['test_style_slideshow']; | |
35 | |
36 /** | |
37 * {@inheritdoc} | |
38 */ | |
39 protected function setUp($import_test_views = TRUE) { | |
40 parent::setUp(); | |
41 | |
42 $this->enableViewsTestModule(); | |
43 if ($import_test_views) { | |
44 ViewTestData::createTestViews(get_class($this), ['views_slideshow_test']); | |
45 } | |
46 } | |
47 | |
48 /** | |
49 * Test slideshow display. | |
50 */ | |
51 public function testSlideshow() { | |
52 $this->drupalGet('test-style-slideshow'); | |
53 | |
54 $result = $this->cssSelect('.views_slideshow_main'); | |
55 $this->assertEqual(count($result), 1, 'Slideshow displayed on page'); | |
56 } | |
57 | |
58 /** | |
59 * Test slideshow control widgets. | |
60 */ | |
61 public function testSlideshowWidgets() { | |
62 $this->drupalGet('test-style-slideshow'); | |
63 | |
64 // Ensure no controls are displayed. | |
65 $this->assertFalse(count($this->cssSelect('.views-slideshow-controls-top'))); | |
66 $this->assertFalse(count($this->cssSelect('.views-slideshow-controls-bottom'))); | |
67 | |
68 // Test top widget position. | |
69 $view = View::load('test_style_slideshow'); | |
70 $display = &$view->getDisplay('default'); | |
71 $display['display_options']['style']['options']['widgets'] = [ | |
72 'top' => [ | |
73 'views_slideshow_controls' => [ | |
74 'enable' => TRUE, | |
75 'weight' => 1, | |
76 'hide_on_single_slide' => 0, | |
77 'type' => 'views_slideshow_controls_text', | |
78 ], | |
79 ], | |
80 ]; | |
81 $view->save(); | |
82 | |
83 $this->drupalGet('test-style-slideshow'); | |
84 $this->assertTrue(count($this->cssSelect('.views-slideshow-controls-top'))); | |
85 $this->assertFalse(count($this->cssSelect('.views-slideshow-controls-bottom'))); | |
86 | |
87 // Test bottom widget position. | |
88 $view = View::load('test_style_slideshow'); | |
89 $display = &$view->getDisplay('default'); | |
90 $display['display_options']['style']['options']['widgets'] = [ | |
91 'bottom' => [ | |
92 'views_slideshow_controls' => [ | |
93 'enable' => TRUE, | |
94 'weight' => 1, | |
95 'hide_on_single_slide' => 0, | |
96 'type' => 'views_slideshow_controls_text', | |
97 ], | |
98 ], | |
99 'top' => [], | |
100 ]; | |
101 $view->save(); | |
102 | |
103 $this->drupalGet('test-style-slideshow'); | |
104 $this->assertFalse(count($this->cssSelect('.views-slideshow-controls-top'))); | |
105 $this->assertTrue(count($this->cssSelect('.views-slideshow-controls-bottom'))); | |
106 } | |
107 | |
108 } |