uc_addresses.test.test in Ubercart Addresses 6.2
Test cases for test module.
File
tests/uc_addresses.test.testView source
<?php
/**
* @file
* Test cases for test module.
*/
// Ensure UcAddressesTestCase is available.
require_once 'UcAddressesTestCase.test';
/**
* Test cases for the test module.
*/
class UcAddressesTestModuleTestCase extends UcAddressesTestCase {
/**
* Describes this test.
*
* @return array
*/
public static function getInfo() {
return array(
'name' => 'Test module',
'description' => 'Ensure that the test module can be installed properly.',
'group' => 'Ubercart Addresses',
'dependencies' => array(
'ctools',
'token',
'uc_store',
'views',
'uc_cart',
'uc_order',
'uc_product',
'uc_payment',
'uc_payment',
'uc_payment_pack',
),
);
}
/**
* Setup modules
*/
public function setUp() {
parent::setUp();
// Install Ubercart Addresses test module and flush schema cache.
drupal_install_modules(array(
'views',
'uc_cart',
'uc_order',
'uc_product',
'uc_payment',
'uc_payment',
'uc_payment_pack',
'uc_addresses_test',
));
drupal_get_schema(NULL, TRUE);
}
/**
* Test if test module is installed without problems.
*/
public function testTestModule() {
// Ensure the expected address fields from the test module are present.
$fields = uc_addresses_get_address_fields();
$this
->assertTrue(isset($fields['billing_extra1']), t('The field %field is available.', array(
'%field' => t('Billing Extra Field'),
)));
$this
->assertTrue(isset($fields['shipping_extra2']), t('The field %field is available.', array(
'%field' => t('Delivery Extra Field'),
)));
// Test if the database columns are added.
$this
->assertTrue(db_column_exists('uc_addresses', 'billing_extra1'), t('The database column %column is available in the table %table.', array(
'%column' => 'billing_extra1',
'%table' => 'uc_addresses',
)));
$this
->assertTrue(db_column_exists('uc_addresses', 'shipping_extra2'), t('The database column %column is available in the table %table.', array(
'%column' => 'shipping_extra2',
'%table' => 'uc_addresses',
)));
$this
->assertTrue(db_column_exists('uc_orders', 'billing_billing_extra1'), t('The database column %column is available in the table %table.', array(
'%column' => 'billing_billing_extra1',
'%table' => 'uc_orders',
)));
$this
->assertTrue(db_column_exists('uc_orders', 'delivery_shipping_extra2'), t('The database column %column is available in the table %table.', array(
'%column' => 'delivery_shipping_extra2',
'%table' => 'uc_orders',
)));
$this
->assertFalse(db_column_exists('uc_orders', 'delivery_billing_extra1'), t('The database column %column is not available in the table %table.', array(
'%column' => 'delivery_billing_extra1',
'%table' => 'uc_orders',
)));
$this
->assertFalse(db_column_exists('uc_orders', 'billing_shipping_extra2'), t('The database column %column is not available in the table %table.', array(
'%column' => 'billing_shipping_extra2',
'%table' => 'uc_orders',
)));
// Test if the fields are displayed on an address form.
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($this
->constructAddressUrl($this->adminUser) . 'add');
$this
->assertFieldByName('address[billing_extra1]');
$this
->assertFieldByName('address[shipping_extra2]');
// Test if the module can be uninstalled too and flush schema cache.
drupal_uninstall_module('uc_addresses_test');
drupal_get_schema(NULL, TRUE);
// Now ensure that the fields added by the test module are no longer there in the database.
$this
->assertFalse(db_column_exists('uc_addresses', 'billing_extra1'), t('The database column %column is not available in the table %table.', array(
'%column' => 'billing_extra1',
'%table' => 'uc_addresses',
)));
$this
->assertFalse(db_column_exists('uc_addresses', 'shipping_extra2'), t('The database column %column is not available in the table %table.', array(
'%column' => 'shipping_extra2',
'%table' => 'uc_addresses',
)));
$this
->assertFalse(db_column_exists('uc_orders', 'billing_billing_extra1'), t('The database column %column is not available in the table %table.', array(
'%column' => 'billing_billing_extra1',
'%table' => 'uc_orders',
)));
$this
->assertFalse(db_column_exists('uc_orders', 'delivery_shipping_extra2'), t('The database column %column is not available in the table %table.', array(
'%column' => 'delivery_shipping_extra2',
'%table' => 'uc_orders',
)));
}
}
Classes
Name | Description |
---|---|
UcAddressesTestModuleTestCase | Test cases for the test module. |