Version 1
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Render / Element / ActionsTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Render\Element;
4
5 use Drupal\Core\Form\FormInterface;
6 use Drupal\Core\Form\FormStateInterface;
7 use Drupal\KernelTests\KernelTestBase;
8
9 /**
10  * @coversDefaultClass \Drupal\Core\Render\Element\Actions
11  * @group Render
12  */
13 class ActionsTest extends KernelTestBase implements FormInterface {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['system'];
19
20   /**
21    * {@inheritdoc}
22    */
23   public function getFormId() {
24   }
25
26   /**
27    * {@inheritdoc}
28    */
29   public function buildForm(array $form, FormStateInterface $form_state) {
30     $form['actions'] = ['#type' => 'actions'];
31     $form['actions']['key'] = [
32       '#type' => 'submit',
33       '#value' => 'Key',
34       '#dropbutton' => 'submit',
35       '#cache' => [
36         'tags' => ['foo'],
37       ],
38       '#attached' => [
39         'library' => [
40           'system/base',
41         ],
42       ],
43     ];
44     $form['actions']['submit'] = [
45       '#type' => 'submit',
46       '#value' => 'Save',
47     ];
48     return $form;
49   }
50
51   /**
52    * {@inheritdoc}
53    */
54   public function validateForm(array &$form, FormStateInterface $form_state) {
55   }
56
57   /**
58    * {@inheritdoc}
59    */
60   public function submitForm(array &$form, FormStateInterface $form_state) {
61   }
62
63   public function testDropbuttonWithBubbleableMetadata() {
64     $result = \Drupal::formBuilder()->getForm($this);
65     \Drupal::service('renderer')->renderRoot($result);
66     $this->assertEquals(['system/base', 'core/drupal.dropbutton'], $result['#attached']['library']);
67     $this->assertEquals(['foo'], $result['#cache']['tags']);
68   }
69
70 }