diff options
Diffstat (limited to 'tests/Actions/Mail/AttachmentRename.php')
-rw-r--r-- | tests/Actions/Mail/AttachmentRename.php | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/tests/Actions/Mail/AttachmentRename.php b/tests/Actions/Mail/AttachmentRename.php index dde8593a8..8474cd451 100644 --- a/tests/Actions/Mail/AttachmentRename.php +++ b/tests/Actions/Mail/AttachmentRename.php @@ -8,12 +8,35 @@ class Actions_Mail_AttachmentRename extends ActionTestCase { /** - * Class constructor + * Test uploaded attachment rename */ - function test_class() + function test_run() { - $object = new rcmail_action_mail_attachment_rename; + $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', $object); + $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']); } } |