public function CommerceBaseTestCase::createDummyCustomerProfile in Commerce Core 7
Create a customer profile.
Parameters
$type: Type of the customer profile, default billing. @param $uid User id that will own the profile, by default anonymous.
@return The customer profile created or FALSE if the profile wasn't created.
7 calls to CommerceBaseTestCase::createDummyCustomerProfile()
- CommerceCustomerUITest::testCommerceCustomerDeleteProfilesWithOrderReference in modules/
customer/ tests/ commerce_customer_ui.test - Delete multiple profiles with and without orders attached.
- CommerceCustomerUITest::testCommerceCustomerUIDeleteCustomerProfile in modules/
customer/ tests/ commerce_customer_ui.test - Delete a customer profile.
- CommerceCustomerUITest::testCommerceCustomerUIDeleteProfileViaOrderUI in modules/
customer/ tests/ commerce_customer_ui.test - Delete a customer profile through the order UI.
- CommerceCustomerUITest::testCommerceCustomerUIDisableCustomerProfile in modules/
customer/ tests/ commerce_customer_ui.test - Disable a customer profile. @TODO: Probably this test should be completed when it is possible to select older profiles for the orders.
- CommerceCustomerUITest::testCommerceCustomerUIEditCustomerProfile in modules/
customer/ tests/ commerce_customer_ui.test - Edit a previously existing customer profile.
File
- tests/
commerce_base.test, line 585 - Defines abstract base test class for the Commerce module tests.
Class
- CommerceBaseTestCase
- Abstract class for Commerce testing. All Commerce tests should extend this class.
Code
public function createDummyCustomerProfile($type = 'billing', $uid = 0) {
// Initialize the profile.
$profile = commerce_customer_profile_new($type, $uid);
// Initialize the address.
$defaults = array();
$defaults['name_line'] = $this
->randomName();
$field = field_info_field('commerce_customer_address');
$instance = field_info_instance('commerce_customer_profile', 'commerce_customer_address', $type);
$values = array_merge($defaults, addressfield_default_values($field, $instance), $this
->generateAddressInformation());
$values['data'] = serialize($values['data']);
$profile->commerce_customer_address[LANGUAGE_NONE][] = $values;
// Save the dummy profile.
commerce_customer_profile_save($profile);
return $profile;
}