-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUploadTest.php
More file actions
115 lines (98 loc) · 3.58 KB
/
Copy pathUploadTest.php
File metadata and controls
115 lines (98 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
namespace FloatPHP\Tests\Classes\Http;
use PHPUnit\Framework\TestCase;
use FloatPHP\Classes\Http\Upload;
/**
* Test Upload class.
*/
final class UploadTest extends TestCase
{
public function testUploadMethodsExist(): void
{
// Upload class has static methods: get, set, isSetted, unset, move, handle, sanitize, getMimes
$this->assertTrue(method_exists(Upload::class, 'get'));
$this->assertTrue(method_exists(Upload::class, 'set'));
$this->assertTrue(method_exists(Upload::class, 'isSetted'));
$this->assertTrue(method_exists(Upload::class, 'unset'));
$this->assertTrue(method_exists(Upload::class, 'move'));
$this->assertTrue(method_exists(Upload::class, 'handle'));
$this->assertTrue(method_exists(Upload::class, 'sanitize'));
$this->assertTrue(method_exists(Upload::class, 'getMimes'));
}
public function testUploadClassExists(): void
{
$this->assertTrue(class_exists(Upload::class));
}
public function testUploadConstants(): void
{
// Test upload error constants
$this->assertTrue(defined('UPLOAD_ERR_OK'));
$this->assertTrue(defined('UPLOAD_ERR_INI_SIZE'));
$this->assertTrue(defined('UPLOAD_ERR_FORM_SIZE'));
$this->assertTrue(defined('UPLOAD_ERR_PARTIAL'));
$this->assertTrue(defined('UPLOAD_ERR_NO_FILE'));
$this->assertTrue(defined('UPLOAD_ERR_NO_TMP_DIR'));
$this->assertTrue(defined('UPLOAD_ERR_CANT_WRITE'));
}
public function testGetMimes(): void
{
$mimes = Upload::getMimes();
$this->assertIsArray($mimes);
}
public function testGetMimesWithTypes(): void
{
$mimes = Upload::getMimes(['jpg', 'png']);
$this->assertIsArray($mimes);
}
public function testGetMethod(): void
{
$result = Upload::get();
$this->assertTrue($result === null || is_array($result));
}
public function testGetWithKey(): void
{
$result = Upload::get('test_file');
$this->assertTrue($result === null || is_array($result));
}
public function testIsSettedMethod(): void
{
$this->assertIsBool(Upload::isSet());
}
public function testIsSettedWithKey(): void
{
$this->assertIsBool(Upload::isSet('test_file'));
}
public function testSanitizeMethod(): void
{
$files = [];
$sanitized = Upload::sanitize($files);
$this->assertIsArray($sanitized);
}
public function testMoveMethod(): void
{
// Test move method exists and returns boolean
$this->assertTrue(method_exists(Upload::class, 'move'));
}
public function testHandleMethod(): void
{
// Test handle method exists
$this->assertTrue(method_exists(Upload::class, 'handle'));
}
public function testUploadClassStructure(): void
{
$reflection = new \ReflectionClass(Upload::class);
$this->assertTrue($reflection->isFinal());
$this->assertEquals('FloatPHP\Classes\Http', $reflection->getNamespaceName());
}
public function testUploadStaticMethods(): void
{
$reflection = new \ReflectionClass(Upload::class);
$methods = $reflection->getMethods(\ReflectionMethod::IS_STATIC);
$methodNames = array_map(fn($method) => $method->getName(), $methods);
$this->assertContains('get', $methodNames);
$this->assertContains('set', $methodNames);
$this->assertContains('isSetted', $methodNames);
$this->assertContains('move', $methodNames);
$this->assertContains('handle', $methodNames);
}
}