1 | <?php |
||
14 | abstract class EntityEmbedTestBase extends WebTestBase { |
||
15 | |||
16 | /** |
||
17 | * Modules to enable. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | public static $modules = ['entity_embed', 'entity_embed_test', 'node', 'ckeditor']; |
||
22 | |||
23 | /** |
||
24 | * The test user. |
||
25 | * |
||
26 | * @var \Drupal\user\UserInterface |
||
27 | */ |
||
28 | protected $webUser; |
||
29 | |||
30 | /** |
||
31 | * A test node to be used for embedding. |
||
32 | * |
||
33 | * @var \Drupal\node\NodeInterface |
||
34 | */ |
||
35 | protected $node; |
||
36 | |||
37 | /** |
||
38 | * |
||
39 | */ |
||
40 | protected function setUp() { |
||
41 | parent::setUp(); |
||
42 | |||
43 | // Create a page content type. |
||
44 | $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); |
||
45 | |||
46 | // Create a text format and enable the entity_embed filter. |
||
47 | $format = FilterFormat::create([ |
||
48 | 'format' => 'custom_format', |
||
49 | 'name' => 'Custom format', |
||
50 | 'filters' => [ |
||
51 | 'entity_embed' => [ |
||
52 | 'status' => 1, |
||
53 | ], |
||
54 | ], |
||
55 | ]); |
||
56 | $format->save(); |
||
57 | |||
58 | $editor_group = [ |
||
59 | 'name' => 'Entity Embed', |
||
60 | 'items' => [ |
||
61 | 'node', |
||
62 | ], |
||
63 | ]; |
||
64 | $editor = Editor::create([ |
||
65 | 'format' => 'custom_format', |
||
66 | 'editor' => 'ckeditor', |
||
67 | 'settings' => [ |
||
68 | 'toolbar' => [ |
||
69 | 'rows' => [[$editor_group]], |
||
70 | ], |
||
71 | ], |
||
72 | ]); |
||
73 | $editor->save(); |
||
74 | |||
75 | // Create a user with required permissions. |
||
76 | $this->webUser = $this->drupalCreateUser([ |
||
77 | 'access content', |
||
78 | 'create page content', |
||
79 | 'use text format custom_format', |
||
80 | ]); |
||
81 | $this->drupalLogin($this->webUser); |
||
82 | |||
83 | // Create a sample node to be embedded. |
||
84 | $settings = array(); |
||
85 | $settings['type'] = 'page'; |
||
86 | $settings['title'] = 'Embed Test Node'; |
||
87 | $settings['body'] = array('value' => 'This node is to be used for embedding in other nodes.', 'format' => 'custom_format'); |
||
88 | $this->node = $this->drupalCreateNode($settings); |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Retrieves a sample file of the specified type. |
||
93 | * |
||
94 | * @return \Drupal\file\FileInterface |
||
95 | */ |
||
96 | protected function getTestFile($type_name, $size = NULL) { |
||
108 | |||
109 | /** |
||
110 | * Assert that the expected display plugins are available for the entity. |
||
111 | */ |
||
112 | public function assertAvailableDisplayPlugins(EntityInterface $entity, array $expected_plugins, $message = '') { |
||
117 | |||
118 | } |
||
119 |