mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-03-21 07:16:58 +01:00
* Check plugins composer.json using CI * Add "require-dev" and "config.allow-plugins" to plugins * fix composer.json format - rm invalid email * fix composer.json format - fix ext require * fix composer.json format - fix plugin name * tmp * Revert "tmp" * fix ext in ext install * disable plugin in plugin install until Roundcube is fully autoloadable * fix composer.json format - fix non-canonical license name * Revert "Add "require-dev" and "config.allow-plugins" to plugins" * no composer install for plugins needed * Revert "fix ext in ext install" * add standard "Test" suffix to phpunit files * rm unneeded "suffix" in phpunit config * simplify phpunit config * fix default "xhtml" doctype in unit testing * fix test_format_date test to not rely on other tests * even more phpunit config simplify * stricter/unify phpunit params for E2E tests * run E2E tests on maximal php version too with lowest deps * "repositories" in bundled plugins are useless as for root package only * add/unify missing plugin test
104 lines
3.5 KiB
PHP
104 lines
3.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Test class to test rcmail_action_utils_error
|
|
*/
|
|
class Actions_Utils_Error extends ActionTestCase
|
|
{
|
|
/**
|
|
* Test run() method in HTTP mode
|
|
*/
|
|
public function test_run_http()
|
|
{
|
|
$output = $this->initOutput(rcmail_action::MODE_HTTP, 'mail', 'test');
|
|
$action = new rcmail_action_utils_error();
|
|
|
|
$this->assertInstanceOf('rcmail_action', $action);
|
|
$this->assertTrue($action->checks());
|
|
|
|
// Default error
|
|
$this->runAndAssert($action, OutputHtmlMock::E_EXIT, []);
|
|
|
|
$result = $output->getOutput();
|
|
|
|
$this->assertSame('error', $output->template);
|
|
$this->assertTrue(stripos($result, '<!DOCTYPE html>') === 0);
|
|
$this->assertTrue(strpos($result, '<h3 class="error-title">SERVER ERROR!</h3>') !== false);
|
|
$this->assertTrue(strpos($result, '<div class="error-text">Error No. [500]</div>') !== false);
|
|
|
|
// TODO: Test error text for all error types
|
|
}
|
|
|
|
/**
|
|
* Test run() method in AJAX mode
|
|
*/
|
|
public function test_run_ajax()
|
|
{
|
|
$_SERVER['HTTP_HOST'] = 'test.com';
|
|
$_SERVER['REQUEST_METHOD'] = 'GET';
|
|
$_SERVER['REQUEST_URI'] = '';
|
|
|
|
$output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'compose');
|
|
$action = new rcmail_action_utils_error();
|
|
|
|
$this->assertInstanceOf('rcmail_action', $action);
|
|
$this->assertTrue($action->checks());
|
|
|
|
// Default error
|
|
$args = ['code' => 600];
|
|
$this->runAndAssert($action, OutputJsonMock::E_EXIT, $args);
|
|
|
|
$this->assertNull($output->getOutput());
|
|
$this->assertSame(['HTTP/1.0 500 Server Error!'], $output->headers);
|
|
|
|
// 401
|
|
$args = ['code' => 401, 'message' => 'test'];
|
|
$this->runAndAssert($action, OutputJsonMock::E_EXIT, $args);
|
|
|
|
$this->assertNull($output->getOutput());
|
|
$this->assertSame(['HTTP/1.0 401 Authorization Failed'], $output->headers);
|
|
|
|
// 403
|
|
$args = ['code' => 403, 'message' => 'test'];
|
|
$this->runAndAssert($action, OutputJsonMock::E_EXIT, $args);
|
|
|
|
$this->assertNull($output->getOutput());
|
|
$this->assertSame(['HTTP/1.0 403 Request Check Failed'], $output->headers);
|
|
|
|
// 404
|
|
$args = ['code' => 404, 'message' => 'test'];
|
|
$this->runAndAssert($action, OutputJsonMock::E_EXIT, $args);
|
|
|
|
$this->assertNull($output->getOutput());
|
|
$this->assertSame(['HTTP/1.0 404 File Not Found'], $output->headers);
|
|
|
|
// 410
|
|
$args = ['code' => 410, 'message' => 'test'];
|
|
$this->runAndAssert($action, OutputJsonMock::E_EXIT, $args);
|
|
|
|
$this->assertNull($output->getOutput());
|
|
$this->assertSame(['HTTP/1.0 410 Server Error!'], $output->headers);
|
|
|
|
// 450
|
|
$args = ['code' => 450, 'message' => 'test'];
|
|
$this->runAndAssert($action, OutputJsonMock::E_EXIT, $args);
|
|
|
|
$this->assertNull($output->getOutput());
|
|
$this->assertSame(['HTTP/1.0 450 Compose session error'], $output->headers);
|
|
|
|
// 601
|
|
$args = ['code' => 601, 'message' => 'test'];
|
|
$this->runAndAssert($action, OutputJsonMock::E_EXIT, $args);
|
|
|
|
$this->assertNull($output->getOutput());
|
|
$this->assertSame(['HTTP/1.0 500 Configuration error'], $output->headers);
|
|
|
|
// 603
|
|
$args = ['code' => 603, 'message' => 'test'];
|
|
$this->runAndAssert($action, OutputJsonMock::E_EXIT, $args);
|
|
|
|
$this->assertNull($output->getOutput());
|
|
$this->assertSame(['HTTP/1.0 500 Database Error!'], $output->headers);
|
|
}
|
|
}
|