Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tests for file upload size limits

git-svn-id: http://svn.php.net/repository/pear/packages/HTTP_Upload/trunk@287437 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit c3b17b240cac4a71bb205bda3c87ef6032151648 1 parent 3dce687
@cweiske cweiske authored
View
1  tests/files/10b.exe
@@ -0,0 +1 @@
+1234567890
View
1  tests/files/10b.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  tests/files/10b.pdf
Binary file not shown
View
1  tests/files/10b.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
1  tests/files/10b.txt
@@ -0,0 +1 @@
+1234567890
View
42 tests/toolarge-2.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Uploaded file is too large (post_max_size)
+--INI--
+post_max_size=5
+--POST--
+MAX_FILE_SIZE=100000
+--UPLOAD--
+userfile=files/10b
+--FILE--
+<?php
+require_once 'HTTP/Upload.php';
+$up = new HTTP_Upload();
+$file = $up->getFiles('userfile');
+echo "Valid: "; var_dump($file->isValid());
+echo "Missing: "; var_dump($file->isMissing());
+echo "Error: "; var_dump($file->isError());
+
+var_dump($file->getProp());
+?>
+--EXPECTF--
+Warning: POST Content-Length of 338 bytes exceeds the limit of 5 bytes in Unknown on line 0
+Valid: bool(false)
+Missing: bool(false)
+Error: bool(true)
+array(8) {
+ ["real"]=>
+ string(6) "_error"
+ ["name"]=>
+ string(6) "_error"
+ ["form_name"]=>
+ NULL
+ ["ext"]=>
+ NULL
+ ["tmp_name"]=>
+ NULL
+ ["size"]=>
+ NULL
+ ["type"]=>
+ NULL
+ ["error"]=>
+ string(9) "TOO_LARGE"
+}
View
42 tests/toolarge-3.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Uploaded file is too large (upload_max_filesize)
+--INI--
+upload_max_filesize=5
+--POST--
+MAX_FILE_SIZE=100000
+--UPLOAD--
+userfile=files/10b
+--FILE--
+<?php
+require_once 'HTTP/Upload.php';
+$up = new HTTP_Upload();
+$file = $up->getFiles('userfile');
+echo "Valid: "; var_dump($file->isValid());
+echo "Missing: "; var_dump($file->isMissing());
+echo "Error: "; var_dump($file->isError());
+
+var_dump($file->getProp());
+?>
+--EXPECTF--
+Notice: upload_max_filesize of 5 bytes exceeded - file [userfile=10b] not saved in Unknown on line 0
+Valid: bool(false)
+Missing: bool(false)
+Error: bool(true)
+array(8) {
+ ["real"]=>
+ string(3) "10b"
+ ["name"]=>
+ string(3) "10b"
+ ["form_name"]=>
+ string(8) "userfile"
+ ["ext"]=>
+ NULL
+ ["tmp_name"]=>
+ string(0) ""
+ ["size"]=>
+ int(0)
+ ["type"]=>
+ string(0) ""
+ ["error"]=>
+ string(9) "TOO_LARGE"
+}
Please sign in to comment.
Something went wrong with that request. Please try again.