public function CommerceCustomerUITest::testCommerceCustomerUIEditProfileViaOrderUI in Commerce Core 7
Edit a customer profile through the order UI.
File
- modules/
customer/ tests/ commerce_customer_ui.test, line 490 - Commerce customer profile tests.
Class
- CommerceCustomerUITest
- Functional tests for the commerce customer UI module.
Code
public function testCommerceCustomerUIEditProfileViaOrderUI() {
// Create a new customer profile.
$profile = $this
->createDummyCustomerProfile('billing', $this->store_customer->uid);
// Create an order for store customer.
$order = $this
->createDummyOrder($this->store_customer->uid, array(), 'pending', $profile->profile_id);
// Login with store admin.
$this
->drupalLogin($this->store_admin);
// Change some profile fields in the order and save.
$edit = array(
'commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]' => 'Example Name line',
'commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][locality]' => 'Example Locality',
);
$this
->drupalPost('admin/commerce/orders/' . $order->order_id . '/edit', $edit, t('Save order'));
$this
->assertText(t('Order saved'), t('\'Order saved\' message is displayed'));
// Check the customer profile in the listing.
$this
->drupalGet('admin/commerce/customer-profiles');
$this
->assertTrue($edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]'], t('\'Name line\' text is present with the correct value: !value', array(
'!value' => $edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]'],
)));
// Check the customer profile at database level.
$profiles = commerce_customer_profile_load_multiple(array(
$profile->profile_id,
), array(), TRUE);
$profile = reset($profiles);
$profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
$this
->assertEqual($profile_wrapper->commerce_customer_address->name_line
->value(), $edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]'], t('\'Name line\' property value !value match', array(
'!value' => $edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]'],
)));
$this
->assertEqual($profile_wrapper->commerce_customer_address->locality
->value(), $edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][locality]'], t('\'Locality\' property value !value match', array(
'!value' => $edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][locality]'],
)));
}