protected function UcAddressesViewsTestCase::doActionLinksTests in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 tests/uc_addresses.views.test \UcAddressesViewsTestCase::doActionLinksTests()
Tests if the right actions links are displayed for one particular account.
Parameters
object $account: The account to check access for.
Return value
void
1 call to UcAddressesViewsTestCase::doActionLinksTests()
- UcAddressesViewsTestCase::testActionLinks in tests/
uc_addresses.views.test - Tests if the view, edit and delete links are only displayed for users that are allowed to perform these tasks.
File
- tests/
uc_addresses.views.test, line 198 - Test cases for Views integration.
Class
- UcAddressesViewsTestCase
- Test cases for Views integration.
Code
protected function doActionLinksTests($account) {
$this
->drupalLogin($account);
// Test view access.
$this
->drupalGet('uc_addresses/action-links');
// Get own addresses uri's.
$own_address_default_uri = UcAddressesAddressBook::get($account->uid)
->getDefaultAddress()
->uri();
$own_address_other_uri = UcAddressesAddressBook::get($account->uid)
->getAddressByName($account->uid . '_other')
->uri();
// Get addresses of other user.
$other_user_address_default_uri = UcAddressesAddressBook::get($this->basicUser->uid)
->getDefaultAddress()
->uri();
$other_user_address_other_uri = UcAddressesAddressBook::get($this->basicUser->uid)
->getAddressByName($this->basicUser->uid . '_other')
->uri();
// View own default addresses.
if ($account->uc_addresses_permissions['view_own_def']) {
$this
->assertRaw($own_address_default_uri['path'], 'User can see own default address.');
}
else {
$this
->assertNoRaw($own_address_default_uri['path']);
}
// View own addresses.
if ($account->uc_addresses_permissions['view_own']) {
$this
->assertRaw($own_address_other_uri['path'], 'User can see own addresses.');
}
else {
$this
->assertNoRaw($own_address_other_uri['path']);
}
// View all default addresses.
if ($account->uc_addresses_permissions['view_all_def']) {
$this
->assertRaw($other_user_address_default_uri['path'], 'User can see all default addresses.');
}
else {
$this
->assertNoRaw($other_user_address_default_uri['path']);
}
// View all addresses.
if ($account->uc_addresses_permissions['view_all']) {
$this
->assertRaw($other_user_address_other_uri['path'], 'User can see all addresses.');
}
else {
$this
->assertNoRaw($other_user_address_other_uri['path']);
}
// Edit own addresses.
if ($account->uc_addresses_permissions['edit_own']) {
$this
->assertRaw($own_address_other_uri['path'] . '/edit', 'User can edit own addresses.');
}
else {
$this
->assertNoRaw($own_address_other_uri['path'] . '/edit');
}
// Edit all addresses.
if ($account->uc_addresses_permissions['edit_all']) {
$this
->assertRaw($other_user_address_other_uri['path'] . '/edit', 'User can edit all addresses.');
}
else {
$this
->assertNoRaw($other_user_address_other_uri['path'] . '/edit');
}
// Delete own addresses.
if ($account->uc_addresses_permissions['delete_own']) {
$this
->assertRaw($own_address_other_uri['path'] . '/delete', 'User can delete own addresses.');
}
else {
$this
->assertNoRaw($own_address_other_uri['path'] . '/delete');
}
// Delete all addresses.
if ($account->uc_addresses_permissions['delete_all']) {
$this
->assertRaw($other_user_address_other_uri['path'] . '/delete', 'User can delete all addresses.');
}
else {
$this
->assertNoRaw($other_user_address_other_uri['path'] . '/delete');
}
}