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

Merge branch 'develop-olympus' into develop

* develop-olympus: (57 commits)
  Revert "[ticket/7716] Data too long for column 'message_subject'"
  [ticket/7716] Data too long for column 'message_subject'
  [ticket/9780] Adding unit tests for gen_rand_string().
  [ticket/9780] Add length check back to gen_rand_string().
  [ticket/7972] Copying topics in the MCP now indexes the new topic.
  [ticket/9782] Board disable radio set on when server load high
  [ticket/9635] Useless parameter $data['post_time'] in function submit_post.
  [ticket/9104] Safari does not display box headers correctly in the ACP.
  [ticket/9777] Print error message in pre-commit hook when php is not installed.
  [ticket/7716] Data too long for column 'message_subject'
  [task/git-tools] Ignore git commit message comments
  [task/git-tools] Adjust the hook to enforce that a ticket is always mentioned
  [task/git-tools] Vastly expanded commit-msg hook.
  [task/git-tools] Beginnings of a syntax checking hook.
  [task/git-tools] Append ticket identifier to commit message prior to editing.
  [ticket/7332] Redirect users back to post details when performing actions.
  [ticket/7332] Collapse post details content down to a maximum of 300px heigh
  [ticket/9771] Remove query string parameters that have no name.
  [ticket/9760] Remove unrestricted wildcards from search terms.
  [ticket/9599] Reimplement phpbb_checkdnsrr() function.
  ...

Conflicts:
	tests/template/template.php
This commit is contained in:
Nils Adermann
2010-08-21 23:35:43 +02:00
61 changed files with 1119 additions and 204 deletions

View File

@@ -24,6 +24,8 @@ require_once 'template/all_tests.php';
require_once 'text_processing/all_tests.php';
require_once 'dbal/all_tests.php';
require_once 'regex/all_tests.php';
require_once 'network/all_tests.php';
require_once 'random/all_tests.php';
// exclude the test directory from code coverage reports
PHPUnit_Util_Filter::addDirectoryToFilter('./');
@@ -48,6 +50,8 @@ class phpbb_all_tests
$suite->addTest(phpbb_text_processing_all_tests::suite());
$suite->addTest(phpbb_dbal_all_tests::suite());
$suite->addTest(phpbb_regex_all_tests::suite());
$suite->addTest(phpbb_network_all_tests::suite());
$suite->addTest(phpbb_random_all_tests::suite());
return $suite;
}

View File

@@ -0,0 +1,40 @@
<?php
/**
*
* @package testing
* @copyright (c) 2010 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
if (!defined('PHPUnit_MAIN_METHOD'))
{
define('PHPUnit_MAIN_METHOD', 'phpbb_network_all_tests::main');
}
require_once 'test_framework/framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'network/checkdnsrr.php';
class phpbb_network_all_tests
{
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('phpBB Network Functions');
$suite->addTestSuite('phpbb_network_checkdnsrr_test');
return $suite;
}
}
if (PHPUnit_MAIN_METHOD == 'phpbb_network_all_tests::main')
{
phpbb_network_all_tests::main();
}

View File

@@ -0,0 +1,63 @@
<?php
/**
*
* @package testing
* @copyright (c) 2010 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
require_once 'test_framework/framework.php';
require_once '../phpBB/includes/functions.php';
class phpbb_network_checkdnsrr_test extends phpbb_test_case
{
public function data_provider()
{
return array(
// Existing MX record
array('phpbb.com', 'MX', true),
// Non-existing MX record
array('does-not-exist.phpbb.com', 'MX', false),
// Existing A record
array('www.phpbb.com', 'A', true),
// Non-existing A record
array('does-not-exist.phpbb.com', 'A', false),
// Existing AAAA record
array('www.six.heise.de', 'AAAA', true),
// Non-existing AAAA record
array('does-not-exist.phpbb.com', 'AAAA', false),
// Existing CNAME record
array('news.cnet.com', 'CNAME', true),
// Non-existing CNAME record
array('does-not-exist.phpbb.com', 'CNAME', false),
// Existing NS record
array('phpbb.com', 'NS', true),
// Non-existing NS record
array('does-not-exist', 'NS', false),
// Existing TXT record
array('phpbb.com', 'TXT', true),
// Non-existing TXT record
array('does-not-exist', 'TXT', false),
);
}
/**
* @dataProvider data_provider
*/
public function test_checkdnsrr($host, $type, $expected)
{
$this->assertEquals($expected, phpbb_checkdnsrr($host, $type));
}
}

View File

