You are here

public function OgAdminMembersViewTest::testMembersTable in Organic groups 8

Tests the Members table.

File

tests/src/Kernel/Views/OgAdminMembersViewTest.php, line 128

Class

OgAdminMembersViewTest
Tests the OG admin Members view.

Namespace

Drupal\Tests\og\Kernel\Views

Code

public function testMembersTable() {

  /** @var \Drupal\Core\Render\RendererInterface $renderer */
  $renderer = $this->container
    ->get('renderer');
  $view = Views::getView('og_members_overview');
  $preview = $view
    ->preview('default', [
    'node',
    $this->group
      ->id(),
  ]);
  $this
    ->setRawContent($renderer
    ->renderRoot($preview));
  $map = [
    // Validate header.
    'Name' => '//*[@id="view-name-table-column"]/a/text()',
    'Member since' => '//*[@id="view-created-table-column"]',
    'State' => '//*[@id="view-state-table-column"]',
    // Validate the user appears.
    $this->user
      ->label() => '//*/tbody/tr/td[2]/span/text()',
    // Validate that the user has the bulk operation checkbox.
    'Update the member' => '//td[contains(@class, \'views-field-og-membership-bulk-form\')]/div/label',
  ];
  foreach ($map as $value => $xpath) {
    $result = $this
      ->xpath($xpath);
    $this
      ->assertTrue(strpos(trim((string) $result[0]), $value) === 0);
  }
}