You are here

protected function CommerceFreeShippingTestProcess::enableFailingFreeShippingRules in Commerce Free Shipping 7

Enable free shipping rules and add a default conditions that fail.

1 call to CommerceFreeShippingTestProcess::enableFailingFreeShippingRules()
CommerceFreeShippingTestProcess::testCommerceFreeShippingWithFailingRulesConditionsCheckoutAuthenticatedUser in tests/commerce_free_shipping.test
Test the checkout process with a rules condition for free shipping that failed using an authenticated user.

File

tests/commerce_free_shipping.test, line 112
Functional tests for the commerce free shipping module.

Class

CommerceFreeShippingTestProcess
Test checkout process.

Code

protected function enableFailingFreeShippingRules() {

  // Loop over every shipping method and define a rule to let user
  // add condition for free shipping.
  $shipping_services = commerce_shipping_services();
  foreach ($shipping_services as $service) {
    $base = $service['base'];

    // Set rules for this service.
    variable_set($base . '_free_shipping_additionnal_rules', TRUE);

    // Create a new condition set.
    // See rules doc: https://drupal.org/node/905262 for tips.
    $condition_set = rules_and(commerce_free_shipping_service_component_variables());
    $condition_set->label = t('Free shipping conditions for: @title', array(
      '@title' => $service['display_title'],
    ));
    $condition_set->active = TRUE;
    $condition_set->tags = array(
      'Commerce free shipping',
    );
    $condition_set
      ->condition('data_is', array(
      'data:select' => 'commerce-order:type',
      'op' => '==',
      'value' => 'commerce_order',
    ))
      ->negate();
    $condition_set
      ->save('commerce_free_shipping_service_' . $base);
  }
  rules_clear_cache();
}