892b279b700629316d339739efbf6d0425ab70a3
[yaffs-website] / web / core / modules / system / src / Tests / Update / FilterHtmlUpdateTest.php
1 <?php
2
3 namespace Drupal\system\Tests\Update;
4
5 use Drupal\filter\Entity\FilterFormat;
6
7 /**
8  * Tests that the allowed html configutations are updated with attributes.
9  *
10  * @group Entity
11  */
12 class FilterHtmlUpdateTest extends UpdatePathTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public function setDatabaseDumpFiles() {
18     $this->databaseDumpFiles = [
19       __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
20     ];
21   }
22
23   /**
24    * Tests system_update_8009().
25    */
26   public function testAllowedHtmlUpdate() {
27     // Make sure we have the expected values before the update.
28     $filters_before = [
29       'basic_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <h4> <h5> <h6> <p> <br> <span> <img>',
30       'restricted_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <h4> <h5> <h6>',
31     ];
32     foreach ($filters_before as $name => $before) {
33       $config = FilterFormat::load($name)->toArray();
34       $this->assertIdentical($before, $config['filters']['filter_html']['settings']['allowed_html']);
35     }
36
37     $this->runUpdates();
38
39     // Make sure we have the expected values after the update.
40     $filters_after = [
41       'basic_html' => '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h4 id> <h5 id> <h6 id> <p> <br> <span> <img src alt height width data-align data-caption>',
42       'restricted_html' => '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h4 id> <h5 id> <h6 id>',
43     ];
44     foreach ($filters_after as $name => $after) {
45       $config = FilterFormat::load($name)->toArray();
46       $this->assertIdentical($after, $config['filters']['filter_html']['settings']['allowed_html']);
47     }
48   }
49
50 }