You are here

function SharerichTests::testAdminUI in Sharerich 8

Admin UI.

File

tests/src/Functional/SharerichTests.php, line 104

Class

SharerichTests
Sharerich tests.

Namespace

Drupal\Tests\sharerich\Functional

Code

function testAdminUI() {
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/structure/sharerich/default');

  // Test that the imported set is correct.
  $element = $this
    ->xpath('//input[@type="text" and @id="edit-label" and @value="Default"]');
  $this
    ->assertTrue(count($element) === 1, 'The label is correct.');
  foreach ($this->services as $item) {

    // Assert that the checkboxes are ticked.
    $element = $this
      ->xpath('//input[@type="checkbox" and @name="services[' . $item . '][enabled]" and @checked="checked"]');
    $this
      ->assertTrue(count($element) === 1, $this
      ->t('The :item is checked.', [
      ':item' => ucfirst($item),
    ]));
    $actual = $this
      ->xpath('//textarea[@name="services[' . $item . '][markup]"]');
    $expected = $this
      ->xpath('//input[@type="hidden"][@name="services[' . $item . '][default_markup]"]/@value');

    // Normalize strings.
    $actual = preg_replace('/(\\r\\n|\\r|\\n|\\s|\\t)/s', "", $actual[0]
      ->getText());
    $expected = preg_replace('/(\\r\\n|\\r|\\n|\\s|\\t)/s', "", $expected[0]
      ->getText());
    $this
      ->assertEquals($actual, $expected, $this
      ->t('The :item widget is correct.', [
      ':item' => $item,
    ]));
  }
}