diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/avatar/manager_test.php | 5 | ||||
-rw-r--r-- | tests/functional/extension_acp_test.php | 2 | ||||
-rw-r--r-- | tests/functional/extension_global_lang_test.php | 7 | ||||
-rw-r--r-- | tests/functional/feed_test.php | 6 | ||||
-rw-r--r-- | tests/functional/metadata_manager_test.php | 7 | ||||
-rw-r--r-- | tests/functional/plupload_test.php | 1 | ||||
-rw-r--r-- | tests/log/add_test.php | 9 | ||||
-rw-r--r-- | tests/request/request_test.php | 106 | ||||
-rw-r--r-- | tests/test_framework/phpbb_database_test_connection_manager.php | 15 | ||||
-rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 3 |
10 files changed, 152 insertions, 9 deletions
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 9b97fa6a68..344eef38ff 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -64,10 +64,13 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case ->method('get_name') ->will($this->returnValue('avatar.driver.foobar')); // barfoo driver can't be mocked with constructor arguments - $this->avatar_barfoo = $this->getMock('\phpbb\avatar\driver\barfoo', array('get_name')); + $this->avatar_barfoo = $this->getMock('\phpbb\avatar\driver\barfoo', array('get_name', 'get_config_name')); $this->avatar_barfoo->expects($this->any()) ->method('get_name') ->will($this->returnValue('avatar.driver.barfoo')); + $this->avatar_barfoo->expects($this->any()) + ->method('get_config_name') + ->will($this->returnValue('barfoo')); $avatar_drivers = array($this->avatar_foobar, $this->avatar_barfoo); foreach ($this->avatar_drivers() as $driver) diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 7be8957ec7..8a71a5ce04 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -41,6 +41,8 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case { parent::setUp(); + $this->purge_cache(); + $this->get_db(); // Clear the phpbb_ext table diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php index 53bb9af5ca..f615114c08 100644 --- a/tests/functional/extension_global_lang_test.php +++ b/tests/functional/extension_global_lang_test.php @@ -52,6 +52,13 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_ $this->purge_cache(); } + public function tearDown() + { + parent::tearDown(); + + $this->purge_cache(); + } + public function test_load_extension_lang_globally() { $this->phpbb_extension_manager->enable('foo/bar'); diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index ad5c4a5cab..e48dfc043a 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -20,6 +20,12 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case static public $init_values = array(); + public function setUp() + { + parent::setUp(); + $this->purge_cache(); + } + public function __construct($name = null, array $data = array(), $dataName = '') { parent::__construct($name, $data, $dataName); diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php index 080822d249..0d2fdf082e 100644 --- a/tests/functional/metadata_manager_test.php +++ b/tests/functional/metadata_manager_test.php @@ -24,6 +24,13 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case 'foo/bar/', ); + public function tearDown() + { + $this->purge_cache(); + + parent::tearDown(); + } + static public function setUpBeforeClass() { parent::setUpBeforeClass(); diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php index ee71597ffc..d358681ad1 100644 --- a/tests/functional/plupload_test.php +++ b/tests/functional/plupload_test.php @@ -33,6 +33,7 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case public function setUp() { parent::setUp(); + $this->purge_cache(); $this->set_extension_group_permission(1); $this->path = __DIR__ . '/fixtures/files/'; $this->add_lang('posting'); diff --git a/tests/log/add_test.php b/tests/log/add_test.php index bacc0c76f7..29d3adaeb6 100644 --- a/tests/log/add_test.php +++ b/tests/log/add_test.php @@ -88,5 +88,14 @@ class phpbb_log_add_test extends phpbb_database_test_case // Invalid mode specified $this->assertFalse($log->add('mode_does_not_exist', $user_id, $log_ip, $log_operation, $log_time)); + + // null user and null ip given + $this->assertEquals(3, $log->add($mode, null, null, $log_operation, $log_time), 'Adding log with null user_id and null user_ip failed'); + $sql = 'SELECT user_id, log_ip FROM ' . LOG_TABLE . ' WHERE log_id = 3'; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + $this->assertEquals(ANONYMOUS, $row['user_id'], 'Adding log with null user_id failed'); + $this->assertEquals('', $row['log_ip'], 'Adding log with null user_ip failed'); } } diff --git a/tests/request/request_test.php b/tests/request/request_test.php index 131abe6aac..ebaea1f9ef 100644 --- a/tests/request/request_test.php +++ b/tests/request/request_test.php @@ -13,7 +13,10 @@ class phpbb_request_test extends phpbb_test_case { + /** @var \phpbb\request\type_cast_helper_interface */ private $type_cast_helper; + + /** @var \phpbb\request\request */ private $request; protected function setUp() @@ -143,15 +146,112 @@ class phpbb_request_test extends phpbb_test_case $this->assertTrue($this->request->is_ajax()); } - public function test_is_secure() + public function data_is_secure() + { + return array( + array( + array( + 'HTTPS' => 'on', + ), + true, + ), + array( + array( + 'HTTPS' => '1', + ), + true, + ), + array( + array( + 'HTTPS' => 'yes', + ), + true, + ), + array( + array( + 'HTTPS' => 1, + ), + true, + ), + array( + array( + 'HTTPS' => 'off', + ), + false, + ), + array( + array( + 'HTTPS' => '0', + ), + false, + ), + array( + array( + 'HTTPS' => 0, + ), + false, + ), + array( + array( + 'HTTPS' => '', + ), + false, + ), + array( + array( + 'HTTPS' => 'off', + 'HTTP_X_FORWARDED_PROTO' => 'https', + ), + true, + ), + array( + array( + 'HTTPS' => 'on', + 'HTTP_X_FORWARDED_PROTO' => 'http', + ), + true, + ), + array( + array( + 'HTTPS' => 'off', + 'HTTP_X_FORWARDED_PROTO' => 'http', + ), + false, + ), + array( + array( + 'HTTP_X_FORWARDED_PROTO' => 'http', + ), + false, + ), + array( + array( + 'HTTP_X_FORWARDED_PROTO' => 'https', + ), + true, + ), + array( + array( + 'HTTPS' => 'on', + 'HTTP_X_FORWARDED_PROTO' => 'http', + ), + true, + ), + ); + } + + /** + * @dataProvider data_is_secure + */ + public function test_is_secure($server_data, $expected) { $this->assertFalse($this->request->is_secure()); $this->request->enable_super_globals(); - $_SERVER['HTTPS'] = 'on'; + $_SERVER = $server_data; $this->request = new \phpbb\request\request($this->type_cast_helper); - $this->assertTrue($this->request->is_secure()); + $this->assertSame($expected, $this->request->is_secure()); } public function test_variable_names() diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 5d643e43e2..3b5bab749e 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -85,11 +85,18 @@ class phpbb_database_test_connection_manager break; default: - $dsn .= 'host=' . $this->config['dbhost']; - - if ($this->config['dbport']) + if (!empty($this->config['dbport']) && !is_numeric($this->config['dbport']) && $this->dbms['PDO'] != 'pgsql') + { + $dsn .= 'unix_socket=' . $this->config['dbport']; + } + else { - $dsn .= ';port=' . $this->config['dbport']; + $dsn .= 'host=' . $this->config['dbhost']; + + if ($this->config['dbport']) + { + $dsn .= ';port=' . $this->config['dbport']; + } } if ($use_db) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d403831626..8107e45dc7 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -89,12 +89,13 @@ class phpbb_functional_test_case extends phpbb_test_case // that were added in other tests are gone $this->lang = array(); $this->add_lang('common'); - $this->purge_cache(); $db = $this->get_db(); foreach (static::setup_extensions() as $extension) { + $this->purge_cache(); + $sql = 'SELECT ext_active FROM ' . EXT_TABLE . " WHERE ext_name = '" . $db->sql_escape($extension). "'"; |