1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-25 17:41:25 +02:00

[ticket/12479] Remove deprecated functions

PHPBB-12479
This commit is contained in:
Marc Alexander
2024-07-11 20:35:26 +02:00
parent 1449706da9
commit 6395639345
6 changed files with 112 additions and 574 deletions

View File

@@ -1,80 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
* @group slow
*/
class phpbb_functions_get_remote_file extends phpbb_test_case
{
public function test_version_phpbb_com()
{
global $phpbb_container;
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->set('file_downloader', new \phpbb\file_downloader());
$hostname = 'version.phpbb.com';
if (!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,
count($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->assertStringContainsString('http', $lines[1]);
$this->assertStringContainsString('phpbb.com', $lines[1], '', true);
}
}

View File

@@ -172,19 +172,63 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case
if ($additional3 != null)
{
add_log($mode, $required1, $additional1, $additional2, $additional3);
$additional_data = [
'forum_id' => $required1,
'topic_id' => $additional1,
$additional3,
];
$phpbb_log->add($mode, $user_id, '', $additional2, false, $additional_data);
}
else if ($additional2 != null)
{
add_log($mode, $required1, $additional1, $additional2);
if ($mode == 'user')
{
$additional_data = [
'reportee_id' => $required1,
$additional2,
];
$log_operation = $additional1;
}
else if ($mode == 'mod')
{
$additional_data = [
'forum_id' => $required1,
'topic_id' => $additional1,
];
$log_operation = $additional2;
}
else
{
$log_operation = $required1;
$additional_data = [
$additional1,
$additional2,
];
}
$phpbb_log->add($mode, $user_id, '', $log_operation, false, $additional_data);
}
else if ($additional1 != null)
{
add_log($mode, $required1, $additional1);
if ($mode == 'user')
{
$additional_data = [
'reportee_id' => $required1,
];
$log_operation = $additional1;
}
else
{
$log_operation = $required1;
$additional_data = [
$additional1,
];
}
$phpbb_log->add($mode, $user_id, '', $log_operation, false, $additional_data);
}
else
{
add_log($mode, $required1);
$phpbb_log->add($mode, $user_id, '', $required1);
}
$result = $db->sql_query('SELECT user_id, log_type, log_operation, log_data, reportee_id, forum_id, topic_id

View File

@@ -224,4 +224,65 @@ class version_helper_remote_test extends \phpbb_test_case
$this->assertEquals($expected_return, $return);
}
public function test_version_phpbb_com()
{
$file_downloader = new \phpbb\file_downloader();
$hostname = 'version.phpbb.com';
if (!checkdnsrr($hostname, 'A'))
{
$this->markTestSkipped(sprintf(
'Could not find a DNS record for hostname %s. ' .
'Assuming network is down.',
$hostname
));
}
$file = $file_downloader->get($hostname, '/phpbb', '30x.txt');
$errstr = $file_downloader->get_error_string();
$errno = $file_downloader->get_error_number();
$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,
count($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->assertStringContainsString('http', $lines[1]);
$this->assertStringContainsString('phpbb.com', $lines[1], '', true);
}
}