mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/17361] Update thumbnail_test test
PHPBB-17361
This commit is contained in:
parent
4becf438e1
commit
9bf9538dc6
2 changed files with 21 additions and 9 deletions
|
@ -151,11 +151,12 @@ class generate extends \phpbb\console\command\command
|
|||
$destination = tempnam(sys_get_temp_dir(), 'thumbnail_destination');
|
||||
|
||||
file_put_contents($source, $this->storage->read($row['physical_filename']));
|
||||
@unlink($source);
|
||||
|
||||
if (create_thumbnail($source, $destination, $row['mimetype']))
|
||||
{
|
||||
$this->storage->write('thumb_' . $row['physical_filename'], fopen($destination, 'rb'));
|
||||
|
||||
@unlink($source);
|
||||
@unlink($destination);
|
||||
|
||||
$thumbnail_created[] = (int) $row['attach_id'];
|
||||
|
|
|
@ -24,6 +24,7 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
|
|||
protected $config;
|
||||
protected $cache;
|
||||
protected $user;
|
||||
protected $storage;
|
||||
protected $phpEx;
|
||||
protected $phpbb_root_path;
|
||||
protected $application;
|
||||
|
@ -46,11 +47,10 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
|
|||
|
||||
$config = $this->config = new \phpbb\config\config(array(
|
||||
'img_min_thumb_filesize' => 2,
|
||||
'img_max_thumb_width' => 2,
|
||||
'upload_path' => 'files',
|
||||
'img_max_thumb_width' => 2
|
||||
));
|
||||
|
||||
$this->db = $this->db = $this->new_dbal();
|
||||
$this->db = $this->new_dbal();
|
||||
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
|
||||
$this->user = new \phpbb\user($this->language, '\phpbb\datetime');
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
|
@ -62,13 +62,24 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
|
|||
'txt' => array('display_cat' => attachment_category::NONE),
|
||||
)));
|
||||
|
||||
$this->application = new Application();
|
||||
$this->application->add(new generate($config, $this->user, $this->db, $this->cache, $this->phpbb_root_path, $this->phpEx));
|
||||
$this->application->add(new delete($config, $this->user, $this->db, $this->phpbb_root_path));
|
||||
$this->application->add(new recreate($this->user));
|
||||
|
||||
$phpbb_filesystem = new \phpbb\filesystem\filesystem();
|
||||
|
||||
$this->storage = $this->createMock('\phpbb\storage\storage');
|
||||
$this->storage->method('write')->willReturnCallback(function ($path, $data) use ($phpbb_root_path) {
|
||||
file_put_contents($phpbb_root_path . 'files/' . $path, $data);
|
||||
});
|
||||
$this->storage->method('read')->willReturnCallback(function ($path) use ($phpbb_root_path) {
|
||||
return fopen($phpbb_root_path . 'files/' . $path, 'rb');
|
||||
});
|
||||
$this->storage->method('delete')->willReturnCallback(function ($path) use ($phpbb_root_path) {
|
||||
unlink($phpbb_root_path . 'files/' . $path);
|
||||
});
|
||||
|
||||
$this->application = new Application();
|
||||
$this->application->add(new generate($this->user, $this->db, $this->cache, $this->language, $this->storage, $this->phpbb_root_path, $this->phpEx));
|
||||
$this->application->add(new delete($this->user, $this->db, $this->language, $this->storage));
|
||||
$this->application->add(new recreate($this->user, $this->language));
|
||||
|
||||
copy(__DIR__ . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_1');
|
||||
copy(__DIR__ . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_2');
|
||||
copy(__DIR__ . '/fixtures/png.png', $this->phpbb_root_path . 'files/thumb_test_png_2');
|
||||
|
|
Loading…
Add table
Reference in a new issue