Commit 3957f727 authored by bobbyaldol's avatar bobbyaldol Committed by bobbyaldol

Issue #1693290 by bobbyaldol: Tests for the Checkout Page Example have been added.

parent b04056b7
......@@ -4,3 +4,4 @@ package = Commerce (contrib)
dependencies[] = commerce_checkout
dependencies[] = checkout_pane_example
core = 7.x
files[] = checkout_page_example.test
<?php
/**
*@file
* This file consists of the tests for commerce_page_example.
*/
class CheckoutPageExampleTestCase extends CommerceBaseTestCase{
public static function getInfo(){
return array(
'name' => 'Checkout Page Example',
'description' => 'Checks the functionality of Checkout Page Example.',
'group' => 'Commerce (contrib)'
);
}
/**
*Set up the necessary modules for testing.
*/
function setUp(){
$modules = parent::setUpHelper('all',array('checkout_pane_example','checkout_page_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.
}
/**
*Test the Checkout Page example.
*/
function testCheckoutPageExampleFunctionality(){
$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 is right.
$this->assertResponse(200, t('The owner of the order can access to the checkout page'));
$this->assertTitle(t('Checkout Page Example') . ' | Drupal', t('Title of the checkout example page is correct'));
$this->assertText(t('Checkout Pane Example'),t('The Pane added by the example is present'));
$this->assertText(t('Your nickname'));
//Testing the cancel button.
$this->drupalPost(NULL,array(),t('Cancel'));
$this->assertText(t('Checkout of your current order has been canceled and may be resumed when you are ready.'));
$this->assertText(t('Shopping cart'));
$this->assertText(t('Product One'));
// Access to checkout page.
$this->drupalGet($this->getCommerceUrl('checkout'));
$nickname = $this->randomName();
//Check the "Continue to real checkout page" button.
$this->drupalPost(NULL,array('checkout_pane_example[nickname]' => $nickname),t('Continue to a real checkout page'));
// 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->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'));
$another_email = 'noreply@drupal.org';
// Check if the page is right.
$this->assertResponse(200, t('The owner of the order can access to the checkout page'));
$this->assertTitle(t('Checkout Page Example') . ' | Drupal', t('Title of the checkout example page is correct'));
$this->assertText(t('Checkout Pane Example'),t('The Pane added by the example is present'));
$this->assertText(t('Your nickname'));
$this->assertText(t('Another e-mail address'));
$this->drupalPost(NULL,array('checkout_pane_example[nickname]' => $nickname,'checkout_pane_example[another_email]' => $another_email),t('Continue to a real checkout page'));
// 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'));
}
}
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