@@ -0,0 +1,40 @@
<?php
/**
*
* @package testing
* @copyright (c) 2010 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
if (!defined('PHPUnit_MAIN_METHOD'))
{
define('PHPUnit_MAIN_METHOD', 'phpbb_random_all_tests::main');
}
require_once 'test_framework/framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'random/gen_rand_string.php';
class phpbb_random_all_tests
{
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('phpBB Random Functions');
$suite->addTestSuite('phpbb_random_gen_rand_string_test');
return $suite;
}
}
if (PHPUnit_MAIN_METHOD == 'phpbb_random_all_tests::main')
{
phpbb_random_all_tests::main();
}

View File

@@ -0,0 +1,63 @@
<?php
/**
*
* @package testing
* @copyright (c) 2010 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
require_once 'test_framework/framework.php';
require_once '../phpBB/includes/functions.php';
class phpbb_random_gen_rand_string_test extends phpbb_test_case
{
const TEST_COUNT = 100;
const MIN_STRING_LENGTH = 1;
const MAX_STRING_LENGTH = 15;
public function setUp()
{
global $config;
if (!is_array($config))
{
$config = array();
}
$config['rand_seed'] = '';
$config['rand_seed_last_update'] = time() + 600;
}
public function test_gen_rand_string()
{
for ($tests = 0; $tests <= self::TEST_COUNT; ++$tests)
{
for ($num_chars = self::MIN_STRING_LENGTH; $num_chars <= self::MAX_STRING_LENGTH; ++$num_chars)
{
$random_string = gen_rand_string($num_chars);
$random_string_length = strlen($random_string);
$this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH);
$this->assertTrue($random_string_length <= $num_chars);
$this->assertRegExp('#^[A-Z0-9]+$#', $random_string);
}
}
}
public function test_gen_rand_string_friendly()
{
for ($tests = 0; $tests <= self::TEST_COUNT; ++$tests)
{
for ($num_chars = self::MIN_STRING_LENGTH; $num_chars <= self::MAX_STRING_LENGTH; ++$num_chars)
{
$random_string = gen_rand_string_friendly($num_chars);
$random_string_length = strlen($random_string);
$this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH);
$this->assertTrue($random_string_length <= $num_chars);
$this->assertRegExp('#^[A-NP-Z1-9]+$#', $random_string);
}
}
}
}

View File

@@ -33,6 +33,27 @@ class phpbb_regex_email_test extends phpbb_test_case
//array('"John Doe"@example.com'),
//array('Alice@[192.168.2.1]'), // IPv4
//array('Bob@[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]'), // IPv6
// http://fightingforalostcause.net/misc/2006/compare-email-regex.php
array('l3tt3rsAndNumb3rs@domain.com'),
array('has-dash@domain.com'),
array('hasApostrophe.o\'leary@domain.org'),
array('uncommonTLD@domain.museum'),
array('uncommonTLD@domain.travel'),
array('uncommonTLD@domain.mobi'),
array('countryCodeTLD@domain.uk'),
array('countryCodeTLD@domain.rw'),
array('numbersInDomain@911.com'),
array('underscore_inLocal@domain.net'),
array('IPInsteadOfDomain@127.0.0.1'),
array('IPAndPort@127.0.0.1:25'),
array('subdomain@sub.domain.com'),
array('local@dash-inDomain.com'),
array('dot.inLocal@foo.com'),
array('a@singleLetterLocal.org'),
array('singleLetterDomain@x.org'),
array('&amp;*=?^+{}\'~@validCharsInLocal.net'),
array('foor@bar.newTLD'),
);
}
@@ -56,6 +77,26 @@ class phpbb_regex_email_test extends phpbb_test_case
array('abc,def@example.com'), // invalid character ,
array('abc<def@example.com'), // invalid character <
array('abc>def@example.com'), // invalid character >
// http://fightingforalostcause.net/misc/2006/compare-email-regex.php
array('missingDomain@.com'),
array('@missingLocal.org'),
array('missingatSign.net'),
array('missingDot@com'),
array('two@@signs.com'),
array('colonButNoPort@127.0.0.1:'),
array(''),
array('someone-else@127.0.0.1.26'),
array('.localStartsWithDot@domain.com'),
array('localEndsWithDot.@domain.com'),
array('two..consecutiveDots@domain.com'),
array('domainStartsWithDash@-domain.com'),
array('domainEndsWithDash@domain-.com'),
array('numbersInTLD@domain.c0m'),
array('missingTLD@domain.'),
array('! "#$%(),/;<>[]`|@invalidCharsInLocal.org'),
array('invalidCharsInDomain@! "#$%(),/;<>_[]`|.org'),
array('local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org'),
);
}
@@ -70,7 +111,7 @@ class phpbb_regex_email_test extends phpbb_test_case
/**
* @dataProvider negative_match_data
*/
public function test_negative_match($address)
public function test_negative_match($email)
{
$this->assertEquals(0, preg_match($this->regex, $email));
}

View File

@@ -360,9 +360,15 @@ class phpbb_template_template_test extends phpbb_test_case
$this->template->destroy_block_vars($block);
}
$error_level = error_reporting();
error_reporting($error_level & ~E_NOTICE);
$this->assertEquals($expected, self::trim_template_result($this->template->assign_display('test')), "Testing assign_display($file)");
$this->template->assign_display('test', 'VARIABLE', false);
error_reporting($error_level);
$this->assertEquals($expected, $this->display('container'), "Testing assign_display($file)");
}