diff options
author | Marc Alexander <admin@m-a-styles.de> | 2015-07-16 16:30:59 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2015-09-09 08:28:08 +0200 |
commit | 46e3d8219671e996677be1943a7e3c80f1039693 (patch) | |
tree | 51097a0638fbbb49adbb6b51b76f763b53ffca30 /tests/upload/filespec_test.php | |
parent | 3e99816fa2f184b859d47308254aa8f07d68f1dd (diff) | |
download | forums-46e3d8219671e996677be1943a7e3c80f1039693.tar forums-46e3d8219671e996677be1943a7e3c80f1039693.tar.gz forums-46e3d8219671e996677be1943a7e3c80f1039693.tar.bz2 forums-46e3d8219671e996677be1943a7e3c80f1039693.tar.xz forums-46e3d8219671e996677be1943a7e3c80f1039693.zip |
[ticket/13904] Add more tests and test cases
PHPBB3-13904
Diffstat (limited to 'tests/upload/filespec_test.php')
-rw-r--r-- | tests/upload/filespec_test.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index f885b1acfc..a6ea850763 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -112,6 +112,13 @@ class phpbb_filespec_test extends phpbb_test_case } } + public function test_empty_upload_ary() + { + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path, $this->mimetype_guesser); + $this->assertInstanceOf('\phpbb\files\filespec', $filespec->set_upload_ary(array())); + $this->assertTrue($filespec->init_error()); + } + public function additional_checks_variables() { // False here just indicates the file is too large and fails the @@ -140,6 +147,19 @@ class phpbb_filespec_test extends phpbb_test_case $this->assertEquals($expected, $filespec->additional_checks()); } + public function test_additional_checks_dimensions() + { + $upload = new phpbb_mock_fileupload(); + $filespec = $this->get_filespec(); + $filespec->set_upload_namespace($upload); + $upload->valid_dimensions = false; + $filespec->file_moved = true; + $upload->max_filesize = 0; + + $this->assertEquals(false, $filespec->additional_checks()); + $this->assertSame(array('WRONG_SIZE'), $filespec->error); + } + public function check_content_variables() { // False here indicates that a file is non-binary and contains @@ -388,4 +408,27 @@ class phpbb_filespec_test extends phpbb_test_case $this->assertSame(trim(utf8_basename(htmlspecialchars($filename))), $filespec->get('uploadname')); } + + public function test_is_uploaded() + { + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->phpbb_root_path, null); + $reflection_filespec = new ReflectionClass($filespec); + $plupload_property = $reflection_filespec->getProperty('plupload'); + $plupload_property->setAccessible(true); + $plupload_mock = $this->getMockBuilder('\phpbb\plupload\plupload') + ->disableOriginalConstructor() + ->getMock(); + $plupload_mock->expects($this->any()) + ->method('is_active') + ->will($this->returnValue(true)); + $plupload_property->setValue($filespec, $plupload_mock); + $is_uploaded = $reflection_filespec->getMethod('is_uploaded'); + + // Plupload is active and file does not exist + $this->assertFalse($is_uploaded->invoke($filespec)); + + // Plupload is not active and file was not uploaded + $plupload_property->setValue($filespec, null); + $this->assertFalse($is_uploaded->invoke($filespec)); + } } |