Completed
Push — master ( 36af8e...9a1b95 )
by Sebastian
01:54
created

FileTest::testConstructNoType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of SebastianFeldmann\Ftp.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace SebastianFeldmann\Ftp;
11
12
use PHPUnit\Framework\TestCase;
13
14
/**
15
 * Class FileTest
16
 *
17
 * @package SebastianFeldmann\Ftp
18
 */
19
class FileTest extends TestCase
20
{
21
    /**
22
     * Tests File::__construct
23
     *
24
     * @expectedException \Exception
25
     */
26
    public function testConstructNoType()
27
    {
28
        $file = new File([]);
29
    }
30
31
    /**
32
     * Tests File::__construct
33
     *
34
     * @expectedException \Exception
35
     */
36
    public function testConstructNoName()
37
    {
38
        $file = new File(['type' => 'file']);
39
    }
40
41
    /**
42
     * Tests File::__construct
43
     */
44
    public function testConstructNoMtime()
45
    {
46
        $file = new File(['type' => 'file', 'name' => 'foo.txt', 'size' => 100]);
47
        $date = $file->getLastModifyDate();
48
49
        $this->assertTrue(is_a($date, \DateTimeImmutable::class));
50
    }
51
52
    /**
53
     * Tests File::getUniqueName
54
     */
55
    public function testGetUnique()
56
    {
57
        $file = new File(['type' => 'file', 'name' => 'foo.txt', 'size' => 100, 'unique' => 'UN']);
58
        $this->assertEquals('UN', $file->getUniqueName());
59
    }
60
61
    /**
62
     * Tests File::isDir
63
     */
64
    public function testIsDir()
65
    {
66
        $file = new File(['type' => 'file', 'name' => 'foo.txt', 'size' => 100, 'unique' => 'UN']);
67
        $this->assertFalse($file->isDir());
68
        $this->assertTrue($file->isFile());
69
    }
70
71
    /**
72
     * Tests File::isDir
73
     */
74
    public function testIsFile()
75
    {
76
        $file = new File(['type' => 'dir', 'name' => 'foo.txt', 'size' => 100, 'unique' => 'UN']);
77
        $this->assertTrue($file->isDir());
78
        $this->assertFalse($file->isFile());
79
    }
80
}
81