public function ColorboxJavascriptTest::testColorboxGallery in Colorbox 8
Test the gallery works.
File
- tests/
src/ FunctionalJavascript/ ColorboxJavascriptTest.php, line 63
Class
- ColorboxJavascriptTest
- Test the colorbox JavaScript.
Namespace
Drupal\Tests\colorbox\FunctionalJavascriptCode
public function testColorboxGallery() {
$this
->drupalGet('node/' . $this->node
->id());
// Click and launch the gallery.
$this
->getSession()
->getPage()
->find('css', 'img')
->click();
$this
->getSession()
->wait(static::COLORBOX_WAIT_TIMEOUT);
$this
->assertSession()
->elementContains('css', '#cboxTitle', 'Image title 1');
$this
->assertSession()
->elementContains('css', '#colorbox', 'test.png');
// Click on the next image and assert the second image is visible.
$this
->assertSession()
->elementExists('css', '#cboxNext')
->click();
$this
->getSession()
->wait(static::COLORBOX_WAIT_TIMEOUT);
$this
->assertSession()
->elementContains('css', '#cboxTitle', 'Image title 2');
$this
->assertSession()
->elementContains('css', '#colorbox', 'test.png');
// Use alt captions.
\Drupal::entityTypeManager()
->getStorage('entity_view_display')
->load('node.page.default')
->setComponent('field_test_image', [
'type' => 'colorbox',
'settings' => [
'colorbox_caption' => 'alt',
],
])
->save();
drupal_flush_all_caches();
// Ensure the caption being used is the alt text.
$this
->drupalGet('node/' . $this->node
->id());
$this
->getSession()
->getPage()
->find('css', 'img')
->click();
$this
->getSession()
->wait(static::COLORBOX_WAIT_TIMEOUT);
$this
->assertSession()
->elementContains('css', '#cboxTitle', 'Image alt 1');
}