initOutput(\rcmail_action::MODE_HTTP, 'settings', 'edit-response'); $this->assertInstanceOf(\rcmail_action::class, $action); $this->assertTrue($action->checks()); $rcmail = \rcmail::get_instance(); $rcmail->user->save_prefs([ 'compose_responses_static' => [ ['name' => 'static 1', 'text' => 'Static Response One'], ], ]); self::initDB('responses'); $responses = $rcmail->get_compose_responses(); // Test read-only response $_GET = ['_id' => $responses[0]['id']]; $this->runAndAssert($action, OutputHtmlMock::E_EXIT); $result = $output->getOutput(); $this->assertSame('responseedit', $output->template); $this->assertSame('Edit response', $output->getProperty('pagetitle')); $this->assertTrue($output->get_env('readonly')); $this->assertTrue(stripos($result, '') === 0); $this->assertTrue(strpos($result, "rcmail.gui_object('editform', 'form')") !== false); $this->assertTrue(strpos($result, 'tinymce.min.js') !== false); $this->assertTrue(strpos($result, 'Static Response One') !== false); // Test writable response $_GET = ['_id' => $responses[2]['id']]; $this->runAndAssert($action, OutputHtmlMock::E_EXIT); $result = $output->getOutput(); $this->assertSame('responseedit', $output->template); $this->assertSame('Edit response', $output->getProperty('pagetitle')); $this->assertFalse($output->get_env('readonly')); $this->assertTrue(strpos($result, 'test response 2</b></p>') !== false); } /** * Test response_form() method */ public function test_response_form() { $result = \rcmail_action_settings_response_edit::response_form([]); $this->assertTrue(strpos(trim($result), '') === 0); } }