You are here

protected function UcAddressesViewsTestCase::doAccessFilterTests in Ubercart Addresses 7

Same name and namespace in other branches
  1. 6.2 tests/uc_addresses.views.test \UcAddressesViewsTestCase::doAccessFilterTests()

Tests if the address access filters work for one particular account.

Parameters

object $account: The account to check access for.

Return value

void

1 call to UcAddressesViewsTestCase::doAccessFilterTests()
UcAddressesViewsTestCase::testAccessFilters in tests/uc_addresses.views.test
Tests if the address access filters work as expected.

File

tests/uc_addresses.views.test, line 93
Test cases for Views integration.

Class

UcAddressesViewsTestCase
Test cases for Views integration.

Code

protected function doAccessFilterTests($account) {
  $this
    ->drupalLogin($account);

  // Test view access.
  $this
    ->drupalGet('uc_addresses/view');

  // View own default addresses.
  $text = $account->uid . '_default';
  if ($account->uc_addresses_permissions['view_own_def']) {
    $this
      ->assertText($text, 'User sees own default address.');
  }
  else {
    $this
      ->assertNoText($text);
  }

  // View own addresses.
  $text = $account->uid . '_other';
  if ($account->uc_addresses_permissions['view_own']) {
    $this
      ->assertText($text);
  }
  else {
    $this
      ->assertNoText($text);
  }

  // View all default addresses.
  $text = $this->basicUser->uid . '_default';
  if ($account->uc_addresses_permissions['view_all_def']) {
    $this
      ->assertText($text);
  }
  else {
    $this
      ->assertNoText($text);
  }

  // View all addresses.
  $text = $this->basicUser->uid . '_other';
  if ($account->uc_addresses_permissions['view_all']) {
    $this
      ->assertText($text);
  }
  else {
    $this
      ->assertNoText($text);
  }

  // Test edit access.
  $this
    ->drupalGet('uc_addresses/edit');

  // Edit own address.
  $text = $account->uid . '_other';
  if ($account->uc_addresses_permissions['edit_own']) {
    $this
      ->assertText($text);
  }
  else {
    $this
      ->assertNoText($text);
  }

  // Edit all addresses.
  $text = $this->basicUser->uid . '_other';
  if ($account->uc_addresses_permissions['edit_all']) {
    $this
      ->assertText($text);
  }
  else {
    $this
      ->assertNoText($text);
  }

  // Test delete access.
  $this
    ->drupalGet('uc_addresses/delete');

  // Delete own address.
  $text = $account->uid . '_other';
  if ($account->uc_addresses_permissions['delete_own']) {
    $this
      ->assertText($text);
  }
  else {
    $this
      ->assertNoText($text);
  }

  // Delete all addresses.
  $text = $this->basicUser->uid . '_other';
  if ($account->uc_addresses_permissions['delete_all']) {
    $this
      ->assertText($text);
  }
  else {
    $this
      ->assertNoText($text);
  }
}