RateLimiterTest::testSetUp()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
1
<?php
2
namespace RazonYang\Yii2\RateLimiter\Tests\Unit\Redis;
3
4
use Codeception\Test\Unit;
5
use RazonYang\Yii2\RateLimiter\Redis\RateLimiter;
6
use Yii;
7
8
class RateLimiterTest extends Unit
9
{
10
    /**
11
     * @dataProvider dataSetUp
12
     */
13
    public function testSetUp(array $config): void
14
    {
15
        $limiter = new RateLimiter($config);
16
        $redis = $limiter->redis;
17
        $this->assertSame(Yii::$app->get('redis'), $redis);
18
        foreach ($config as $name => $val) {
19
            $this->assertSame($val, $limiter->$name);
20
        }
21
    }
22
23
    public function dataSetUp(): array
24
    {
25
        return [
26
            [['ttl' => 0, 'prefix' => 'foo']],
27
            [['ttl' => 60, 'prefix' => 'bar']],
28
        ];
29
    }
30
}
31