public function ResponsiveWrappersTest::testsFilterContentOutput in Responsive wrappers 2.0.x
Same name and namespace in other branches
- 8 tests/src/Functional/ResponsiveWrappersTest.php \Drupal\Tests\responsivewrappers\Functional\ResponsiveWrappersTest::testsFilterContentOutput()
Tests responsive wrappers filter content output.
File
- tests/
src/ Functional/ ResponsiveWrappersTest.php, line 84
Class
- ResponsiveWrappersTest
- Provides a class for responsivewrappers functional tests.
Namespace
Drupal\Tests\responsivewrappers\FunctionalCode
public function testsFilterContentOutput() {
// Tests the node output without responsive wrappers filter enabled.
$this
->drupalGet('node/' . $this->node
->id());
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseContains('<img scr="#" />');
$this
->assertSession()
->responseContains('<table></table>');
$this
->assertSession()
->responseContains('<iframe src="https://www.youtube.com/embed/"></iframe>');
$this
->assertSession()
->responseContains('<iframe src="https://player.vimeo.com/video/"></iframe>');
// Enable the responsive wrappers filter.
$this
->drupalGet('admin/config/content/formats/manage/full_html');
$edit = [
'filters[filter_bootstrap_responsive_wrapper][status]' => TRUE,
'filters[filter_bootstrap_responsive_wrapper][settings][responsive_iframe]' => TRUE,
'filters[filter_bootstrap_responsive_wrapper][settings][responsive_table]' => TRUE,
'filters[filter_bootstrap_responsive_wrapper][settings][responsive_image]' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, t('Save configuration'));
// Tests the node output with responsive wrappers filter enabled. Bootstrap
// 4 output by default.
$this
->drupalGet('node/' . $this->node
->id());
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseContains('<img scr="#" class="img-fluid" />');
$this
->assertSession()
->responseContains('<div class="table-responsive"><table class="table"></table></div>');
$this
->assertSession()
->responseContains('<div class="embed-responsive embed-responsive-16by9"><iframe src="https://www.youtube.com/embed/" class="embed-responsive-item"></iframe></div>');
$this
->assertSession()
->responseContains('<div class="embed-responsive embed-responsive-16by9"><iframe src="https://player.vimeo.com/video/" class="embed-responsive-item"></iframe></div>');
// Set Bootstrap 3 output.
$this
->drupalGet('admin/config/content/responsivewrappers');
$this
->drupalPostForm(NULL, [
'version' => 3,
], t('Save configuration'));
// Update node to apply new filter settings.
$this->node
->setTitle('Responsive filter test B3');
$this->node
->save();
// Tests Bootstrap 3 output.
$this
->drupalGet('node/' . $this->node
->id());
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseContains('<img scr="#" class="img-responsive" />');
// Set Custom image class.
$this
->drupalGet('admin/config/content/responsivewrappers');
$this
->drupalPostForm(NULL, [
'version' => 0,
'image_class' => 'holi',
], t('Save configuration'));
// Update node to apply new filter settings.
$this->node
->setTitle('Responsive filter test Custom');
$this->node
->save();
// Tests Custom image class output.
$this
->drupalGet('node/' . $this->node
->id());
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseContains('<img scr="#" class="holi" />');
}