Example #1
0
 /**
  * @dataProvider data_check_upload_size
  */
 public function test_check_upload_size($filename, $max_filesize, $expected)
 {
     $php_ini = $this->getMock('\\bantu\\IniGetWrapper\\IniGetWrapper');
     $php_ini->expects($this->any())->method('getString')->willReturn($max_filesize);
     $type_form = new \phpbb\files\types\local($this->factory, $this->language, $php_ini, $this->request);
     $file = $this->getMockBuilder('\\phpbb\\files\\filespec')->disableOriginalConstructor()->getMock();
     $file->expects($this->any())->method('get')->willReturn($filename);
     $type_form->check_upload_size($file);
     $this->assertSame($expected, $file->error);
 }
Example #2
0
 /**
  * @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);
 }