- <?php
- * @file
- * Test case for Testing the filter example module.
- *
- * This file contains the test cases to check if module is performing as
- * expected.
- */
-
- * Functional tests for the Filter Example module.
- *
- * @ingroup filter_example
- */
-
- class FilterExampleTestCase extends BackdropWebTestCase {
- protected $webUser;
- protected $filteredHtml;
- protected $fullHtml;
-
-
- * Enable modules and create user with specific permissions.
- */
- public function setUp() {
- parent::setUp('filter_example');
-
-
-
-
- $this->filteredHtml = (object) config_get('filter.format.filtered_html');
- $this->fullHtml = (object) config_get('filter.format.full_html');
-
-
- $this->webUser = $this->backdropCreateUser(array(
- 'administer filters',
- filter_permission_name($this->filteredHtml),
- filter_permission_name($this->fullHtml),
- 'bypass node access',
- ));
- }
-
-
- * Functional test of the foo filter.
- *
- * Login user, create an example node, and test blog functionality through
- * the admin and user interfaces.
- */
- public function testFilterExampleBasic() {
-
- $this->backdropLogin($this->webUser);
-
-
- $edit = array(
- 'filters[filter_time][status]' => TRUE,
- 'filters[filter_foo][status]' => TRUE,
- );
- $this->backdropPost('admin/config/content/formats/' . $this->filteredHtml->format, $edit, t('Save configuration'));
-
-
- $content_type = $this->backdropCreateContentType();
-
-
- $langcode = LANGUAGE_NONE;
- $edit = array(
- "title" => $this->randomName(),
- "body[$langcode][0][value]" => 'What foo is it? it is <time />',
- );
- $result = $this->backdropPost('node/add/' . $content_type->type, $edit, t('Save'));
- $this->assertResponse(200);
- $time = format_date(time(), 'medium', '', 'Europe/London');
- $this->assertRaw('What bar is it? it is <em>' . $time . '</em>');
-
-
- $edit = array(
- 'filters[filter_foo][status]' => TRUE,
- );
- $this->backdropPost('admin/config/content/formats/' . $this->fullHtml->format, $edit, t('Save configuration'));
-
-
- $replacement = $this->randomName();
- $options = array(
- 'filters[filter_foo][settings][filter_example_foo]' => $replacement,
- );
- $this->backdropPost('admin/config/content/formats/' . $this->fullHtml->format, $options, t('Save configuration'));
-
-
- $langcode = LANGUAGE_NONE;
- $edit = array(
- "title" => $this->randomName(),
- "body[$langcode][0][value]" => 'What foo is it? it is <time />',
- "body[$langcode][0][format]" => $this->fullHtml->format,
- );
- $result = $this->backdropPost('node/add/' . $content_type->type, $edit, t('Save'));
- $this->assertResponse(200);
-
-
- $this->assertRaw("What " . $replacement . " is it", 'Foo filter successfully verified.');
- }
- }