コード例 #1
0
ファイル: types_remote_test.php プロジェクト: phpbb/phpbb
 public function test_upload_wrong_path()
 {
     $type_remote = new \phpbb\files\types\foo($this->config, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
     $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
     $upload->set_allowed_extensions(array('png'));
     $type_remote->set_upload($upload);
     $type_remote::$tempnam_path = $this->phpbb_root_path . 'cache/wrong/path';
     $file = $type_remote->upload('http://google.com/?.png');
     $this->assertSame(array('NOT_UPLOADED'), $file->error);
     $type_remote::$tempnam_path = '';
 }
コード例 #2
0
ファイル: types_local_test.php プロジェクト: phpbb/phpbb
 /**
  * @dataProvider data_upload_form
  */
 public function test_upload_form($filename, $upload_ary, $expected)
 {
     $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, new \phpbb\mimetype\guesser(array('mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser())));
     $filespec_local = new ReflectionProperty($filespec, 'local');
     $filespec_local->setAccessible(true);
     $filespec_local->setValue($filespec, true);
     $this->container->set('files.filespec', $filespec);
     $this->factory = new \phpbb\files\factory($this->container);
     $type_local = new \phpbb\files\types\local($this->factory, $this->language, $this->php_ini, $this->request);
     $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
     $upload->set_allowed_extensions(array('png'));
     $type_local->set_upload($upload);
     $file = $type_local->upload($filename, $upload_ary);
     $this->assertSame($expected, $file->error);
     $this->assertInstanceOf('\\phpbb\\files\\filespec', $file);
 }
コード例 #3
0
ファイル: types_form_test.php プロジェクト: phpbb/phpbb
 /**
  * @dataProvider data_upload_form
  */
 public function test_upload_form($upload, $expected, $plupload = array())
 {
     $this->request = $this->getMock('\\phpbb\\request\\request');
     $this->request->expects($this->any())->method('file')->willReturn($upload);
     $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, new \phpbb\mimetype\guesser(array('mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser())));
     $this->container->set('files.filespec', $filespec);
     $this->factory = new \phpbb\files\factory($this->container);
     $this->plupload = $this->getMockBuilder('\\phpbb\\plupload\\plupload')->disableOriginalConstructor()->getMock();
     $this->plupload->expects($this->any())->method('handle_upload')->willReturn($plupload);
     $type_form = new \phpbb\files\types\form($this->factory, $this->language, $this->php_ini, $this->plupload, $this->request);
     $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
     $upload->set_allowed_extensions(array('png'));
     $type_form->set_upload($upload);
     $file = $type_form->upload('foobar');
     $this->assertSame($expected, $file->error);
     $this->assertInstanceOf('\\phpbb\\files\\filespec', $file);
 }
コード例 #4
0
ファイル: fileupload_test.php プロジェクト: MrAdder/phpbb
 public function test_valid_dimensions()
 {
     $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
     $upload->set_allowed_extensions(false)->set_max_filesize(false)->set_allowed_dimensions(1, 1, 100, 100);
     $file1 = $this->gen_valid_filespec();
     $file2 = $this->gen_valid_filespec();
     $file2->height = 101;
     $file3 = $this->gen_valid_filespec();
     $file3->width = 0;
     $this->assertTrue($upload->valid_dimensions($file1));
     $this->assertFalse($upload->valid_dimensions($file2));
     $this->assertFalse($upload->valid_dimensions($file3));
 }