mirror of
https://github.com/silverstripe/silverstripe-externallinks.git
synced 2024-10-22 15:05:44 +00:00
Add new permission group
This commit is contained in:
parent
b4ccd03025
commit
6d288c54f2
@ -58,7 +58,7 @@ class BrokenExternalLink extends DataObject
|
||||
public function canView($member = false)
|
||||
{
|
||||
$member = $member ? $member : Security::getCurrentUser();
|
||||
$codes = array('content-authors', 'administrators');
|
||||
$codes = ['CMS_ACCESS_CMSMain'];
|
||||
return Permission::checkMember($member, $codes);
|
||||
}
|
||||
|
||||
|
@ -8,21 +8,16 @@ use SilverStripe\ExternalLinks\Model\BrokenExternalLink;
|
||||
class BrokenExternalLinkTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* @param int $httpCode
|
||||
* @param string $expected
|
||||
* @dataProvider httpCodeProvider
|
||||
*/
|
||||
public function testGetHTTPCodeDescription($httpCode, $expected)
|
||||
public function testGetHTTPCodeDescription(int $httpCode, string $expected)
|
||||
{
|
||||
$link = new BrokenExternalLink();
|
||||
$link->HTTPCode = $httpCode;
|
||||
$this->assertSame($expected, $link->getHTTPCodeDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
*/
|
||||
public function httpCodeProvider()
|
||||
|
||||
public function httpCodeProvider(): array
|
||||
{
|
||||
return [
|
||||
[200, '200 (OK)'],
|
||||
@ -32,4 +27,30 @@ class BrokenExternalLinkTest extends SapphireTest
|
||||
[789, '789 (Unknown Response Code)'],
|
||||
];
|
||||
}
|
||||
|
||||
public function permissionProvider(): array
|
||||
{
|
||||
return [
|
||||
['admin', 'ADMIN'],
|
||||
['content-author', 'CMS_ACCESS_CMSMain'],
|
||||
['asset-admin', 'CMS_ACCESS_AssetAdmin'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider permissionProvider
|
||||
*/
|
||||
public function testCanViewReport(string $user, string $permission)
|
||||
{
|
||||
$this->logOut();
|
||||
$this->logInWithPermission($permission);
|
||||
|
||||
$link = new BrokenExternalLink();
|
||||
|
||||
if ($user === 'asset-admin') {
|
||||
$this->assertFalse($link->canView());
|
||||
} else {
|
||||
$this->assertTrue($link->canView());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user