UploaderTest::testSaveFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 2
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\Uploader;
6
7
class UploaderTest extends Unit
8
{
9
    private $host = 'http://localhost/';
10
11
    private function createUploader(): Uploader
12
    {
13
        return new Uploader([
14
            'host' => $this->host,
15
        ]);
16
    }
17
18
    /**
19
     * @dataProvider dataProviderHost
20
     */
21
    public function testHost(string $host, string $expected): void
22
    {
23
        $uploader = $this->createUploader();
24
        $uploader->setHost($host);
25
        $this->assertSame($expected, $uploader->getHost());
26
    }
27
28
    public function dataProviderHost(): array
29
    {
30
        return [
31
            ['http://localhost', 'http://localhost/'],
32
            ['http://localhost/', 'http://localhost/'],
33
        ];
34
    }
35
36
    /**
37
     * @dataProvider dataProviderPath
38
     */
39
    public function testGetUrl(string $path, string $url): void
40
    {
41
        $uploader = $this->createUploader();
42
        $this->assertSame($url, $uploader->getUrl($path));
43
    }
44
45
    public function dataProviderPath(): array
46
    {
47
        return [
48
            ['foo.jpg', $this->host . 'foo.jpg'],
49
            ['bar.mp4', $this->host . 'bar.mp4'],
50
        ];
51
    }
52
53
    /**
54
     * @dataProvider dataProviderUrl
55
     */
56
    public function testGetPath(string $url, string $path): void
57
    {
58
        $uploader = $this->createUploader();
59
        $this->assertSame($path, $uploader->getPath($url));
60
    }
61
62
    public function dataProviderUrl(): array
63
    {
64
        return [
65
            [$this->host . 'foo.jpg', 'foo.jpg'],
66
            [$this->host . 'bar.mp4','bar.mp4'],
67
        ];
68
    }
69
70
    // TODO
71
    public function testSave(): void
72
    {
73
    }
74
75
    // TODO
76
    public function testSaveStream(): void
77
    {
78
    }
79
80
    // TODO
81
    public function testSaveFile(): void
82
    {
83
    }
84
}
85