UploadModelTraitTest::testRules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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