public function MetatagTestBase::searchTranslationPage in Metatag 7
Check the translation page for a specific string.
Parameters
string $string: The source string to search for.
string $context: The i18n string context to check for.
bool $assert_true: By default strings are expeted to be found. If the string is not expected to be translatable yet then pass in FALSE.
15 calls to MetatagTestBase::searchTranslationPage()
- MetatagContextWithI18nTest::testExportedContext in metatag_context/
tests/ MetatagContextWithI18nTest.test - Test the Metatag:Context translations for an exported configuration.
- MetatagCoreNodeWithI18nTest::testI18nNodeConfig in tests/
MetatagCoreNodeWithI18nTest.test - Test translations of the main node configuration.
- MetatagCoreNodeWithI18nTest::testI18nNodePageConfig in tests/
MetatagCoreNodeWithI18nTest.test - Test translations of the 'page' content type configuration.
- MetatagCoreTermWithI18nTest::testI18nTermConfig in tests/
MetatagCoreTermWithI18nTest.test - Test translations of the main taxonomy term configuration.
- MetatagCoreTermWithI18nTest::testI18nTermTagsConfig in tests/
MetatagCoreTermWithI18nTest.test - Test translations of the 'tags' vocabulary configuration.
File
- tests/
MetatagTestBase.test, line 666 - A base class for the Metatag tests, provides shared methods.
Class
- MetatagTestBase
- A base class for the Metatag tests, provides shared methods.
Code
public function searchTranslationPage($string, $context, $assert_true = TRUE) {
// Load the translation page.
$search = array(
'string' => $string,
'language' => 'all',
'translation' => 'all',
'group' => 'metatag',
);
$this
->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this
->assertResponse(200, 'Loaded the translation admin page.');
// Confirm there are strings to translate.
$xpath = $this
->xpath("//body//div[@class='content']//table//tbody//tr");
$count = count($xpath);
// If the string is expected, then confirm that there are strings to be
// found.
if ($assert_true) {
$this
->assertTrue($count >= 1, 'Found Metatag strings to translate.');
$this
->assertNoText(t('No strings available.'));
$xpath = $this
->xpath("//body//div[@class='content']//table//tbody//tr");
$this
->verbose("Found {$count} items to translate.");
if (!empty($string)) {
$this
->assertText($context);
$this
->assertText('metatag:' . $context);
}
}
else {
$this
->assertNoText($context);
$this
->assertNoText('metatag:' . $context);
}
}