protected function Drupali18nSyncNodeReferenceTestCase::assertPageReferencesNodes in i18n node reference synch 7
Asserts that the page references the articles.
Parameters
int $page_nid: Nid of the page that contains the references.
array $referenced_nids: Nids of the articles that should be referenced.
string $message: Message to be shown in assertions.
1 call to Drupali18nSyncNodeReferenceTestCase::assertPageReferencesNodes()
- Drupali18nSyncNodeReferenceTestCase::testI18nSyncNodeReference in ./
i18n_node_reference.test - Full test for node synchronization.
File
- ./
i18n_node_reference.test, line 191 - Test node reference field synchronization.
Class
- Drupali18nSyncNodeReferenceTestCase
- Unit test for node reference field synchronisation.
Code
protected function assertPageReferencesNodes($page_nid, $referenced_nids, $message) {
$real_articles_nids = $this
->getReferencedNodes($page_nid);
foreach ($referenced_nids as $article_nid) {
$this
->assertTrue(in_array($article_nid, $real_articles_nids), $message . t(': Page @page_nid references node @article_nid.', array(
'@page_nid' => $page_nid,
'@article_nid' => $article_nid,
)));
}
$diff = array_diff($real_articles_nids, $referenced_nids);
$this
->assertTrue(count($real_articles_nids) == count($referenced_nids) && empty($diff), $message . t(': Page references no unexpected nodes, but found @diff.', array(
'diff' => implode(',', $diff),
)));
}