public function CommerceCustomerUITest::testCommerceCustomerUIDeleteCustomerProfile in Commerce Core 7
Delete a customer profile.
File
- modules/
customer/ tests/ commerce_customer_ui.test, line 341 - Commerce customer profile tests.
Class
- CommerceCustomerUITest
- Functional tests for the commerce customer UI module.
Code
public function testCommerceCustomerUIDeleteCustomerProfile() {
// Create a new customer profile.
$profile = $this
->createDummyCustomerProfile('billing', $this->store_customer->uid);
// Login with customer.
$this
->drupalLogin($this->store_customer);
// Check the access to the profile delete.
$this
->drupalGet('admin/commerce/customer-profiles/' . $profile->profile_id . '/delete');
$this
->assertResponse(403, t('Store customer is not able to access the admin deletion page for a customer profile'));
// Login with store admin.
$this
->drupalLogin($this->store_admin);
// Check the access to the profile delete.
$this
->drupalGet('admin/commerce/customer-profiles/' . $profile->profile_id . '/delete');
$this
->assertResponse(200, t('Store customer is able to access the admin deletion page for a customer profile'));
// Check the integrity of the delete form.
$this
->pass(t('Test the integrity of the delete customer profile form:'));
$this
->assertTitle(t('Are you sure you want to delete this profile?') . ' | Drupal', t('The title of the deletion page is correct'));
$this
->assertText(t('Deleting this profile cannot be undone'), t('A warning message for deleting the profile is displayed'));
$this
->assertFieldById('edit-submit', t('Delete'), '\'Delete\' button is present');
$this
->assertLink(t('Cancel'), 0, t('Cancel link is present'));
// Delete the profile.
$this
->drupalPost(NULL, array(), t('Delete'));
// Assert the landing page and confirmation messages.
$this
->assertTrue($this->url == url('admin/commerce/customer-profiles', array(
'absolute' => TRUE,
)), t('Landing page after deleting the profile is the profile listing page'));
$this
->assertText(t('The profile has been deleted'), t('Confirmation message after deleting the profile is displayed'));
$this
->assertText(t('No customer profiles have been created yet.'), t('\'No customer profiles have been created yet\' message is displayed'));
// Check at database level.
$profiles = commerce_customer_profile_load_multiple(array(
$profile->profile_id,
), array(), TRUE);
$profile = reset($profiles);
$this
->assertTrue(empty($profile), t('Profile can\'t be loaded from database after deleting it'));
}