initOutput(\rcmail_action::MODE_HTTP, 'settings', 'save-response'); $this->assertInstanceOf(\rcmail_action::class, $action); $this->assertTrue($action->checks()); $rcmail = \rcmail::get_instance(); $rcmail->user->save_prefs(['compose_responses_static' => []]); self::initDB('responses'); $responses = $rcmail->get_compose_responses(); // Test updating an existing response $_POST = [ '_id' => $responses[0]['id'], '_name' => 'name1', '_text' => 'text1', ]; $action->run(); $this->assertSame('edit-response', \rcmail::get_instance()->action); $this->assertSame('successfullysaved', $output->getProperty('message')); $response = $rcmail->get_compose_response($responses[0]['id']); $this->assertSame('name1', $response['name']); $this->assertSame('text1', $response['data']); $this->assertTrue(empty($response['is_html'])); // Test updating an existing response (change format) $_POST = [ '_id' => $responses[0]['id'], '_name' => 'name2', '_text' => '

text2

', '_is_html' => 1, ]; $action->run(); $this->assertSame('edit-response', \rcmail::get_instance()->action); $this->assertSame('successfullysaved', $output->getProperty('message')); $response = $rcmail->get_compose_response($responses[0]['id']); $this->assertSame('name2', $response['name']); $this->assertSame('

text2

', $response['data']); $this->assertTrue(!empty($response['is_html'])); // Test adding a response $_POST = [ '_name' => 'aaa', '_text' => '

text3

', '_is_html' => 1, ]; $action->run(); $this->assertSame('edit-response', \rcmail::get_instance()->action); $this->assertSame('successfullysaved', $output->getProperty('message')); $responses = $rcmail->get_compose_responses(); $response = $rcmail->get_compose_response($responses[0]['id']); $this->assertSame('aaa', $responses[0]['name']); $this->assertSame('

text3

', $response['data']); $this->assertTrue(!empty($response['is_html'])); // TODO: Test error handling } }