You are here

protected function UbercartAjaxTestCase::addPaymentZoneCondition in Ubercart 7.3

Set a zone-based condition for a particular payment method.

Parameters

$method: The method to set (e.g. 'check')

$zone: The zone id (numeric) to check for.

$negate: TRUE to negate the condition.

1 call to UbercartAjaxTestCase::addPaymentZoneCondition()
UbercartAjaxTestCase::testCheckoutAjax in uc_store/tests/uc_ajax.test

File

uc_store/tests/uc_ajax.test, line 42
Tests for the UcAddress class.

Class

UbercartAjaxTestCase
Tests for the Ubercart Ajax Attach.

Code

protected function addPaymentZoneCondition($method, $zone, $negate = FALSE) {
  $not = $negate ? 'NOT ' : '';
  $name = 'uc_payment_method_' . $method;
  $label = ucfirst($method) . ' conditions';
  $condition = array(
    'LABEL' => $label,
    'PLUGIN' => 'and',
    'REQUIRES' => array(
      'rules',
    ),
    'USES VARIABLES' => array(
      'order' => array(
        'label' => 'Order',
        'type' => 'uc_order',
      ),
    ),
    'AND' => array(
      array(
        $not . 'data_is' => array(
          'data' => array(
            'order:billing-address:zone',
          ),
          'value' => $zone,
        ),
      ),
    ),
  );
  $newconfig = rules_import(array(
    $name => $condition,
  ));
  $oldconfig = rules_config_load($name);
  if ($oldconfig) {
    $newconfig->id = $oldconfig->id;
    unset($newconfig->is_new);
    $newconfig->status = ENTITY_CUSTOM;
  }
  $newconfig
    ->save();
  entity_flush_caches();

  //$this->drupalGet('admin/config/workflow/rules/components/manage/' . $newconfig->id);
}