public function CommerceCustomerUITest::testCommerceCustomerUIDeleteProfileViaOrderUI in Commerce Core 7
Delete a customer profile through the order UI.
File
- modules/
customer/ tests/ commerce_customer_ui.test, line 521 - Commerce customer profile tests.
Class
- CommerceCustomerUITest
- Functional tests for the commerce customer UI module.
Code
public function testCommerceCustomerUIDeleteProfileViaOrderUI() {
// Create a new customer profile.
$profile = $this
->createDummyCustomerProfile('billing', $this->store_customer->uid);
$profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
// 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);
// Access the order and check delete customer profile information.
$this
->drupalPost('admin/commerce/orders/' . $order->order_id . '/edit', array(
'commerce_customer_billing[und][profiles][0][remove]' => 1,
), t('Save order'));
// Check the customer profile is not present in the listing.
$this
->drupalGet('admin/commerce/customer-profiles');
$this
->assertNoText($profile_wrapper->commerce_customer_address->name_line
->value(), t('\'Name line\' for the profile is not present in the customer profiles listing'));
// Check the customer profile has been deleted at database level.
$profiles = commerce_customer_profile_load_multiple(array(
$profile->profile_id,
), array(), TRUE);
$profile = reset($profiles);
$this
->assertTrue(empty($profile), t('Profile has been delete from database'));
}