FunctionalTest.php in No Non-breaking Space Filter 8
File
src/Tests/FunctionalTest.php
View source
<?php
namespace Drupal\no_nbsp\Tests;
class FunctionalTest extends NoNbspWebTestBase {
public static $modules = [
'no_nbsp',
];
protected $profile = 'minimal';
public function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'name' => 'page',
'type' => 'page',
]);
$this->user = $this
->drupalCreateUser([
'administer filters',
'bypass node access',
'administer content types',
]);
$this
->drupalLogin($this->user);
}
public function testFormatAdmin() {
$this
->drupalGet('admin/config/content/formats');
$this
->clickLink('Add text format');
$this
->assertText(t('No Non-breaking Space Filter'), 'Title text is shown.');
$this
->assertText(t('Delete all non-breaking space HTML entities.'), 'Description text is shown.');
$this
->assertText(t('Preserve placeholders.'), 'Settings: Title.');
$this
->assertText(t('A placeholder non-breaking space is surrounded by a HTML tag'), 'Settings: Description.');
$format_id = 'no_nbsp_format';
$name = 'No nbsp filter format';
$edit = [
'format' => $format_id,
'name' => $name,
'roles[anonymous]' => 1,
'roles[authenticated]' => 1,
'filters[filter_no_nbsp][status]' => 1,
];
$this
->drupalPostForm(NULL, $edit, t('Save configuration'));
$this
->drupalGet('filter/tips');
$this
->assertText(t('All non-breaking space HTML entities are replaced by blank space characters.'));
$this
->assertText(t('Multiple contiguous space characters are replaced by a single blank space character.'));
$this
->drupalGet('admin/config/content/formats/manage/' . $format_id);
$input = $this
->xpath('//input[@id="edit-filters-filter-no-nbsp-status"]');
$this
->assertEqual($input[0]
->attributes()->checked, 'checked');
filter_formats_reset();
$formats = filter_formats();
$this
->assertIdentical($formats[$format_id]
->get('name'), $name);
$this
->drupalGet('admin/config/content/formats');
$this
->assertText($name);
$node = $this
->createFormatAndNode('l o l', 0);
$this
->assertRaw('l o l');
$this
->drupalGet('node/' . $node
->id() . '/edit');
$this
->assertText(t('All non-breaking space HTML entities are replaced by blank space characters.'));
$this
->assertNoText(t('Multiple contiguous space characters are replaced by a single blank space character.'));
$node = $this
->createFormatAndNode('l o l', 1);
$this
->assertRaw('l o l');
$this
->drupalGet('node/' . $node
->id() . '/edit');
$this
->assertText(t('All non-breaking space HTML entities are replaced by blank space characters.'));
$this
->assertNoText(t('Multiple contiguous space characters are replaced by a single blank space character.'));
}
}