You are here

public function I18nBookNavigationTestBase::assertText in Book translation 7.2

Add the ability to assert a text is found a certain number of times.

Overrides DrupalWebTestCase::assertText

3 calls to I18nBookNavigationTestBase::assertText()
I18nBookNavigationTestBase::outlineTranslationBlockVisibleOnAllPages in tests/i18n_book_navigation.test
Test outline translation with the book block visible on ALL pages.
I18nBookNavigationTestBase::outlineTranslationBlockVisibleOnBookPages in tests/i18n_book_navigation.test
Test outline translation with the book block visible on only BOOK pages.
I18nBookNavigationTestCase::testIssue1619026 in tests/i18n_book_navigation.test
Regression test for [#1619026].

File

tests/i18n_book_navigation.test, line 32
Unit tests for the Book translation module.

Class

I18nBookNavigationTestBase
@file Unit tests for the Book translation module.

Code

public function assertText($text, $message = '', $num = 1, $group = 'Other') {
  if ($num === 1) {
    return parent::assertText($text, $message, $group);
  }
  else {
    $matches = array();
    $page_content = filter_xss(preg_replace('/<title>(.+)<\\/title>/', '', $this
      ->drupalGetContent()), array());
    return $this
      ->assert($num === preg_match_all("/({$text})/", $page_content, $matches), $message . " (found {$num} times)", $group);
  }
}