Completed
Push — 8.x-1.x ( 77e186...f7c112 )
by Janez
03:35
created

MultistepDisplayTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 66
rs 10
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
B testMultistepDisplay() 0 44 1
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
      'submit_text' => 'Select',
46
    ];
47
    $this->drupalPostForm(NULL, $edit, 'Next');
48
    $this->drupalPostForm(NULL, [], 'Next');
49
    $this->drupalPostForm(NULL, [], 'Next');
50
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
      'select_text' => 'Use blah selected',
56
    ];
57
    $this->drupalPostForm(NULL, $edit, 'Next');
58
    $this->drupalPostAjaxForm(NULL, ['widget' => 'upload'], 'widget');
59
    $this->drupalPostForm(NULL, [], 'Finish');
60
61
    $account = $this->drupalCreateUser([
62
      'access test_entity_browser entity browser pages',
63
    ]);
64
    $this->drupalLogin($account);
65
    // Go to the entity browser iframe link.
66
    $this->drupalGet('/entity-browser/iframe/test_entity_browser');
67
    $this->assertNoRaw('Use blah selected');
68
69
    $image = current($this->drupalGetTestFiles('image'));
70
    $edit = [
71
      'files[upload][]' => $this->container->get('file_system')->realpath($image->uri),
72
    ];
73
    $this->drupalPostForm(NULL, $edit, 'Select');
74
    $this->assertRaw('Use blah selected', 'Select button is displayed if something is selected.');
75
  }
76
77
}
78