Passed
Push — master ( 1b6475...610123 )
by Petr
10:18
created

BasicTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 36
rs 10
c 1
b 0
f 0
wmc 2
1
<?php
2
3
namespace BasicTests;
4
5
6
use CommonTestClass;
7
use Support;
8
use kalanis\UploadPerPartes\Uploader\Calculates;
9
10
11
class BasicTest extends CommonTestClass
12
{
13
    /**
14
     * beware, i need to test this, because it's necessary for run - it happens for me to got failed testing
15
     * PHP has problems with badly defined params, it cost me 3hrs
16
     * @throws \kalanis\UploadPerPartes\Exceptions\UploadException
17
     */
18
    public function testStrings(): void
19
    {
20
        $this->assertEquals('bcdef',  substr('abcdef', 1));
21
        $this->assertEquals('bcd',    substr('abcdef', 1, 3));
22
        $this->assertEquals('abcd',   substr('abcdef', 0, 4));
23
        $this->assertEquals('abcdef', substr('abcdef', 0, 8));
24
        $this->assertEquals('f',      substr('abcdef', -1, 1));
25
26
        // now with lib
27
        $this->assertEquals('bcdef',  Support\Strings::substr('abcdef', 1, null, ''));
28
        $this->assertEquals('bcd',    Support\Strings::substr('abcdef', 1, 3, ''));
29
        $this->assertEquals('abcd',   Support\Strings::substr('abcdef', 0, 4, ''));
30
        $this->assertEquals('abcdef', Support\Strings::substr('abcdef', 0, 8, ''));
31
        $this->assertEquals('f',      Support\Strings::substr('abcdef', -1, 1, ''));
32
    }
33
34
    /**
35
     * @throws \kalanis\UploadPerPartes\Exceptions\UploadException
36
     */
37
    public function testCalculate(): void
38
    {
39
        $lib = new Calculates();
40
        $this->assertEquals(Calculates::DEFAULT_BYTES_PER_PART, $lib->getBytesPerPart());
41
42
        $lib2 = new Calculates(20);
43
        $this->assertEquals(20, $lib2->getBytesPerPart());
44
        $this->assertEquals(2, $lib2->calcParts(35));
45
        $this->assertEquals(2, $lib2->calcParts(40));
46
        $this->assertEquals(3, $lib2->calcParts(41));
47
    }
48
}
49