function BoxoutTest::testBoxoutArticle in Boxout 8
Test article creation.
File
- tests/
src/ Functional/ BoxoutTest.php, line 114
Class
- BoxoutTest
- Tests for Boxout.
Namespace
Drupal\Tests\boxout\FunctionalCode
function testBoxoutArticle() {
$this
->drupalLogin($this->adminUser);
// Test boxout form callback.
$this
->drupalGet('boxout/dialog');
$this
->assertResponse(200, "Boxout Dialog works");
$this
->xpath('//select[@id=:id]/option', [
':id' => 'boxout-style',
]);
$this
->assertOption('boxout-style', 'default');
$this
->assertOption('boxout-style', 'plain');
$this
->xpath('//select[@name=:id]/option', [
':id' => 'boxout-element-type',
]);
$this
->assertOption('boxout-element-type', 'p');
$this
->assertOption('boxout-element-type', 'h2');
$this
->assertOption('boxout-element-type', 'h3');
$this
->assertOption('boxout-element-type', 'h4');
$this
->assertOption('boxout-element-type', 'h5');
$field_header = $this
->xpath('//input[@name="attributes[header]"]');
$this
->assertTrue(count($field_header) === 1, 'Header field is present');
$field_body = $this
->xpath('//textarea[@name="attributes[body]"]');
$this
->assertTrue(count($field_body) === 1, 'Body field is present');
// Add an article.
$this
->drupalGet('node/add/article');
// Test editor config.
$editor_settings = $this
->getDrupalSettings()['editor']['formats']['boxout_filter']['editorSettings'];
$this
->assertTrue($editor_settings['allowedContent']['div']['classes'] == 'boxout,default,plain');
$this
->assertTrue($editor_settings['boxout_dialog_title_insert'] == 'Insert Boxout');
$this
->assertTrue($editor_settings['toolbar'][0]['items'][0] == 'Boxout');
// Set content.
$markup = '<div class="boxout default"><h2>Title</h2><p>Content</p></div>';
$this
->submitForm([
'title[0][value]' => 'Boxout test node ' . $this
->randomMachineName(10),
'body[0][value]' => $markup,
], $this
->t('Save'));
// Check markup.
$this
->assertRaw($markup);
}