You are here

protected function UcAddressesTestCase::editAddress in Ubercart Addresses 7

Same name and namespace in other branches
  1. 6.2 tests/UcAddressesTestCase.test \UcAddressesTestCase::editAddress()

Edit an address of an user.

Parameters

object $account: The user whose address must be edited

int $aid: The ID of the address to edit

boolean $may_edit: If expected if the user may edit the address. Defaults to TRUE

array $values: (optional) The values for the address to set If not given, default values will be used for the address.

Return value

void

1 call to UcAddressesTestCase::editAddress()
UcAddressesTestCase::doCrudTests in tests/UcAddressesTestCase.test
Test if user can view, edit or delete the address.

File

tests/UcAddressesTestCase.test, line 168
Contains base class for Ubercart Addresses tests.

Class

UcAddressesTestCase
Base class for Ubercart Addresses tests.

Code

protected function editAddress($account, $aid, $may_edit = TRUE, $values = array()) {
  if ($may_edit) {
    $values = self::getEditAddressValues(array(
      'address',
    ), $values, 'address_form');
    $this
      ->drupalPost($this
      ->constructAddressUrl($account, $aid) . 'edit', $values['form_values'], t('Save address'));
    $this
      ->assertText(t('The address is saved.'), t('The address was saved.'));

    // Ensure any given values exists based on whether they should be displayed.
    $this
      ->viewAddress($account, $aid);
    $values['values']['aid'] = $aid;
    $this
      ->doAddressValuesDisplayedTests($values['values'], 'address_view');
    $this
      ->assertTrue(self::checkAddressValuesInDatabase($values['values']), t('The address %aid is correctly saved to the database.', array(
      '%aid' => $aid,
    )));
  }
  else {
    $this
      ->drupalGet($this
      ->constructAddressUrl($account, $aid) . 'edit');
    $this
      ->assertResponse(403);
  }
}