Commit b04056b7 authored by root's avatar root

Issue #1686160 by bobbyaldol:tests for the checkout Pane Example added.

parent f9ae3c02
......@@ -3,3 +3,4 @@ description = Demonstrates providing an additional checkout pane
package = Commerce (contrib)
dependencies[] = commerce_checkout
core = 7.x
files[] = checkout_pane_example.test
<?php
/**
*@file
* This file contains the tests for checkout_pane_example.
*/
class CheckoutPaneExampleTestCase extends CommerceBaseTestCase{
public static function getInfo() {
return array(
'name' => 'Checkout Pane Example',
'description' => 'Test the functionality of the Checkout Pane Example',
'group' => 'Commerce (contrib)',
);
}
/**
*Set up the necessary modules and users for testing.
*/
function setUp() {
$modules = parent::setUpHelper('all',array('checkout_pane_example'));
parent::setUp($modules);
// User creation for different operations.
$this->store_customer = $this->createStoreCustomer();
$this->store_admin = $this->createStoreAdmin();
//Check if the default product type is available else create it.
$product_types = commerce_product_types();
if(empty($product_types['product'])){
$this->createDummyProductType('product');
commerce_product_types_reset();
}
// The rule that sends a mail after checkout completion should be disabled
// as it returns an error caused by how mail messages are stored.
$rules_config = rules_config_load('commerce_checkout_order_email');
$rules_config->active = FALSE;
$rules_config->save();
cache_clear_all(); //Just in case required.
}
/**
*Tests the menu-link functionality.
*/
function testCheckoutPanelExampleTestMenuLink(){
$this->drupalGet('commerce_examples/checkout_pane_example');
$this->assertResponse(200);
$this->assertText(t('Checkout Pane Example'),t('The menu-link is working fine'));
}
/**
*Tests the checkout pane functionality.
*/
function testCheckoutPaneExampleFunctionality(){
//First the checkbox for additional email is unchecked and the modules functionality is checked.
// Log in as a store customer.
$this->drupalLogin($this->store_customer);
// Order creation, in cart status.
$this->order = $this->createDummyOrder($this->store_customer->uid);
// Access to checkout page.
$this->drupalGet($this->getCommerceUrl('checkout'));
// Check if the page resolves and if the default panes are present.
$this->assertResponse(200, t('The owner of the order can access to the checkout page'));
$this->assertTitle(t('Checkout') . ' | Drupal', t('Title of the checkout phase is correct'));
$this->assertText(t('Your big wonderful shopping cart brimming over with shopaholic nonsense'), t('Shopping cart contents pane is present'));
$this->assertText(t('Billing information'), t('Billing information pane is present'));
$this->assertText(t('Checkout Pane Example'),t('The Pane added by the example is present'));
// Generate random information, as city, postal code, etc.
$nickname = $this->randomName();
$address_info = $this->generateAddressInformation();
// Fill in the billing address information.
$billing_pane = $this->xpath("//select[starts-with(@name, 'customer_profile_billing[commerce_customer_address]')]");
$this->drupalPostAJAX(NULL, array((string) $billing_pane[0]['name'] => 'US'), (string) $billing_pane[0]['name']);
// Check if the country has been selected correctly, this uses XPath as the
// ajax call replaces the element and the id may change.
$this->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', t('Country selected'));
// Fill in the required information for billing pane, with a random State.
$info = array(
'checkout_pane_example[nickname]' => $nickname,
'customer_profile_billing[commerce_customer_address][und][0][name_line]' => $address_info['name_line'],
'customer_profile_billing[commerce_customer_address][und][0][thoroughfare]' => $address_info['thoroughfare'],
'customer_profile_billing[commerce_customer_address][und][0][locality]' => $address_info['locality'],
'customer_profile_billing[commerce_customer_address][und][0][administrative_area]' => 'KY',
'customer_profile_billing[commerce_customer_address][und][0][postal_code]' => $address_info['postal_code'],
);
$this->drupalPost(NULL, $info, t('Continue to next step'));
//No check the data entred in the pane appears in the checkout review or not.
$this->assertText('Checkout Pane Example',t('Checkout Pane Example Present'));
$this->assertText($nickname,t('Nickname Present'));
$this->drupalGet('');
$this->drupalLogout();
//Login as a store admin, to check the additional email address checkbox.
$this->drupalLogin($this->store_admin);
$this->drupalGet('admin/commerce/config/checkout/form/pane/checkout_pane_example');
$this->assertText('Checkout Pane Example',t('Entered the checkout pane configuration page'));
$this->drupalPost(NULL,array('checkout_pane_example_request_another_email' => TRUE),t('Save configuration'));
$this->drupalLogout();
$this->drupalLogin($this->store_customer);
// Access to checkout page.
$this->drupalGet($this->getCommerceUrl('checkout'));
// Check if the page resolves and if the default panes are present.
$this->assertResponse(200, t('The owner of the order can access to the checkout page'));
$this->assertTitle(t('Checkout') . ' | Drupal', t('Title of the checkout phase is correct'));
$this->assertText(t('Your big wonderful shopping cart brimming over with shopaholic nonsense'), t('Shopping cart contents pane is present'));
$this->assertText(t('Billing information'), t('Billing information pane is present'));
$this->assertText(t('Checkout Pane Example'),t('The Pane added by the example is present'));
$this->assertText(t('Another e-mail address'),t('Additional email address Pane present'));
//Set email address.
$another_email = 'noreply@drupal.org';
$this->drupalPost(NULL, array('checkout_pane_example[another_email]' => $another_email), t('Continue to next step'));
//No check the data entred in the pane appears in the checkout review or not.
$this->assertText('Checkout Pane Example',t('Checkout Pane Example Present'));
$this->assertText($nickname,t('Nickname Present'));
$this->assertText($another_email,t('Additionale Email address Found.'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment