/**
  * @depends testCreateAccountAccountAffiliation
  */
 public function testUpdateAccountAccountAffiliation()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $account = AccountTestHelper::createAccountByNameForOwner('primaryUpdateAccount', Yii::app()->user->userModel);
     $account2 = AccountTestHelper::createAccountByNameForOwner('secondaryUpdateAccount', Yii::app()->user->userModel);
     $account3 = AccountTestHelper::createAccountByNameForOwner('thirdUpdateAccount', Yii::app()->user->userModel);
     $accountAccountAffiliation = new AccountAccountAffiliation();
     $accountAccountAffiliation->primaryAccount = $account;
     $accountAccountAffiliation->secondaryAccount = $account2;
     $this->assertTrue($accountAccountAffiliation->save());
     $data['secondaryAccount']['id'] = $account3->id;
     $response = $this->createApiCallWithRelativeUrl('update/' . $accountAccountAffiliation->id, 'PUT', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals($account->id, $response['data']['primaryAccount']['id']);
     $this->assertEquals($account3->id, $response['data']['secondaryAccount']['id']);
     $accountAccountAffiliationId = $accountAccountAffiliation->id;
     $accountAccountAffiliation->forgetAll();
     $accountAccountAffiliation = AccountAccountAffiliation::getById($accountAccountAffiliationId);
     $this->assertEquals($accountAccountAffiliation->primaryAccount->id, $response['data']['primaryAccount']['id']);
     $this->assertEquals($accountAccountAffiliation->secondaryAccount->id, $response['data']['secondaryAccount']['id']);
 }