5a0174a65a56691323b95613cb47dec4c55deae4
[yaffs-website] / web / core / modules / filter / tests / src / Functional / Rest / FilterFormatResourceTestBase.php
1 <?php
2
3 namespace Drupal\Tests\filter\Functional\Rest;
4
5 use Drupal\filter\Entity\FilterFormat;
6 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
7
8 abstract class FilterFormatResourceTestBase extends EntityResourceTestBase {
9
10   /**
11    * {@inheritdoc}
12    */
13   public static $modules = [];
14
15   /**
16    * {@inheritdoc}
17    */
18   protected static $entityTypeId = 'filter_format';
19
20   /**
21    * @var \Drupal\filter\FilterFormatInterface
22    */
23   protected $entity;
24
25   /**
26    * {@inheritdoc}
27    */
28   protected function setUpAuthorization($method) {
29     $this->grantPermissionsToTestedRole(['administer filters']);
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   protected function createEntity() {
36     $pablo_format = FilterFormat::create([
37       'name' => 'Pablo Piccasso',
38       'format' => 'pablo',
39       'langcode' => 'es',
40       'filters' => [
41         'filter_html' => [
42           'status' => TRUE,
43           'settings' => [
44             'allowed_html' => '<p> <a> <b> <lo>',
45           ],
46         ],
47       ],
48     ]);
49     $pablo_format->save();
50     return $pablo_format;
51   }
52
53   /**
54    * {@inheritdoc}
55    */
56   protected function getExpectedNormalizedEntity() {
57     return [
58       'dependencies' => [],
59       'filters' => [
60         'filter_html' => [
61           'id' => 'filter_html',
62           'provider' => 'filter',
63           'status' => TRUE,
64           'weight' => -10,
65           'settings' => [
66             'allowed_html' => '<p> <a> <b> <lo>',
67             'filter_html_help' => TRUE,
68             'filter_html_nofollow' => FALSE,
69           ],
70         ],
71       ],
72       'format' => 'pablo',
73       'langcode' => 'es',
74       'name' => 'Pablo Piccasso',
75       'status' => TRUE,
76       'uuid' => $this->entity->uuid(),
77       'weight' => 0,
78     ];
79   }
80
81   /**
82    * {@inheritdoc}
83    */
84   protected function getNormalizedPostEntity() {
85     // @todo Update in https://www.drupal.org/node/2300677.
86   }
87
88 }