FieldFormatterTest.php in No Non-breaking Space Filter 8
File
src/Tests/FieldFormatterTest.php
View source
<?php
namespace Drupal\no_nbsp\Tests;
class FieldFormatterTest extends NoNbspWebTestBase {
public static $modules = [
'field_ui',
'no_nbsp',
];
protected $profile = 'minimal';
public function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
$this->user = $this
->drupalCreateUser([
'administer filters',
'create page content',
'administer content types',
'administer node fields',
'administer node display',
]);
$this
->drupalLogin($this->user);
}
public function testFieldFormatter() {
$this
->createTextFormatWeb('with_no_nbsp', TRUE);
$this
->createTextFormatWeb('without_no_nbsp', FALSE);
$this
->drupalGet('admin/structure/types/manage/page/display');
$this
->assertText(t('No Non-breaking Space Filter'));
$edit = [];
$title = $this
->randomMachineName();
$edit['title[0][value]'] = $title;
$edit['body[0][value]'] = 'l o l';
$edit['body[0][format]'] = 'without_no_nbsp';
$this
->drupalPostForm('node/add/page', $edit, t('Save'));
$node = $this
->drupalGetNodeByTitle($title);
$this
->assertRaw('l o l');
$edit = [
'fields[body][type]' => 'no_nbsp',
];
$this
->drupalPostForm('admin/structure/types/manage/page/display', $edit, t('Save'));
$this
->drupalGet('node/' . $node
->id());
$this
->assertRaw('l o l');
}
}