View source
<?php
namespace Drupal\Tests\freelinking\Functional;
use Drupal\Tests\BrowserTestBase;
abstract class FreelinkingBrowserTestBase extends BrowserTestBase {
public static $modules = [
'node',
'user',
'path',
'file',
'filter',
'search',
'freelinking',
];
protected $privilegedUser;
protected $defaultTheme = 'stable';
protected function setUp() : void {
parent::setUp();
$this
->createContentType([
'name' => 'Basic page',
'type' => 'page',
]);
$this->privilegedUser = $this
->createUser([
'access administration pages',
'access content',
'administer content types',
'administer filters',
'access user profiles',
'create page content',
'edit own page content',
]);
$this
->drupalLogin($this->privilegedUser);
$this
->drupalCreateNode([
'type' => 'page',
'title' => t('First page'),
]);
$this
->drupalCreateNode([
'type' => 'page',
'title' => t('Second page'),
]);
}
protected function updateFilterSettings($name = 'plain_text', array $edit = NULL) {
$label = str_replace('_', ' ', ucwords($name));
if (!isset($edit)) {
$edit = [
'filters[freelinking][status]' => 1,
'filters[freelinking][weight]' => 0,
'filters[freelinking][settings][plugins][nodetitle][enabled]' => 1,
'filters[freelinking][settings][plugins][external][enabled]' => 1,
'filters[freelinking][settings][plugins][external][settings][scrape]' => 0,
'filters[freelinking][settings][plugins][file][enabled]' => 1,
'filters[freelinking][settings][plugins][file][settings][scheme]' => 'public',
'filters[freelinking][settings][plugins][drupalorg][enabled]' => 1,
'filters[freelinking][settings][plugins][drupalorg][settings][scrape]' => 0,
'filters[freelinking][settings][plugins][drupalorg][settings][node]' => 1,
'filters[freelinking][settings][plugins][drupalorg][settings][project]' => 1,
'filters[freelinking][settings][plugins][google][enabled]' => 1,
'filters[freelinking][settings][plugins][nid][enabled]' => 1,
'filters[freelinking][settings][plugins][path_alias][enabled]' => 1,
'filters[freelinking][settings][plugins][search][enabled]' => 1,
'filters[freelinking][settings][plugins][user][enabled]' => 1,
'filters[freelinking][settings][plugins][wiki][enabled]' => 1,
'filters[filter_url][weight]' => 1,
'filters[filter_html][weight]' => 2,
'filters[filter_autop][weight]' => 3,
'filters[filter_htmlcorrector][weight]' => 4,
];
}
$this
->drupalGet('admin/config/content/formats/manage/' . $name);
$this
->submitForm($edit, 'Save configuration');
$this
->assertSession()
->pageTextContains(t('The text format @label has been updated.', [
'@label' => $label,
]));
$this
->drupalGet('admin/config/content/formats/manage/' . $name);
$this
->assertSession()
->checkboxChecked('edit-filters-freelinking-status');
}
}