You are here

commerce_ups.test in Commerce UPS 7.2

Same filename and directory in other branches
  1. 7 tests/commerce_ups.test

This will allows me to test the commerce ups module.

File

tests/commerce_ups.test
View source
<?php

/**
 * @file
 * This will allows me to test the commerce ups module.
 */

/**
 * Administration tests for Commerce UPS.
 */
class CommerceUPSAdministrationTestCase extends CommerceBaseTestCase {

  /**
   * Order object.
   */
  protected $order;

  /**
   * Implementation of getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => 'Commerce UPS',
      'description' => 'Commerce UPS admin stuff...',
      'group' => 'Drupal Commerce',
    );
  }

  /**
   * Implementation of setUp().
   */
  function setUp() {
    $modules = parent::setUpHelper('all');
    $final_modules = array_unique(array_merge($modules, array(
      'commerce_ups',
    )));
    parent::setUp($final_modules);
    $permissions = parent::permissionBuilder('all');
    $final_permissions = array_unique(array_merge($permissions, array(
      'administer shipping',
    )));
    $user = $this
      ->drupalCreateUser($final_permissions);
    $this
      ->drupalLogin($user);
  }
  public function testCommerceUPSSettingsForm() {
    $this
      ->drupalGet('admin/commerce/config/shipping/methods/ups/edit');
    $this
      ->assertResponse(200, 'Hit something');
  }

  /**
   * This function will generate a fake credentails in order to use the test
   * funcionality.
   */
  public function testCommerceUPSFieldSaves() {
    $form = array(
      'commerce_ups_account_id' => 'test',
      'commerce_ups_user_id' => 'test1',
      'commerce_ups_access_key' => 'test2',
      'commerce_ups_access_key' => 'test3',
      'commerce_ups_default_package_size_length' => 1,
      'commerce_ups_default_package_size_width' => 2,
      'commerce_ups_default_package_size_height' => 3,
      'commerce_ups_password' => 'testb',
    );
    $this
      ->drupalPost('admin/commerce/config/shipping/methods/ups/edit', $form, t('Save configuration'));
  }

}

Classes

Namesort descending Description
CommerceUPSAdministrationTestCase Administration tests for Commerce UPS.