function testDelete() { $customer = Braintree_Customer::createNoValidate(); $address = Braintree_Address::createNoValidate(array('customerId' => $customer->id, 'streetAddress' => '1 E Main St')); Braintree_Address::find($customer->id, $address->id); Braintree_Address::delete($customer->id, $address->id); $this->setExpectedException('Braintree_Exception_NotFound'); Braintree_Address::find($customer->id, $address->id); }
/** * Deletes a record via the API * * @param object $model * @param mixed $conditions * @return bool */ public function delete(Model $model, $conditions = null) { $ids = $this->_getIdsToBeDeleted($model, $conditions); if ($ids === false) { return false; } $entity = $this->_getModelEntity($model); if (!empty($ids)) { foreach ($ids as $id) { try { switch ($entity) { case 'Customer': Braintree_Customer::delete($id); break; case 'Transaction': $this->showError(__('Transactions cannot be deleted', true)); return false; break; case 'CreditCard': Braintree_CreditCard::delete($id); break; case 'Address': $exploded = explode('|', $id); if (count($exploded) != 2) { return false; } list($customer_id, $address_id) = $exploded; Braintree_Address::delete($customer_id, $address_id); break; default: return false; break; } } catch (Exception $e) { $this->showError(print_r($e, true)); return false; } } } return true; }