Skip to content

Commit

Permalink
Merge branch '2.2' into 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed May 5, 2022
2 parents 3721dab + d4871e7 commit e743b90
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Model/BrokenExternalLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function canEdit($member = false)
public function canView($member = false)
{
$member = $member ? $member : Security::getCurrentUser();
$codes = array('content-authors', 'administrators');
$codes = ['CMS_ACCESS_CMSMain'];
return Permission::checkMember($member, $codes);
}

Expand Down
37 changes: 29 additions & 8 deletions tests/php/Model/BrokenExternalLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,16 @@
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)'],
Expand All @@ -32,4 +27,30 @@ public function httpCodeProvider()
[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());
}
}
}

0 comments on commit e743b90

Please sign in to comment.