You are here

protected function SmsTrackArchiveTestCase::assertTextInXPath in SMS Framework 7

Asserts that some text exists in the current page following the given XPath.

Parameters

string $xpath: XPath used to find the text.

string $text: The text that is to be checked.

string $message: (optional) Message to display.

string $group: (optional) The group this message belongs to.

Return value

bool TRUE on pass, FALSE on fail.

1 call to SmsTrackArchiveTestCase::assertTextInXPath()
SmsTrackArchiveTestCase::testArchiveWriteForSentMessages in modules/sms_track/tests/sms_track.test
Tests recording a message sent from one site user to another.

File

modules/sms_track/tests/sms_track.test, line 176

Class

SmsTrackArchiveTestCase
Provides integration tests for the SMS Framework.

Code

protected function assertTextInXPath($xpath, $text, $message = NULL, $group = 'Other') {
  if (!$message) {
    $message = t('"@text" found', array(
      '@text' => $text,
    ));
  }

  /** @var SimpleXMLElement $xml_node */
  foreach ($this
    ->xpath($xpath) as $xml_node) {
    $xml = filter_xss($xml_node
      ->asXML(), array());
    if (strpos($xml, $text) !== FALSE) {
      return $this
        ->pass($message, $group);
    }
  }
  return $this
    ->fail($message, $group);
}