function testGet_givesErrorIfInvalidProperty() { $this->setExpectedException('PHPUnit_Framework_Error', 'Undefined property on Braintree_Customer: foo'); $c = Braintree_Customer::factory(array()); $c->foo; }
/** * generic method for validating incoming gateway responses * * creates a new Braintree_Customer object and encapsulates * it inside a Braintree_Result_Successful object, or * encapsulates a Braintree_Errors object inside a Result_Error * alternatively, throws an Unexpected exception if the response is invalid. * * @ignore * @param array $response gateway response values * @return object Result_Successful or Result_Error * @throws Braintree_Exception_Unexpected */ private function _verifyGatewayResponse($response) { if (isset($response['customer'])) { // return a populated instance of Braintree_Customer return new Braintree_Result_Successful(Braintree_Customer::factory($response['customer'])); } else { if (isset($response['apiErrorResponse'])) { return new Braintree_Result_Error($response['apiErrorResponse']); } else { throw new Braintree_Exception_Unexpected("Expected customer or apiErrorResponse"); } } }