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