Skip to content

Commit 03f6a66

Browse files
committed
:octocat: +unwritable dir test
1 parent 8beba5d commit 03f6a66

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/Psr7/UploadedFileTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
use function basename, file_exists, fopen, is_scalar, sys_get_temp_dir, tempnam, uniqid, unlink;
2626

2727
use const UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_INI_SIZE,
28-
UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_OK, UPLOAD_ERR_PARTIAL;
28+
UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_OK, UPLOAD_ERR_PARTIAL, PHP_OS_FAMILY;
2929

3030
class UploadedFileTest extends TestCase{
3131

@@ -152,6 +152,20 @@ public function testCannotMoveToEmptyTarget(){
152152
$upload->moveTo('');
153153
}
154154

155+
public function testCannotMoveToUnwritableDirectory(){
156+
157+
if(PHP_OS_FAMILY !== 'Linux'){
158+
$this->markTestSkipped('testing Linux only');
159+
}
160+
161+
$stream = create_stream('Foo bar!');
162+
$upload = new UploadedFile($stream, 0);
163+
164+
$this->expectException(RuntimeException::class);
165+
$this->expectExceptionMessage('Directory is not writable');
166+
$upload->moveTo('/boot');
167+
}
168+
155169
public function nonOkErrorStatus(){
156170
return [
157171
'UPLOAD_ERR_INI_SIZE' => [UPLOAD_ERR_INI_SIZE],

0 commit comments

Comments
 (0)