EntityBrowserUpdateHookTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 9.4285
1
<?php
2
3
namespace Drupal\entity_browser\Tests;
4
5
use Drupal\system\Tests\Update\UpdatePathTestBase;
6
7
/**
8
 * Tests the update hooks in entity_browser module.
9
 *
10
 * @group entity_browser
11
 */
12
class EntityBrowserUpdateHookTest extends UpdatePathTestBase {
13
14
  /**
15
   * Set database dump files to be used.
16
   */
17
  protected function setDatabaseDumpFiles() {
18
    $this->databaseDumpFiles = [
19
      DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
20
      __DIR__ . '/../../tests/fixtures/update/entity_browser.update-hook-test.php',
21
    ];
22
  }
23
24
  /**
25
   * {@inheritdoc}
26
   */
27
  protected function setUp() {
28
    parent::setUp();
29
    $entity_browser_type = $this->container
30
      ->get('entity_type.manager')
31
      ->getDefinition('entity_browser');
32
33
    $this->container
34
      ->get('entity.last_installed_schema.repository')
35
      ->setLastInstalledDefinition($entity_browser_type);
36
  }
37
38
  /**
39
   * {@inheritdoc}
40
   */
41
  protected function doSelectionTest() {
42
    parent::doSelectionTest();
43
    $this->assertRaw('8001 -   Updates submit text for existing Entity browsers.');
44
    $this->assertRaw('8002 -   Migrates duplicated Views entity_browser_select fields.');
45
  }
46
47
  /**
48
   * Tests entity_browser_update_8001().
49
   */
50
  public function testSubmitTextUpdate() {
51
    $this->runUpdates();
52
    $browser = $this->container->get('config.factory')
53
      ->get('entity_browser.browser.test_update');
54
55
    $this->assertNull($browser->get('submit_text'), 'Old submit text is gone');
56
    $this->assertEqual($browser->get('widgets.a4ad947c-9669-497c-9988-24351955a02f.settings.submit_text'), 'All animals are created equal','New submit text appears on the widget.');
57
  }
58
59
  /**
60
   * Tests entity_browser_update_8002().
61
   */
62
  public function testViewsFieldUpdate() {
63
    $this->runUpdates();
64
    $view = $this->container->get('config.factory')
65
      ->get('views.view.test_deprecated_field');
66
67
    $this->assertEqual($view->get('display.default.display_options.fields.entity_browser_select.table'), 'node', 'Data table in "entity_browser_select" replaced with data field.');
68
  }
69
70
}
71