You are here

protected function TaxonomyAccessFixTestTrait::assertElementByCssSelector in Taxonomy access fix 8.2

Same name and namespace in other branches
  1. 8.3 tests/src/Traits/TaxonomyAccessFixTestTrait.php \Drupal\Tests\taxonomy_access_fix\Traits\TaxonomyAccessFixTestTrait::assertElementByCssSelector()

Passes if an element matching the specified CSS selector is found.

An optional element index may be passed.

Parameters

string $selector: CSS selector of element.

int $index: Element position counting from zero.

string $message: (optional) A message to display with the assertion. Do not translate messages: use strtr() to embed variables in the message text, not t(). If left blank, a default message will be displayed.

Return value

bool TRUE if the assertion succeeded, FALSE otherwise.

2 calls to TaxonomyAccessFixTestTrait::assertElementByCssSelector()
TaxonomyAccessFixTestTrait::assertSortableTable in tests/src/Traits/TaxonomyAccessFixTestTrait.php
Asserts that the page contains a sortable taxonomy term table.
VocabularyAccessTest::testTaxonomyVocabularyOverview in tests/src/Functional/VocabularyAccessTest.php
Tests access to Taxonomy Vocabulary overview page.

File

tests/src/Traits/TaxonomyAccessFixTestTrait.php, line 29

Class

TaxonomyAccessFixTestTrait
Provides common methods for functional tests of Taxonomy Access Fix module.

Namespace

Drupal\Tests\taxonomy_access_fix\Traits

Code

protected function assertElementByCssSelector($selector, $index = 0, $message = '') {
  $elements = $this
    ->cssSelect($selector);
  $message = $message ? $message : new FormattableMarkup('Element with CSS selector %selector found.', [
    '%selector' => $selector,
  ]);
  return $this
    ->assertTrue(isset($elements[$index]), $message);
}