mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-03-21 23:36:58 +01:00
* Fix "method_argument_space" * Fix "control_structure_continuation_position" * Fix "new_with_parentheses" * Fix "blank_line_before_statement" * Fix "visibility_required" * Fix some "array_indentation" * Fix some "array_indentation" - unify all "rcube::raise_error" calls * rm useless eslint ignores and add rules counts * sort eslint ignores * fix eslint ignores grammar * Revert "Fix "blank_line_before_statement"" * fix CS 3.46.0
41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Test class to test rcmail_action_mail_attachment_rename
|
|
*/
|
|
class Actions_Mail_AttachmentRename extends ActionTestCase
|
|
{
|
|
/**
|
|
* Test uploaded attachment rename
|
|
*/
|
|
public function test_run()
|
|
{
|
|
$rcmail = rcube::get_instance();
|
|
$action = new rcmail_action_mail_attachment_rename();
|
|
$output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'rename-attachment');
|
|
|
|
$this->assertInstanceOf('rcmail_action', $action);
|
|
$this->assertTrue($action->checks());
|
|
|
|
// First we create the upload record
|
|
$file = $this->fileUpload('100');
|
|
|
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
|
$_SESSION = ['compose_data_100' => ['test' => 'test']];
|
|
|
|
// Invoke the rename action
|
|
$_POST = ['_id' => '100', '_file' => 'rcmfile' . $file['id'], '_name' => 'mod.gif'];
|
|
$this->runAndAssert($action, OutputJsonMock::E_EXIT);
|
|
|
|
$result = $output->getOutput();
|
|
|
|
$this->assertSame(['Content-Type: application/json; charset=UTF-8'], $output->headers);
|
|
$this->assertSame('rename-attachment', $result['action']);
|
|
$this->assertSame('this.rename_attachment_handler("rcmfile' . $file['id'] . '","mod.gif");', trim($result['exec']));
|
|
|
|
$upload = rcube::get_instance()->get_uploaded_file($file['id']);
|
|
$this->assertSame($_POST['_name'], $upload['name']);
|
|
$this->assertSame($_POST['_id'], $upload['group']);
|
|
}
|
|
}
|