1d91a5d344f1593cc727471b8d5360fb17ccb08a
[yaffs-website] / Tests / MultistepDisplayTest.php
1 <?php
2
3 namespace Drupal\entity_browser\Tests;
4
5 use Drupal\simpletest\WebTestBase;
6
7 /**
8  * Tests the multistep display selection display.
9  *
10  * @group entity_browser
11  */
12 class MultistepDisplayTest extends WebTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['entity_browser', 'ctools', 'block', 'node', 'file'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp() {
25     parent::setUp();
26     $this->drupalPlaceBlock('local_actions_block');
27   }
28
29   /**
30    * Tests multistep display.
31    */
32   public function testMultistepDisplay() {
33     $account = $this->drupalCreateUser([
34       'administer entity browsers',
35     ]);
36     $this->drupalLogin($account);
37     $this->drupalGet('/admin/config/content/entity_browser');
38     $this->clickLink('Add Entity browser');
39     $edit = [
40       'label' => 'Test entity browser',
41       'id' => 'test_entity_browser',
42       'display' => 'iframe',
43       'widget_selector' => 'tabs',
44       'selection_display' => 'multi_step_display',
45     ];
46     $this->drupalPostForm(NULL, $edit, 'Next');
47     $this->drupalPostForm(NULL, [], 'Next');
48     $this->drupalPostForm(NULL, [], 'Next');
49
50     $this->assertText('Selection display', 'Trail is shown.');
51     $this->assertText('Select button text', 'Title is correct.');
52     $this->assertText('Text to display on the entity browser select button.', 'Description is correct.');
53     $this->assertRaw('Use selected', 'Default text is correct.');
54     $edit = [
55       'entity_type' => 'file',
56       'display' => 'label',
57       'selection_hidden' => 0,
58       'select_text' => 'Use blah selected',
59     ];
60     $this->drupalPostForm(NULL, $edit, 'Next');
61     $this->drupalPostAjaxForm(NULL, ['widget' => 'upload'], 'widget');
62     $this->drupalPostForm(NULL, [], 'Finish');
63
64     $account = $this->drupalCreateUser([
65       'access test_entity_browser entity browser pages',
66     ]);
67     $this->drupalLogin($account);
68     // Go to the entity browser iframe link.
69     $this->drupalGet('/entity-browser/iframe/test_entity_browser');
70     $this->assertNoRaw('Use blah selected');
71
72     $image = current($this->drupalGetTestFiles('image'));
73     $edit = [
74       'files[upload][]' => $this->container->get('file_system')->realpath($image->uri),
75     ];
76     $this->drupalPostForm(NULL, $edit, 'Select files');
77     $this->assertRaw('Use blah selected', 'Select button is displayed if something is selected.');
78   }
79
80 }