Test Failed
Push — master ( c65274...a98fd4 )
by Alexander
18:33
created

TokenRepositorySettingsTest::testVerifyLimit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Wearesho\Yii\Tests\Configs;
6
7
use PHPUnit\Framework\TestCase;
8
9
use Wearesho\Yii\Configs\TokenRepositoryConfig;
10
11
class TokenRepositorySettingsTest extends TestCase
12
{
13
    protected TokenRepositoryConfig $config;
14
15
    /**
16
     * @throws \yii\base\InvalidConfigException
17
     * @throws \yii\di\NotInstantiableException
18
     */
19
    protected function setUp(): void
20
    {
21
        parent::setUp();
22
        $this->config = \Yii::$container->get(TokenRepositoryConfig::class);
23
    }
24
25
    public function testExpire()
26
    {
27
        putenv("{$this->config->expirePeriodKey}=0");
28
29
        $this->config->defaultExpirePeriod = $expirePeriod = mt_rand(1, 10);
30
        $this->assertEquals($expirePeriod, $this->config->getExpirePeriod()->minutes);
31
32
        $this->config->defaultExpirePeriod = 0;
33
        putenv("{$this->config->expirePeriodKey}={$expirePeriod}");
34
        $this->assertEquals($expirePeriod, $this->config->getExpirePeriod()->minutes);
35
    }
36
37
    public function testDeliveryLimit()
38
    {
39
        putenv("{$this->config->deliveryLimitKey}=0");
40
41
        $this->config->defaultDeliveryLimit = $deliveryLimit = mt_rand(1, 10);
42
        $this->assertEquals($deliveryLimit, $this->config->getDeliveryLimit());
43
44
        $this->config->defaultDeliveryLimit = 0;
45
        putenv("{$this->config->deliveryLimitKey}={$deliveryLimit}");
46
        $this->assertEquals($deliveryLimit, $this->config->getDeliveryLimit());
47
    }
48
49
    public function testVerifyLimit()
50
    {
51
        putenv("{$this->config->verifyLimitKey}=0");
52
53
        $this->config->defaultVerifyLimit = $verifyLimit = mt_rand(1, 10);
54
        $this->assertEquals($verifyLimit, $this->config->getVerifyLimit());
55
56
        $this->config->defaultVerifyLimit = 0;
57
        putenv("{$this->config->verifyLimitKey}={$verifyLimit}");
58
        $this->assertEquals($verifyLimit, $this->config->getVerifyLimit());
59
    }
60
}
61