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