public function UcAddressesViewsTestCase::doDisplayAccessTests in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 tests/uc_addresses.views.test \UcAddressesViewsTestCase::doDisplayAccessTests()
Tests for each user if he/she should have access to pages:
- representing a listing of his/her own addresses;
- representing a View of his/her own default billing address;
- representing a View of his/her own non-default address;
- representing a listing of addresses of an other user;
- representing a View a default billing address of an other user;
- representing a View a non-default address of an other user;
This method is used by the display access plugin test and the argument validator plugin test as they are basically equal in functionality.
Parameters
string $user_path: The path to embed in user/[uid]/[user_path]_[access_type].
Return value
void
2 calls to UcAddressesViewsTestCase::doDisplayAccessTests()
- UcAddressesViewsTestCase::testArgumentValidatorPlugins in tests/
uc_addresses.views.test - Tests if the argument validator plugins work as expected.
- UcAddressesViewsTestCase::testDisplayAccessPlugin in tests/
uc_addresses.views.test - Tests if the display access plugin works as expected.
File
- tests/
uc_addresses.views.test, line 310 - Test cases for Views integration.
Class
- UcAddressesViewsTestCase
- Test cases for Views integration.
Code
public function doDisplayAccessTests($user_path) {
// Define types of access.
$access_types = array(
'view',
'edit',
'delete',
);
// Get addresses for basic user.
$other_user_address_default = UcAddressesAddressBook::get($this->basicUser->uid)
->getDefaultAddress();
$other_user_address_other = UcAddressesAddressBook::get($this->basicUser->uid)
->getAddressByName($this->basicUser->uid . '_other');
foreach ($this->accounts as $account) {
$this
->drupalLogin($account);
$addressBook = UcAddressesAddressBook::get($account->uid);
$default_address = $addressBook
->getDefaultAddress();
$other_address = $addressBook
->getAddressByName($account->uid . '_other');
// Test access per access type.
foreach ($access_types as $access_type) {
// Test for access for any own addresses.
$base_own_path = 'user/' . $account->uid . '/' . $user_path . '_' . $access_type;
$this
->drupalGet($base_own_path);
if ($access_type == 'view') {
// Take "view own default" permission.
$this
->assertAddressAccessResponse($account, $access_type, $account, TRUE);
}
else {
$this
->assertAddressAccessResponse($account, $access_type, $account);
}
// Test access for own default address.
$this
->drupalGet($base_own_path . '/' . $default_address
->getId());
$this
->assertAddressAccessResponse($account, $access_type, $account, TRUE);
// Test access for own non-default address.
$this
->drupalGet($base_own_path . '/' . $other_address
->getId());
$this
->assertAddressAccessResponse($account, $access_type, $account);
// Test for access for any addresses of an other user.
$base_other_path = 'user/' . $this->basicUser->uid . '/' . $user_path . '_' . $access_type;
$this
->drupalGet($base_other_path);
if ($access_type == 'view') {
// Take "view all default" permission.
$this
->assertAddressAccessResponse($account, $access_type, $this->basicUser, TRUE);
}
else {
$this
->assertAddressAccessResponse($account, $access_type, $this->basicUser);
}
// Test access for default address of an other user.
$this
->drupalGet($base_other_path . '/' . $other_user_address_default
->getId());
$this
->assertAddressAccessResponse($account, $access_type, $this->basicUser, TRUE);
// Test access for non-default address of an other user.
$this
->drupalGet($base_other_path . '/' . $other_user_address_other
->getId());
$this
->assertAddressAccessResponse($account, $access_type, $this->basicUser);
}
}
}