You are here

function ContentTaxonomyTestCase::assertNodeMultiValues in Content Taxonomy 6.2

Same name and namespace in other branches
  1. 6 tests/content_taxonomy.test \ContentTaxonomyTestCase::assertNodeMultiValues()

helper assertion function, which checks if the node field array is built correctly

2 calls to ContentTaxonomyTestCase::assertNodeMultiValues()
ContentTaxonomyAutocompleteTest::testAutocomplete in tests/content_taxonomy.test
ContentTaxonomyTest::testContentTaxonomySaving in tests/content_taxonomy.test

File

tests/content_taxonomy.test, line 46

Class

ContentTaxonomyTestCase
Base Class for testing Content Taxonomy extends the ContentCrudTestCase Class from CCK, which provides many useful helper functions

Code

function assertNodeMultiValues($node, $field_name, $terms_in = array(), $terms_out = array()) {
  $tids = array();
  if (is_array($node->{$field_name})) {
    foreach ($node->{$field_name} as $key => $value) {
      $tids[$value['value']] = $value['value'];
    }
  }
  foreach ($terms_in as $term) {
    $this
      ->assertTrue(in_array($term->tid, $tids), 'Term correctly in node field');
  }
  foreach ($terms_out as $term) {
    $this
      ->assertTrue(!in_array($term->tid, $tids), 'Term correctly in node field');
  }
}