-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ACMS-4237: Add Filter Format test in Common module.
- Loading branch information
1 parent
c4df617
commit 8d32ce5
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
modules/acquia_cms_common/tests/src/Functional/FilterFormatTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\acquia_cms_common\Functional; | ||
|
||
use Drupal\Tests\BrowserTestBase; | ||
|
||
/** | ||
* Tests the filter filter_html. | ||
* | ||
* @group acquia_cms | ||
* @group acquia_cms_common | ||
*/ | ||
class FilterFormatTest extends BrowserTestBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $defaultTheme = 'stark'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected static $modules = [ | ||
'acquia_cms_common', | ||
]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function setUp(): void { | ||
parent::setUp(); | ||
|
||
$account = $this->drupalCreateUser(['administer filters']); | ||
$this->drupalLogin($account); | ||
} | ||
|
||
/** | ||
* Tests the filter filter_html. | ||
* | ||
* @param string $filter_format | ||
* The filter format name. | ||
* @param bool $status | ||
* Status of the field. | ||
* | ||
* @dataProvider providerFilterFormat | ||
*/ | ||
public function testFilterBlackListHtmlTags(string $filter_format, bool $status) { | ||
$assert_session = $this->assertSession(); | ||
|
||
// Visit the filter page. | ||
$this->drupalGet('/admin/config/content/formats/manage/' . $filter_format); | ||
$assert_session->statusCodeEquals(200); | ||
$filter_element = $assert_session->elementExists('css', '#edit-filters-filter-html-status'); | ||
$this->assertSame($status, $filter_element->isChecked(), 'Expect checked, but found uncheck.'); | ||
|
||
} | ||
|
||
/** | ||
* Defines an array of modules & permissions to roles. | ||
*/ | ||
public static function providerFilterFormat(): array { | ||
return [ | ||
[ | ||
'full_html', | ||
TRUE, | ||
], | ||
[ | ||
'filtered_html', | ||
TRUE, | ||
], | ||
]; | ||
} | ||
|
||
} |