You are here

public function CommerceNodeCheckoutBaseTest::setUp in Commerce Node Checkout 7

Implementation of setUp().

Overrides DrupalWebTestCase::setUp

1 call to CommerceNodeCheckoutBaseTest::setUp()
CommerceNodeCheckoutExpireTests::setUp in commerce_node_checkout_expire/commerce_node_checkout_expire.test
Implementation of setUp().
1 method overrides CommerceNodeCheckoutBaseTest::setUp()
CommerceNodeCheckoutExpireTests::setUp in commerce_node_checkout_expire/commerce_node_checkout_expire.test
Implementation of setUp().

File

./commerce_node_checkout.test, line 20
Provides tests for Commerce Node Checkout process.

Class

CommerceNodeCheckoutBaseTest
Base class for other test classes to extend.

Code

public function setUp() {
  $modules = array(
    'entity',
    'entity_token',
    'rules',
    'addressfield',
    'ctools',
    'views',
    'field',
    'field_ui',
    'field_sql_storage',
    'commerce',
    'commerce_product',
    'commerce_price',
    'commerce_customer',
    'commerce_customer_ui',
    'commerce_line_item',
    'commerce_order',
    'commerce_product_reference',
    'commerce_tax',
    'commerce_product_pricing',
    'entityreference',
    'commerce_checkout',
    'commerce_cart',
    'commerce_product_ui',
    'commerce_node_checkout',
    'commerce_order_ui',
  );

  // See if modules were passed in
  $args = func_get_args();
  if (isset($args[0]) && is_array($args[0])) {
    $modules = array_merge($modules, $args[0]);
  }

  // General set up
  parent::setUp($modules);
  drupal_flush_all_caches();

  // Create our admin
  $this->admin = $this
    ->createAdmin();

  // Create a commerce_node_checkout for the listing.
  $new_product = commerce_product_new('commerce_node_checkout');
  $new_product->sku = 'std-listing';
  $new_product->title = 'Standard listing';

  // Admin user.
  $new_product->uid = 1;

  // Standard listing is 30 dollars.
  $new_product->commerce_price[LANGUAGE_NONE][0]['amount'] = 3000;
  $new_product->commerce_price[LANGUAGE_NONE][0]['currency_code'] = 'USD';

  // Save the product
  commerce_product_save($new_product);

  // Now associate standard listing with the content type.
  variable_set('commerce_node_checkout_products_page', array(
    $new_product->product_id,
  ));

  // Give anonymous and authenticated users the permissions they need
  foreach (array(
    DRUPAL_ANONYMOUS_RID,
    DRUPAL_AUTHENTICATED_RID,
  ) as $rid) {
    user_role_grant_permissions($rid, array(
      'create page content',
      'edit own page content',
      'view own unpublished content',
      'access checkout',
    ));
  }

  // Default pages to not be published
  variable_set('node_options_page', array());

  // Set default country.
  variable_set('site_default_country', 'AU');
}