Skip to content
Snippets Groups Projects
Commit e4f926cb authored by Eirik Morland's avatar Eirik Morland
Browse files

Issue #3453770: Add a method to indicate if a team can view logs

parent a88b687f
No related branches found
No related tags found
1 merge request!63Add the method
Pipeline #196032 passed with warnings
......@@ -25,6 +25,19 @@ class TeamNode extends Node {
const BILLING_ENABLED_FIELD = 'field_send_receipts';
const BILLING_EMAIL_FIELD = 'field_billing_email';
/**
* Helper to return if the team has access or not.
*/
public function canViewLogs() : bool {
$plan_id = $this->getPlan()->getId();
$allowed_to_view_logs = [
PlanInterface::PREMIUM_PLAN,
PlanInterface::AGENCY_PLAN,
PlanInterface::ENTERPRISE_PLAN,
];
return in_array($plan_id, $allowed_to_view_logs);
}
/**
* Get the env variables.
*
......
......@@ -24,6 +24,21 @@ class TeamNodeTest extends KernelTestBase {
self::assertInstanceOf(TeamNode::class, $node);
}
/**
* Test the ::canViewLogs method.
*/
public function testLogAccess() {
/** @var \Drupal\violinist_teams\TeamNode $node */
$node = Node::create([
'type' => $this->nodeType->id(),
]);
self::assertFalse($node->canViewLogs());
$node->setPlan(PlanInterface::AGENCY_PLAN);
self::assertTrue($node->canViewLogs());
$node->setPlan(PlanInterface::DEFAULT_PLAN);
self::assertFalse($node->canViewLogs());
}
/**
* Test append member method.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment