You are here

function SharerichTest::testAdminUI in Sharerich 7.2

Same name and namespace in other branches
  1. 7.3 tests/sharerich.test \SharerichTest::testAdminUI()

Admin UI.

File

tests/sharerich.test, line 109

Class

SharerichTest
Sharerich tests.

Code

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

  // Test that the imported set is correct.
  $element = $this
    ->xpath('//input[@type="text" and @id="edit-name" and @value="Default set"]');
  $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, t('The :item is checked.', array(
      ':item' => ucfirst($item),
    )));
    $actual = (string) $this
      ->xpath('//textarea[@name="sharerich_custom_' . $item . '"]/text()')[0];

    // Normalize strings.
    $actual = preg_replace('/(\\r\\n|\\r|\\n|\\s|\\t)/s', " ", $actual);
    $expected = sharerich_load_service($item);
    $expected = preg_replace('/(\\r\\n|\\r|\\n|\\s|\\t)/s', " ", $expected);
    $this
      ->assertTrue($actual == $expected, t('The :item widget is correct.', array(
      ':item' => ucfirst($item),
    )));
  }
}