public function update($data = array())
{
if (empty($data)) {
return false;
}
$data = $this->sanitize_columns($data);
do_action('give_customer_pre_update', $this->id, $data);
$updated = false;
if ($this->db->update($this->id, $data)) {
$customer = $this->db->get_customer_by('id', $this->id);
$this->setup_customer($customer);
$updated = true;
}
do_action('give_customer_post_update', $updated, $this->id, $data);
return $updated;
}
public function test_update_customer() { $test_email = '*****@*****.**'; $customer = new Give_Customer($test_email); $customer_id = $customer->create(array('email' => $test_email)); $this->assertEquals($customer_id, $customer->id); $data_to_update = array('email' => '*****@*****.**', 'name' => 'Test Account'); $customer->update($data_to_update); $this->assertEquals('*****@*****.**', $customer->email); $this->assertEquals('Test Account', $customer->name); // Verify if we have an empty array we get false $this->assertFalse($customer->update()); }