View source
<?php
namespace Drupal\Tests\xbbcode\Kernel;
use Drupal\filter\Entity\FilterFormat;
use Drupal\KernelTests\KernelTestBase;
use Drupal\user\RoleInterface;
class XBBCodeDefaultConfigTest extends KernelTestBase {
public static $modules = [
'system',
'user',
'filter',
'xbbcode',
];
protected function setUp() : void {
parent::setUp();
$this
->installConfig([
'user',
'xbbcode',
]);
}
public function testInstallation() : void {
$format = FilterFormat::load('xbbcode');
self::assertNotNull($format);
self::assertEquals('BBCode', $format
->label());
self::assertEquals(-5, $format
->get('weight'));
self::assertEquals([
RoleInterface::ANONYMOUS_ID,
RoleInterface::AUTHENTICATED_ID,
], array_keys(filter_get_roles_by_format($format)));
self::assertEquals([
'module' => [
'xbbcode',
],
'enforced' => [
'module' => [
'xbbcode',
],
],
], $format
->get('dependencies'));
$filters = $format
->get('filters');
self::assertEquals(1, $filters['filter_html_escape']['status']);
self::assertEquals(0, $filters['filter_html_escape']['weight']);
self::assertEquals('filter', $filters['filter_html_escape']['provider']);
self::assertEquals([], $filters['filter_html_escape']['settings']);
self::assertEquals(1, $filters['xbbcode']['status']);
self::assertEquals(1, $filters['xbbcode']['weight']);
self::assertEquals('xbbcode', $filters['xbbcode']['provider']);
self::assertEquals([
'linebreaks' => TRUE,
'tags' => '',
'xss' => TRUE,
], $filters['xbbcode']['settings']);
self::assertEquals(1, $filters['filter_url']['status']);
self::assertEquals(2, $filters['filter_url']['weight']);
self::assertEquals('filter', $filters['filter_url']['provider']);
self::assertEquals([
'filter_url_length' => 72,
], $filters['filter_url']['settings']);
self::assertEquals(1, $filters['filter_htmlcorrector']['status']);
self::assertEquals(3, $filters['filter_htmlcorrector']['weight']);
self::assertEquals('filter', $filters['filter_htmlcorrector']['provider']);
self::assertEquals([], $filters['filter_htmlcorrector']['settings']);
}
}