You are here

function RadioactivityNodeTestCase::testNodeApi_load in Radioactivity 6

Tests that radioactivity_node nodeapi works as it should, i.e., when we do node load, we don't have, e.g., missing require_onces.

File

plugins/radioactivity_node.test, line 34

Class

RadioactivityNodeTestCase

Code

function testNodeApi_load() {

  // add some default stuff for node id 123
  db_query("INSERT INTO {radioactivity} (id, class, decay_profile, energy, last_emission_timestamp) " . "VALUES (%d, '%s', %d, %f, %d)", 123, 'node', 3, 88.5, 13131313);
  db_query("INSERT INTO {radioactivity} (id, class, decay_profile, energy, last_emission_timestamp) " . "VALUES (%d, '%s', %d, %f, %d)", 123, 'node', 2, 17, 31313131);

  // these are to make sure that only node id 123 is considered
  foreach (array(
    '122',
    '124',
  ) as $nid) {
    db_query("INSERT INTO {radioactivity} (id, class, decay_profile, energy, last_emission_timestamp) " . "VALUES (%d, '%s', %d, %f, %d)", $nid, 'node', 2, 1.23, 111);
  }
  $node = new stdClass();
  $node->nid = 123;
  $nodeapi_ret = radioactivity_node_nodeapi($node, 'load');
  $this
    ->assertTrue(isset($nodeapi_ret['radioactivity']), t('radioactivity_node_nodeapi() has radioactivity field'));
  $this
    ->assertEqual($nodeapi_ret['radioactivity']['energy'][2], 17, t('Proper energy for profile 2'));
  $this
    ->assertEqual($nodeapi_ret['radioactivity']['energy'][3], 88.5, t('Proper energy for profile 3'));
}