function testUpdate_handleErrors()
 {
     $customer = Braintree_Customer::createNoValidate();
     $firstToken = 'FIRST_PAYPALToken-' . strval(rand());
     $http = new Braintree_HttpClientApi(Braintree_Configuration::$global);
     $firstNonce = $http->nonceForPayPalAccount(array('paypal_account' => array('consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $firstToken)));
     $firstPaypalAccount = Braintree_PaymentMethod::create(array('customerId' => $customer->id, 'paymentMethodNonce' => $firstNonce));
     $this->assertTrue($firstPaypalAccount->success);
     $secondToken = 'SECOND_PAYPALToken-' . strval(rand());
     $http = new Braintree_HttpClientApi(Braintree_Configuration::$global);
     $secondNonce = $http->nonceForPayPalAccount(array('paypal_account' => array('consent_code' => 'PAYPAL_CONSENT_CODE', 'token' => $secondToken)));
     $secondPaypalAccount = Braintree_PaymentMethod::create(array('customerId' => $customer->id, 'paymentMethodNonce' => $secondNonce));
     $this->assertTrue($secondPaypalAccount->success);
     $updateResult = Braintree_PayPalAccount::update($firstToken, array('token' => $secondToken));
     $this->assertFalse($updateResult->success);
     $errors = $updateResult->errors->forKey('paypalAccount')->errors;
     $this->assertEquals(Braintree_Error_Codes::PAYPAL_ACCOUNT_TOKEN_IS_IN_USE, $errors[0]->code);
 }