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
|
|
|
|