aboutsummaryrefslogtreecommitdiffstats
path: root/tests/session/extract_hostname_test.php
diff options
context:
space:
mode:
authorDavid King <imkingdavid@gmail.com>2013-08-31 13:37:11 -0700
committerDavid King <imkingdavid@gmail.com>2013-08-31 13:37:11 -0700
commitaf1eb7466f11cdb0f851acfcacd957267e20e3ce (patch)
tree1c72f7436ffcaa0d355ee11a0375323dcf5731f6 /tests/session/extract_hostname_test.php
parent9485eea0987478da25327a06a4fd36943ca1c01c (diff)
parent9d6370751f1b998e3da448e16c1446b33ddd17d0 (diff)
downloadforums-af1eb7466f11cdb0f851acfcacd957267e20e3ce.tar
forums-af1eb7466f11cdb0f851acfcacd957267e20e3ce.tar.gz
forums-af1eb7466f11cdb0f851acfcacd957267e20e3ce.tar.bz2
forums-af1eb7466f11cdb0f851acfcacd957267e20e3ce.tar.xz
forums-af1eb7466f11cdb0f851acfcacd957267e20e3ce.zip
Merge branch 'develop' into ticket/11215
Diffstat (limited to 'tests/session/extract_hostname_test.php')
-rw-r--r--tests/session/extract_hostname_test.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/session/extract_hostname_test.php b/tests/session/extract_hostname_test.php
new file mode 100644
index 0000000000..bd183fd438
--- /dev/null
+++ b/tests/session/extract_hostname_test.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ *
+ * @package testing
+ * @copyright (c) 2013 phpBB Group
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+ *
+ */
+
+require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php';
+
+class phpbb_session_extract_hostname_test extends phpbb_session_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_empty.xml');
+ }
+
+ static public function extract_current_hostname_data()
+ {
+ return array (
+ // [Input] $host, $server_name_config, $cookie_domain_config, [Expected] $output
+ // If host is ip use that
+ // ipv4
+ array('127.0.0.1', 'skipped.org', 'skipped.org', '127.0.0.1'),
+ // ipv6
+ array('::1', 'skipped.org', 'skipped.org', ':'),
+ array('2002::3235:51f9', 'skipped.org', 'skipped.org', '2002::3235'),
+ // If no host but server name matches cookie_domain use that
+ array('', 'example.org', 'example.org', 'example.org'),
+ // If there is a host uri use that
+ array('example.org', false, false, 'example.org'),
+ // 'best approach' guessing
+ array('', 'example.org', false, 'example.org'),
+ array('', false, '127.0.0.1', '127.0.0.1'),
+ array('', false, false, php_uname('n')),
+ );
+ }
+
+ /** @dataProvider extract_current_hostname_data */
+ function test_extract_current_hostname($host, $server_name_config, $cookie_domain_config, $expected)
+ {
+ $output = $this->session_facade->extract_current_hostname(
+ $host,
+ $server_name_config,
+ $cookie_domain_config
+ );
+
+ $this->assertEquals($expected, $output);
+ }
+}