Commit 56f0a237 authored by Ben Hayward's avatar Ben Hayward

Added back in isOnchainBooster

parent 815a1529
1 merge request!191WIP: [Sprint/GiddyGiraffe](feat): Add in delegate for checking for onchain badge
......@@ -1047,6 +1047,15 @@ class User extends \ElggUser
return "urn:user:{$this->getGuid()}";
}
/**
* Returns whether the user has onchain_booster status.
* @return boolean true if the date set in onchain_booster is larger than the current time.
*/
public function isOnchainBooster()
{
return (boolean) (time() < $this->onchain_booster);
  • boolean is an alias. bool should ideally be used. aliases blow up when used a typehints so we should avoid.

  • Thanks, was unaware of that, have amended.

Please register or sign in to reply
}
/**
* Gets the unix timestamp for the last time the user boosted onchain.
* @return int the date that a booster last boosted on chain
......
......@@ -40,4 +40,13 @@ class UserSpec extends ObjectBehavior
$this->getOnchainBooster()->shouldReturn(123);
}
function it_should_recognise_a_user_is_in_the_onchain_booster_timeframe() {
$this->setOnchainBooster(20601923579999);
$this->isOnchainBooster()->shouldReturn(true);
}
function it_should_recognise_a_user_is_not_in_the_onchain_booster_timeframe() {
$this->setOnchainBooster(1560192357);
$this->isOnchainBooster()->shouldReturn(false);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment