protected function TestHelperTrait::assertStringPosition in Facets 8
Asserts that a string is found before another string in the source.
This uses the simpletest's getRawContent method to search in the source of the page for the position of 2 strings and that the first argument is before the second argument's position.
Parameters
string $x: A string.
string $y: Another string.
7 calls to TestHelperTrait::assertStringPosition()
- HierarchicalFacetIntegrationTest::testHierarchySorting in tests/
src/ Functional/ HierarchicalFacetIntegrationTest.php - Tests sorting of hierarchy.
- HierarchicalFacetIntegrationTest::testWeightSort in tests/
src/ Functional/ HierarchicalFacetIntegrationTest.php - Tests sorting by weight of a taxonomy term.
- ProcessorIntegrationTest::checkSortByActive in tests/
src/ Functional/ ProcessorIntegrationTest.php - Tests the active widget order.
- ProcessorIntegrationTest::checkSortByCount in tests/
src/ Functional/ ProcessorIntegrationTest.php - Tests the active widget order.
- ProcessorIntegrationTest::checkSortByDisplay in tests/
src/ Functional/ ProcessorIntegrationTest.php - Tests the display order.
File
- tests/
src/ Functional/ TestHelperTrait.php, line 98
Class
- TestHelperTrait
- Adds helpers for test methods.
Namespace
Drupal\Tests\facets\FunctionalCode
protected function assertStringPosition($x, $y) {
$this
->assertSession()
->pageTextContains($x);
$this
->assertSession()
->pageTextContains($y);
$x_position = strpos($this
->getTextContent(), $x);
$y_position = strpos($this
->getTextContent(), $y);
$message = new FormattableMarkup('Assert that %x is before %y in the source', [
'%x' => $x,
'%y' => $y,
]);
$this
->assertTrue($x_position < $y_position, $message);
}