t('Check address on checkout'), 'description' => t('When the payment gateway is changed by the user, ensure that the customers address is not lost or corrupted'), 'group' => t('e-Commerce'), ); } function setUp() { parent::setUp('ec_product', 'ec_anon', 'ctools', 'ec_checkout', 'ec_buynow', 'ec_receipt', 'ec_store', 'ec_common', 'ec_receipt_test_payment', 'ec_customer', 'ec_address', 'search', 'ctools', 'rules', 'views'); variable_set('ec_default_currency', 'USD'); } function testChangeOfPaymentType() { $account = $this->drupalCreateUser(); $this->drupalLogin($account); $address = array( 'uid' => $account->uid, 'firstname' => $this->randomName(20), 'lastname' => $this->randomName(20), 'street1' => $this->randomName(52), 'street2' => $this->randomName(52), 'zip' => drupal_substr($this->randomName(10), -10), 'city' => $this->randomName(20), 'state' => $this->randomName(20), 'country' => 'US', ); drupal_write_record('ec_address', $address); $product = array( 'type' => 'product', 'ptype' => 'generic', 'price' => '20.00', 'revision' => 1, ); $node = $this->drupalCreateNode($product); $this->drupalGet('node/' . $node->nid); $this->clickLink(t('Buy now')); $this->drupalPost(NULL, array('select_payment_type' => 'test2'), t('Select payment method')); $this->drupalPost(NULL, array(), t('Place your order')); if ($txn = ec_store_transaction_load(1)) { unset($address['aid'], $address['uid']); foreach ($address as $key => $value) { $this->assertEqual($value, $txn->address['billing'][$key], t('address[@key] equal to "@value" was "@value2"', array('@key' => $key, '@value' => $value, '@value2' => $txn->address['billing'][$key]))); } } else { $this->fail('No transaction created'); } } } class ecCheckoutTestLoadingAddressDuringCheckout extends DrupalWebTestCase { function getInfo() { return array( 'name' => t('Check loading address on checkout'), 'description' => t('Check to make sure that changing payment gateway is not losing address information on the page'), 'group' => t('e-Commerce'), ); } function setUp() { parent::setUp('ec_product', 'ec_anon', 'ec_checkout', 'ec_buynow', 'ec_receipt', 'ec_store', 'ec_common', 'ec_receipt_test_payment', 'ec_customer', 'ec_address', 'search', 'ctools', 'rules', 'views'); variable_set('ec_default_currency', 'USD'); } function testLoadingAddress() { $account = $this->drupalCreateUser(); $this->drupalLogin($account); $address = array( 'firstname' => $this->randomName(20), 'lastname' => $this->randomName(20), 'street1' => $this->randomName(52), 'street2' => $this->randomName(52), 'zip' => drupal_substr($this->randomName(10), -10), 'city' => $this->randomName(20), 'state' => 'CA', 'country' => 'US', ); $product = array( 'type' => 'product', 'ptype' => 'generic', 'price' => '20.00', 'revision' => 1, ); $node = $this->drupalCreateNode($product); $this->drupalGet('node/' . $node->nid); $this->clickLink(t('Buy now')); $params = array('select_payment_type' => 'test2'); foreach ($address as $key => $value) { $params['address[billing][' . $key . ']'] = $value; } $this->drupalPost(NULL, $params, t('Select payment method')); unset($params['select_payment_type']); foreach ($params as $field => $value) { $this->assertFieldByName($field, $value); } $params = array(); $this->drupalPost(NULL, $params, t('Place your order')); if ($txn = ec_store_transaction_load(1)) { //trigger_error('
'. print_r($txn, TRUE) .'
'); unset($address['aid'], $address['uid']); foreach ($address as $key => $value) { $this->assertEqual($value, $txn->address['billing'][$key], t('address[@key] equal to "@value" was "@value2"', array('@key' => $key, '@value' => $value, '@value2' => $txn->address['billing'][$key]))); } } else { $this->fail('No transaction created'); } } } class ecCheckoutTestUpdateOrder extends DrupalWebTestCase { function getInfo() { return array( 'name' => t('Test Update Order (Registered User)'), 'description' => t('Test update order to make sure an entered address is retained'), 'group' => t('e-Commerce'), ); } function setUp() { parent::setUp('ec_product', 'ec_anon', 'ec_checkout', 'ec_buynow', 'ec_receipt', 'ec_store', 'ec_common', 'ec_receipt_test_payment', 'ec_customer', 'ec_address', 'search', 'ctools', 'rules', 'views'); variable_set('ec_default_currency', 'USD'); } function testLoadingAddress() { $account = $this->drupalCreateUser(); $this->drupalLogin($account); $address = array( 'firstname' => $this->randomName(20), 'lastname' => $this->randomName(20), 'street1' => $this->randomName(52), 'street2' => $this->randomName(52), 'zip' => drupal_substr($this->randomName(10), -10), 'city' => $this->randomName(20), 'state' => 'CA', 'country' => 'US', ); $product = array( 'type' => 'product', 'ptype' => 'generic', 'price' => '20.00', 'revision' => 1, ); $node = $this->drupalCreateNode($product); $this->drupalGet('node/' . $node->nid); $this->clickLink(t('Buy now')); //$params = array('select_payment_type' => 'test2'); $params = array(); foreach ($address as $key => $value) { $params['address[billing][' . $key . ']'] = $value; } $this->drupalPost(NULL, $params, t('Update order')); foreach ($params as $field => $value) { $this->assertFieldByName($field, $value); } } } class ecCheckoutTestUpdateOrderAnonymousNoCache extends DrupalWebTestCase { function getInfo() { return array( 'name' => t('Test Update Order (Anonymous User w/nocache)'), 'description' => t('Test update order to make sure an entered address is retained for an anonymous customer with no caching'), 'group' => t('e-Commerce'), ); } function setUp() { parent::setUp('ec_product', 'ec_anon', 'ec_checkout', 'ec_buynow', 'ec_receipt', 'ec_store', 'ec_common', 'ec_receipt_test_payment', 'ec_customer', 'ec_address', 'search', 'ctools', 'rules', 'views'); variable_set('ec_default_currency', 'USD'); variable_set('cache', 0); } function testLoadingAddress() { $address = array( 'firstname' => $this->randomName(20), 'lastname' => $this->randomName(20), 'street1' => $this->randomName(52), 'street2' => $this->randomName(52), 'zip' => drupal_substr($this->randomName(10), -10), 'city' => $this->randomName(20), 'state' => 'CA', 'country' => 'US', ); $product = array( 'type' => 'product', 'ptype' => 'generic', 'price' => '20.00', 'revision' => 1, ); $node = $this->drupalCreateNode($product); $this->drupalGet('node/'. $node->nid); $this->clickLink(t('Buy now')); //$params = array('select_payment_type' => 'test2'); $params = array( 'mail' => $this->randomString() . '@foo.bar', ); foreach ($address as $key => $value) { $params['address[billing]['. $key .']'] = $value; } $this->drupalPost(NULL, $params, t('Update order')); foreach ($params as $field => $value) { $this->assertFieldByName($field, $value); } } } class ecCheckoutTestUpdateOrderAnonymousCache extends DrupalWebTestCase { function getInfo() { return array( 'name' => t('Test Update Order (Anonymous User w/cache)'), 'description' => t('Test update order to make sure an entered address is retained for an anonymous customer with caching'), 'group' => t('e-Commerce'), ); } function setUp() { parent::setUp('ec_product', 'ec_anon', 'ec_checkout', 'ec_buynow', 'ec_receipt', 'ec_store', 'ec_common', 'ec_receipt_test_payment', 'ec_customer', 'ec_address', 'search', 'ctools', 'rules', 'views'); variable_set('ec_default_currency', 'USD'); variable_set('cache', 1); } function testLoadingAddress() { $this->assertTrue(variable_get('cache', 0), 'Cache set to CACHE_NORMAL'); $address = array( 'firstname' => $this->randomName(20), 'lastname' => $this->randomName(20), 'street1' => $this->randomName(52), 'street2' => $this->randomName(52), 'zip' => drupal_substr($this->randomName(10), -10), 'city' => $this->randomName(20), 'state' => 'CA', 'country' => 'US', ); $product = array( 'type' => 'product', 'ptype' => 'generic', 'price' => '20.00', 'revision' => 1, ); $node = $this->drupalCreateNode($product); $this->drupalGet('node/'. $node->nid); $this->clickLink(t('Buy now')); //$params = array('select_payment_type' => 'test2'); $params = array( 'mail' => $this->randomString() . '@foo.bar', ); foreach ($address as $key => $value) { $params['address[billing]['. $key .']'] = $value; } $this->drupalPost(NULL, $params, t('Update order')); foreach ($params as $field => $value) { $this->assertFieldByName($field, $value); } } }