UploadModelTraitTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 11
c 1
b 0
f 0
dl 0
loc 35
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A dataProviderExtensions() 0 7 1
A testExtensions() 0 5 1
A testRules() 0 3 1
A testUpload() 0 2 1
A createModel() 0 3 1
1
<?php
2
namespace RazonYang\Yii2\Setting\Tests\Unit;
3
4
use Codeception\Test\Unit;
5
use RazonYang\Yii2\Uploader\Tests\TestModel;
6
use yii\web\UploadedFile;
7
8
class UploadModelTraitTest extends Unit
9
{
10
    private function createModel(): TestModel
11
    {
12
        return new TestModel();
13
    }
14
15
    /**
16
     * @dataProvider dataProviderExtensions
17
     */
18
    public function testExtensions($extensions, array $expected): void
19
    {
20
        $model = $this->createModel();
21
        $model->setExtensions($extensions);
22
        $this->assertEquals($expected, $model->getExtensions());
23
    }
24
25
    public function dataProviderExtensions(): array
26
    {
27
        return [
28
            ['jpg', ['jpg']],
29
            ['jpg,gif', ['jpg','gif']],
30
            [['jpg'], ['jpg']],
31
            [['jpg', 'gif'], ['jpg','gif']],
32
        ];
33
    }
34
35
    public function testRules(): void
36
    {
37
        $this->assertIsArray($this->createModel()->rules());
38
    }
39
40
    // TODO
41
    public function testUpload(): void
42
    {
43
    }
44
}
45