Apply new limit to new users
I refactored the SubscribersFeature class so that it's easily unit tested. Computing the subscribers count in the constructor is better then computing it on every call to check(). [MAILPOET-2394]
This commit is contained in:
committed by
Jack Kitterhing
parent
53e0934a87
commit
042557aafa
54
tests/unit/Util/License/Features/SubscribersTest.php
Normal file
54
tests/unit/Util/License/Features/SubscribersTest.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Test\Util\License\Features;
|
||||
|
||||
use Codeception\Util\Stub;
|
||||
use MailPoet\Util\License\Features\Subscribers as SubscribersFeature;
|
||||
|
||||
class SubscribersTest extends \MailPoetUnitTest {
|
||||
|
||||
function testCheckReturnsTrueIfOldUserReachedLimit() {
|
||||
$subscribers_feature = Stub::make(SubscribersFeature::class, [
|
||||
'license' => false,
|
||||
'installation_time' => strtotime('2018-11-11'),
|
||||
'subscribers_count' => 2500,
|
||||
]);
|
||||
expect($subscribers_feature->check())->true();
|
||||
}
|
||||
|
||||
function testCheckReturnsFalseIfOldUserDidntReachLimit() {
|
||||
$subscribers_feature = Stub::make(SubscribersFeature::class, [
|
||||
'license' => false,
|
||||
'installation_time' => strtotime('2018-11-11'),
|
||||
'subscribers_count' => 1500,
|
||||
]);
|
||||
expect($subscribers_feature->check())->false();
|
||||
}
|
||||
|
||||
function testCheckReturnsTrueIfNewUserReachedLimit() {
|
||||
$subscribers_feature = Stub::make(SubscribersFeature::class, [
|
||||
'license' => false,
|
||||
'installation_time' => strtotime('2019-11-11'),
|
||||
'subscribers_count' => 1500,
|
||||
]);
|
||||
expect($subscribers_feature->check())->true();
|
||||
}
|
||||
|
||||
function testCheckReturnsFalseIfNewUserDidntReachLimit() {
|
||||
$subscribers_feature = Stub::make(SubscribersFeature::class, [
|
||||
'license' => false,
|
||||
'installation_time' => strtotime('2019-11-11'),
|
||||
'subscribers_count' => 900,
|
||||
]);
|
||||
expect($subscribers_feature->check())->false();
|
||||
}
|
||||
|
||||
function testCheckReturnsFalseIfLicenseExists() {
|
||||
$subscribers_feature = Stub::make(SubscribersFeature::class, [
|
||||
'license' => true,
|
||||
'installation_time' => strtotime('2019-11-11'),
|
||||
'subscribers_count' => 1500,
|
||||
]);
|
||||
expect($subscribers_feature->check())->false();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user