You are here

function CommerceRecurringEnableDisableTestCase::assertCommerceRecurringFields in Commerce Recurring Framework 7.2

Assert the list of fields exist or not.

Parameters

$fields: Field list to check.

entity_type: Entity type.

$bundle: Bundle.

$exist: Boolean to check for the existance of the field.

3 calls to CommerceRecurringEnableDisableTestCase::assertCommerceRecurringFields()
CommerceRecurringEnableDisableTestCase::testCommerceRecurringDisable in tests/commerce_recurring.test
Test if the module can be correctly disabled.
CommerceRecurringEnableDisableTestCase::testCommerceRecurringDisableUninstall in tests/commerce_recurring.test
Test if the module can be correctly uninstalled.
CommerceRecurringEnableDisableTestCase::testCommerceRecurringEnable in tests/commerce_recurring.test
Test if the module has been correctly enabled.

File

tests/commerce_recurring.test, line 872
Unit tests for the commerce recurring module.

Class

CommerceRecurringEnableDisableTestCase
Test module enabling/disabling functionality.

Code

function assertCommerceRecurringFields(array $fields, $entity_type, $bundle, $exist) {
  field_info_cache_clear();
  $instances = field_info_instances($entity_type, $bundle);
  foreach ($fields as $field) {
    if ($exist) {
      $message = 'Field "@field" does exist.';
    }
    else {
      $message = 'Field "@field" does not exist.';
    }
    $info_field = field_info_field($field);
    $field_exist = !empty($info_field) && !empty($instances[$field]);
    $this
      ->assertEqual($field_exist, $exist, t($message, array(
      '@field' => $field,
    )));
  }
}