Commit 5f801ecc authored by Ben Hayward's avatar Ben Hayward

test update

1 merge request!279[Sprint/JollyJellyfish](feat): Added plus tiers to endpoint and passed through #578
Pipeline #72129790 passed with stages
in 9 minutes and 16 seconds
......@@ -89,7 +89,8 @@ class Plus
* @param [Integer] $previousTimestamp - the users previous subscription unix timestamp.
* @return [Integer] the new unix expiry date.
*/
public function calculatePlusExpires($timespan, $wireTimestamp, $previousTimestamp = null) {
public function calculatePlusExpires($timespan, $wireTimestamp, $previousTimestamp = null)
{
if ($previousTimestamp === 9999999999) {
throw new \Exception('Already existing lifetime subscription');
}
......
......@@ -145,7 +145,8 @@ class PlusSpec extends ObjectBehavior
}
function it_should_not_make_a_user_plus_if_onchain_wire_wrong(
Config $config
Config $config,
User $sender
)
{
$this->beConstructedWith($config);
......@@ -176,4 +177,40 @@ class PlusSpec extends ObjectBehavior
$wire->getSender()->isPlus()->shouldBe(false);
}
function it_should_return_expiry_time_for_not_plus_already_subscriber_one_month()
{
$wireTimestamp = time();
$previousTimestamp = 10000;
$this->calculatePlusExpires("+30 days", $wireTimestamp, $previousTimestamp)
->shouldEqualApproximately(strtotime('+30 days', time()), 1.0e-9);
}
function it_should_return_expiry_time_for_not_plus_already_subscriber_one_year()
{
$wireTimestamp = time();
$previousTimestamp = 10000;
$this->calculatePlusExpires("+1 year", $wireTimestamp, $previousTimestamp)
->shouldEqualApproximately(strtotime('+1 year', time()), 1.0e-9);
}
function it_should_return_expiry_time_for_existing_1_year_plus_a_new_month()
{
$wireTimestamp = time();
$previousTimestamp = strtotime('+11 months', time()); //already subbed for the next 11 momths
$this->calculatePlusExpires("+1 month", $wireTimestamp, $previousTimestamp)
->shouldEqualApproximately(strtotime('+1 year', time()), 1.0e-9);
}
function it_should_return_expiry_time_for_existing_monthly_subscription_upgrade_to_year()
{
$wireTimestamp = time();
$previousTimestamp = strtotime('+1 months', time()); //already subbed for the next 11 month
$this->calculatePlusExpires("+1 year", $wireTimestamp, $previousTimestamp)
->shouldEqualApproximately(strtotime('+13 months', time()), 1.0e-9);
}
}
\ No newline at end of file
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