You are here

protected function UcAddressesEntityCase::assertEntityHookInvoked in Ubercart Addresses 7

Asserts if a certain hook is invoked.

Parameters

string $hook: The hook that was invoked.

object $entity: The entity that was passed with the hook.

Return value

void

2 calls to UcAddressesEntityCase::assertEntityHookInvoked()
UcAddressesEntityCase::testEntityCrud in tests/uc_addresses.entity.test
Test Ubercart Addresses Entity CRUD.
UcAddressesEntityCase::testHooks in tests/uc_addresses.entity.test
Test if entity hooks are invoked when using the address book API.

File

tests/uc_addresses.entity.test, line 550
Test cases address entity.

Class

UcAddressesEntityCase
Tests for Entity API integration.

Code

protected function assertEntityHookInvoked($hook, $entity_id, $message = NULL) {
  if (is_null($message)) {
    $message = t('The hook %hook was invoked upon an uc_addresses entity with id %id', array(
      '%hook' => $hook . '()',
      '%id' => $entity_id,
    ));
  }

  // We can not use variable_get() here, because that returns the
  // on runtime cached variables.
  $serialized_value = db_select('variable')
    ->fields('variable', array(
    'value',
  ))
    ->condition('name', 'uc_addresses_' . $hook)
    ->execute()
    ->fetchField();
  if (!$serialized_value) {
    $this
      ->fail($message);
    return;
  }
  $value = unserialize($serialized_value);
  $this
    ->verbose($value);
  $this
    ->assertEqual($value, $entity_id, $message);
}