aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functions
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2013-07-03 15:31:24 +0200
committerAndreas Fischer <bantu@phpbb.com>2013-07-03 15:31:24 +0200
commit950a3a7d952cd361c9dc3c3ff8138b0becea6f74 (patch)
tree4b31a2891376aee5c15dcfc39f7ad490b350778f /tests/functions
parent44de24f1b8b32a5ce3391b9ef24518a6671e452d (diff)
downloadforums-950a3a7d952cd361c9dc3c3ff8138b0becea6f74.tar
forums-950a3a7d952cd361c9dc3c3ff8138b0becea6f74.tar.gz
forums-950a3a7d952cd361c9dc3c3ff8138b0becea6f74.tar.bz2
forums-950a3a7d952cd361c9dc3c3ff8138b0becea6f74.tar.xz
forums-950a3a7d952cd361c9dc3c3ff8138b0becea6f74.zip
[ticket/11619] Some tests for get_remote_file().
PHPBB3-11619
Diffstat (limited to 'tests/functions')
-rw-r--r--tests/functions/get_remote_file_test.php75
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php
new file mode 100644
index 0000000000..4032ca5b58
--- /dev/null
+++ b/tests/functions/get_remote_file_test.php
@@ -0,0 +1,75 @@
+<?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__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php';
+
+/**
+* @group slow
+*/
+class phpbb_functions_get_remote_file extends phpbb_test_case
+{
+ public function test_version_phpbb_com()
+ {
+ $hostname = 'version.phpbb.com';
+
+ if (!phpbb_checkdnsrr($hostname, 'A'))
+ {
+ $this->markTestSkipped(sprintf(
+ 'Could not find a DNS record for hostname %s. ' .
+ 'Assuming network is down.',
+ $hostname
+ ));
+ }
+
+ $errstr = $errno = null;
+ $file = get_remote_file($hostname, '/phpbb', '30x.txt', $errstr, $errno);
+
+ $this->assertNotEquals(
+ 0,
+ strlen($file),
+ 'Failed asserting that the response is not empty.'
+ );
+
+ $this->assertSame(
+ '',
+ $errstr,
+ 'Failed asserting that the error string is empty.'
+ );
+
+ $this->assertSame(
+ 0,
+ $errno,
+ 'Failed asserting that the error number is 0 (i.e. no error occurred).'
+ );
+
+ $lines = explode("\n", $file);
+
+ $this->assertGreaterThanOrEqual(
+ 2,
+ sizeof($lines),
+ 'Failed asserting that the version file has at least two lines.'
+ );
+
+ $this->assertStringStartsWith(
+ '3.',
+ $lines[0],
+ "Failed asserting that the first line of the version file starts with '3.'"
+ );
+
+ $this->assertNotSame(
+ false,
+ filter_var($lines[1], FILTER_VALIDATE_URL),
+ 'Failed asserting that the second line of the version file is a valid URL.'
+ );
+
+ $this->assertContains('http', $lines[1]);
+ $this->assertContains('phpbb.com', $lines[1], '', true);
+ }
+}