aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2018-01-07 11:02:31 +0100
committerMarc Alexander <admin@m-a-styles.de>2018-01-07 11:02:31 +0100
commit1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99 (patch)
treed70037f3f547a71e4a6b87bcddb31aeb19db7328 /tests
parent3ae016954212e90032a10d1427c34a4ff9d9637c (diff)
parent182a96f2738316adcb292816a9ac8af0e0cb5866 (diff)
downloadforums-1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99.tar
forums-1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99.tar.gz
forums-1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99.tar.bz2
forums-1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99.tar.xz
forums-1b4bad6583ffa8a7ba8a1e7f5f9c29c5654bba99.zip
Merge remote-tracking branch 'upstream/3.2.x' into prep-release-3.2.2
Diffstat (limited to 'tests')
-rw-r--r--tests/attachment/fixtures/resync.xml7
-rw-r--r--tests/cache/cache_memory_test.php2
-rw-r--r--tests/console/user/add_test.php48
-rw-r--r--tests/cron/manager_test.php2
-rw-r--r--tests/dbal/db_tools_test.php32
-rw-r--r--tests/dbal/fixtures/boolean_processor.xml6
-rw-r--r--tests/dbal/write_test.php2
-rw-r--r--tests/error_collector_test.php4
-rw-r--r--tests/event/md_exporter_test.php4
-rw-r--r--tests/functional/extension_acp_test.php4
-rw-r--r--tests/functional/extension_controller_test.php2
-rw-r--r--tests/functional/extension_global_lang_test.php2
-rw-r--r--tests/functional/extension_module_test.php2
-rw-r--r--tests/functional/extension_permission_lang_test.php2
-rw-r--r--tests/functional/fileupload_remote_test.php4
-rw-r--r--tests/functional/metadata_manager_test.php2
-rw-r--r--tests/functions/fixtures/validate_username.xml2
-rw-r--r--tests/functions/get_remote_file_test.php2
-rw-r--r--tests/functions_user/fixtures/delete_user.xml9
-rw-r--r--tests/mock/sql_insert_buffer.php2
-rw-r--r--tests/notification/base.php2
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.bookmark.xml2
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.post.xml3
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml2
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.quote.xml2
-rw-r--r--tests/notification/fixtures/submit_post_notification.type.topic.xml2
-rw-r--r--tests/notification/notification_test.php2
-rw-r--r--tests/search/fixtures/posts.xml5
-rw-r--r--tests/test_framework/phpbb_database_test_case.php79
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php10
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php5
-rw-r--r--tests/test_framework/phpbb_ui_test_case.php2
-rw-r--r--tests/tree/nestedset_forum_base.php20
-rw-r--r--tests/upload/fileupload_test.php12
-rw-r--r--tests/wrapper/version_compare_test.php2
35 files changed, 243 insertions, 47 deletions
diff --git a/tests/attachment/fixtures/resync.xml b/tests/attachment/fixtures/resync.xml
index 6e2cc62f68..af04701b4a 100644
--- a/tests/attachment/fixtures/resync.xml
+++ b/tests/attachment/fixtures/resync.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_attachments">
+ <column>attach_id</column>
<column>post_msg_id</column>
<column>topic_id</column>
<column>in_message</column>
@@ -11,6 +12,7 @@
<row>
<value>1</value>
<value>1</value>
+ <value>1</value>
<value>0</value>
<value>0</value>
<value>foo</value>
@@ -18,6 +20,7 @@
<value>0</value>
</row>
<row>
+ <value>2</value>
<value>1</value>
<value>1</value>
<value>1</value>
@@ -27,6 +30,7 @@
<value>0</value>
</row>
<row>
+ <value>3</value>
<value>1</value>
<value>1</value>
<value>1</value>
@@ -37,13 +41,16 @@
</row>
</table>
<table name="phpbb_extensions">
+ <column>extension_id</column>
<column>extension</column>
<column>group_id</column>
<row>
+ <value>1</value>
<value>jpg</value>
<value>1</value>
</row>
<row>
+ <value>2</value>
<value>png</value>
<value>1</value>
</row>
diff --git a/tests/cache/cache_memory_test.php b/tests/cache/cache_memory_test.php
index 9f92e8d8dc..ba1010bcf3 100644
--- a/tests/cache/cache_memory_test.php
+++ b/tests/cache/cache_memory_test.php
@@ -116,7 +116,7 @@ class phpbb_cache_memory_test extends phpbb_database_test_case
$results[] = $row;
}
$this->cache->sql_freeresult($query_id);
- $this->assertEquals($query[1], sizeof($results));
+ $this->assertEquals($query[1], count($results));
}
$this->cache->destroy('sql', $table);
diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php
index 8641bf87b6..bdfb8a8d2a 100644
--- a/tests/console/user/add_test.php
+++ b/tests/console/user/add_test.php
@@ -14,12 +14,15 @@
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use phpbb\console\command\user\add;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Question\Question;
require_once dirname(__FILE__) . '/base.php';
class phpbb_console_user_add_test extends phpbb_console_user_base
{
- public function get_command_tester()
+ public function get_command_tester($question_answers = [])
{
$application = new Application();
$application->add(new add(
@@ -34,7 +37,42 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
$command = $application->find('user:add');
$this->command_name = $command->getName();
- $this->question = $command->getHelper('question');
+
+ if (!empty($question_answers))
+ {
+ $ask = function(InputInterface $input, OutputInterface $output, Question $question) use ($question_answers)
+ {
+ $text = $question->getQuestion();
+
+ // handle a question
+ foreach ($question_answers as $expected_question => $answer)
+ {
+ if (strpos($text, $expected_question) !== false)
+ {
+ $response = $answer;
+ }
+ }
+
+ if (!isset($response))
+ {
+ throw new \RuntimeException('Was asked for input on an unhandled question: ' . $text);
+ }
+
+ $output->writeln(print_r($response, true));
+ return $response;
+ };
+ $helper = $this->getMock('\Symfony\Component\Console\Helper\QuestionHelper', array('ask'));
+ $helper->expects($this->any())
+ ->method('ask')
+ ->will($this->returnCallback($ask));
+ $this->question = $helper;
+ $command->getHelperSet()->set($helper, 'question');
+ }
+ else
+ {
+ $this->question = $command->getHelper('question');
+ }
+
return new CommandTester($command);
}
@@ -57,7 +95,11 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
public function test_add_dialog()
{
- $command_tester = $this->get_command_tester();
+ $command_tester = $this->get_command_tester([
+ 'USERNAME' => 'bar',
+ 'PASSWORD' => 'password',
+ 'EMAIL_ADDRESS' => 'bar@test.com',
+ ]);
$this->assertEquals(2, $this->get_user_id('Admin'));
diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php
index f4dd69b19b..76f8c753bf 100644
--- a/tests/cron/manager_test.php
+++ b/tests/cron/manager_test.php
@@ -40,7 +40,7 @@ class phpbb_cron_manager_test extends \phpbb_test_case
public function test_manager_finds_all_ready_tasks()
{
$tasks = $this->manager->find_all_ready_tasks();
- $this->assertEquals(3, sizeof($tasks));
+ $this->assertEquals(3, count($tasks));
}
public function test_manager_finds_one_ready_task()
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index f9243e7266..0365463a48 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -203,8 +203,15 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
public function test_list_columns()
{
+ $config = $this->get_database_config();
+ $table_columns = $this->table_data['COLUMNS'];
+
+ if (strpos($config['dbms'], 'mssql') !== false)
+ {
+ ksort($table_columns);
+ }
$this->assertEquals(
- array_keys($this->table_data['COLUMNS']),
+ array_keys($table_columns),
array_values($this->tools->sql_list_columns('prefix_table_name'))
);
}
@@ -432,28 +439,37 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->markTestIncomplete('The table prefix length is too long for proper testing of index shortening function.');
}
+ $max_index_length = 30;
+
+ if ($this->tools instanceof \phpbb\db\tools\mssql)
+ {
+ $max_length_method = new ReflectionMethod('\phpbb\db\tools\mssql', 'get_max_index_name_length');
+ $max_length_method->setAccessible(true);
+ $max_index_length = $max_length_method->invoke($this->tools);
+ }
+
$table_suffix = str_repeat('a', 25 - strlen($table_prefix));
$table_name = $table_prefix . $table_suffix;
$this->tools->sql_create_table($table_name, $this->table_data);
- // Index name and table suffix and table prefix have > 30 chars in total.
- // Index name and table suffix have <= 30 chars in total.
- $long_index_name = str_repeat('i', 30 - strlen($table_suffix));
+ // Index name and table suffix and table prefix have > maximum index length chars in total.
+ // Index name and table suffix have <= maximum index length chars in total.
+ $long_index_name = str_repeat('i', $max_index_length - strlen($table_suffix));
$this->assertFalse($this->tools->sql_index_exists($table_name, $long_index_name));
$this->assertTrue($this->tools->sql_create_index($table_name, $long_index_name, array('c_timestamp')));
$this->assertTrue($this->tools->sql_index_exists($table_name, $long_index_name));
- // Index name and table suffix have > 30 chars in total.
- $very_long_index_name = str_repeat('i', 30);
+ // Index name and table suffix have > maximum index length chars in total.
+ $very_long_index_name = str_repeat('i', $max_index_length);
$this->assertFalse($this->tools->sql_index_exists($table_name, $very_long_index_name));
$this->assertTrue($this->tools->sql_create_index($table_name, $very_long_index_name, array('c_timestamp')));
$this->assertTrue($this->tools->sql_index_exists($table_name, $very_long_index_name));
$this->tools->sql_table_drop($table_name);
- // Index name has > 30 chars - that should not be possible.
- $too_long_index_name = str_repeat('i', 31);
+ // Index name has > maximum index length chars - that should not be possible.
+ $too_long_index_name = str_repeat('i', $max_index_length + 1);
$this->assertFalse($this->tools->sql_index_exists('prefix_table_name', $too_long_index_name));
$this->setExpectedTriggerError(E_USER_ERROR);
$this->tools->sql_create_index('prefix_table_name', $too_long_index_name, array('c_timestamp'));
diff --git a/tests/dbal/fixtures/boolean_processor.xml b/tests/dbal/fixtures/boolean_processor.xml
index c5da677116..d31d679f45 100644
--- a/tests/dbal/fixtures/boolean_processor.xml
+++ b/tests/dbal/fixtures/boolean_processor.xml
@@ -60,25 +60,31 @@
<table name="phpbb_user_group">
<column>user_id</column>
<column>group_id</column>
+ <column>group_leader</column>
<row>
<value>1</value>
<value>1</value>
+ <value>2</value>
</row>
<row>
<value>2</value>
<value>1</value>
+ <value>2</value>
</row>
<row>
<value>3</value>
<value>1</value>
+ <value>2</value>
</row>
<row>
<value>4</value>
<value>2</value>
+ <value>2</value>
</row>
<row>
<value>5</value>
<value>2</value>
+ <value>2</value>
</row>
</table>
</dataset>
diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php
index 98709fb043..4fa5cc37a2 100644
--- a/tests/dbal/write_test.php
+++ b/tests/dbal/write_test.php
@@ -67,7 +67,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case
$result = $db->sql_query($sql);
$rows = $db->sql_fetchrowset($result);
- $this->assertEquals(1, sizeof($rows));
+ $this->assertEquals(1, count($rows));
$this->assertEquals('config2', $rows[0]['config_name']);
$db->sql_freeresult($result);
diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php
index 273284c8fc..8ed89bbe52 100644
--- a/tests/error_collector_test.php
+++ b/tests/error_collector_test.php
@@ -52,8 +52,8 @@ class phpbb_error_collector_test extends phpbb_test_case
1/0; $line = __LINE__;
// Cause a notice
- $array = array('ITEM' => 'value');
- $value = $array[ITEM]; $line2 = __LINE__;
+ $array = array(0 => 'value');
+ $value = $array[1]; $line2 = __LINE__;
$collector->uninstall();
diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php
index 607f442fdf..2eeb48ea05 100644
--- a/tests/event/md_exporter_test.php
+++ b/tests/event/md_exporter_test.php
@@ -92,7 +92,7 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
public function test_crawl_eventsmd($file, $min_version, $max_version, $events)
{
$exporter = new \phpbb\event\md_exporter(dirname(__FILE__) . '/fixtures/', null, $min_version, $max_version);
- $this->assertSame(sizeof($events), $exporter->crawl_eventsmd($file, 'adm'));
+ $this->assertSame(count($events), $exporter->crawl_eventsmd($file, 'adm'));
$this->assertEquals($events, $exporter->get_events());
}
@@ -146,7 +146,7 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
$exporter->crawl_eventsmd('docs/events.md', $filter);
$events = $exporter->crawl_file_for_events($file);
- $this->assertGreaterThanOrEqual(0, sizeof($events));
+ $this->assertGreaterThanOrEqual(0, count($events));
$this->assertTrue($exporter->validate_events_from_file($file, $events));
}
}
diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php
index 8a71a5ce04..ce0f4911e3 100644
--- a/tests/functional/extension_acp_test.php
+++ b/tests/functional/extension_acp_test.php
@@ -26,7 +26,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/../extension/ext/', self::$fixtures);
}
@@ -133,7 +133,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
for ($i = 0; $i < $crawler->filter('dl')->count(); $i++)
{
- $text = $crawler->filter('dl')->eq($i)->text();
+ $text = trim($crawler->filter('dl')->eq($i)->text());
$match = false;
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index 18eb9ad4c6..58c3878b8b 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -34,7 +34,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php
index f615114c08..a1e2547745 100644
--- a/tests/functional/extension_global_lang_test.php
+++ b/tests/functional/extension_global_lang_test.php
@@ -30,7 +30,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php
index 95107665cd..d3a66b9b35 100644
--- a/tests/functional/extension_module_test.php
+++ b/tests/functional/extension_module_test.php
@@ -29,7 +29,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php
index 92d8d596c7..f570d45215 100644
--- a/tests/functional/extension_permission_lang_test.php
+++ b/tests/functional/extension_permission_lang_test.php
@@ -30,7 +30,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php
index 88f8999005..426ebcee53 100644
--- a/tests/functional/fileupload_remote_test.php
+++ b/tests/functional/fileupload_remote_test.php
@@ -102,7 +102,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
->set_allowed_extensions(array('gif'))
->set_max_filesize(2000);
$file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif');
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
$this->assertTrue(file_exists($file->get('filename')));
$this->assertTrue($file->is_uploaded());
}
@@ -115,7 +115,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
->set_allowed_extensions(array('gif'))
->set_max_filesize(100);
$file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif');
- $this->assertEquals(1, sizeof($file->error));
+ $this->assertEquals(1, count($file->error));
$this->assertEquals('WRONG_FILESIZE', $file->error[0]);
}
}
diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php
index 0d2fdf082e..8456c40f00 100644
--- a/tests/functional/metadata_manager_test.php
+++ b/tests/functional/metadata_manager_test.php
@@ -35,7 +35,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functions/fixtures/validate_username.xml b/tests/functions/fixtures/validate_username.xml
index 1b85a2f06d..add8f76553 100644
--- a/tests/functions/fixtures/validate_username.xml
+++ b/tests/functions/fixtures/validate_username.xml
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_groups">
+ <column>group_id</column>
<column>group_name</column>
<column>group_desc</column>
<row>
+ <value>10</value>
<value>foobar_group</value>
<value>test123</value>
</row>
diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php
index 1550aa37e6..75e5a6dc61 100644
--- a/tests/functions/get_remote_file_test.php
+++ b/tests/functions/get_remote_file_test.php
@@ -58,7 +58,7 @@ class phpbb_functions_get_remote_file extends phpbb_test_case
$this->assertGreaterThanOrEqual(
2,
- sizeof($lines),
+ count($lines),
'Failed asserting that the version file has at least two lines.'
);
diff --git a/tests/functions_user/fixtures/delete_user.xml b/tests/functions_user/fixtures/delete_user.xml
index 56014b35d1..8de2659722 100644
--- a/tests/functions_user/fixtures/delete_user.xml
+++ b/tests/functions_user/fixtures/delete_user.xml
@@ -515,35 +515,44 @@
</table>
<table name="phpbb_privmsgs_folder">
<column>user_id</column>
+ <column>folder_id</column>
<row>
<value>2</value>
+ <value>1</value>
</row>
<row>
<value>3</value>
+ <value>2</value>
</row>
</table>
<table name="phpbb_privmsgs_rules">
<column>user_id</column>
<column>rule_string</column>
+ <column>rule_id</column>
<row>
<value>2</value>
<value></value>
+ <value>1</value>
</row>
<row>
<value>3</value>
<value></value>
+ <value>2</value>
</row>
</table>
<table name="phpbb_drafts">
<column>user_id</column>
<column>draft_message</column>
+ <column>draft_id</column>
<row>
<value>2</value>
<value></value>
+ <value>1</value>
</row>
<row>
<value>3</value>
<value></value>
+ <value>2</value>
</row>
</table>
</dataset>
diff --git a/tests/mock/sql_insert_buffer.php b/tests/mock/sql_insert_buffer.php
index c751764d45..e57983684d 100644
--- a/tests/mock/sql_insert_buffer.php
+++ b/tests/mock/sql_insert_buffer.php
@@ -15,7 +15,7 @@ class phpbb_mock_sql_insert_buffer extends \phpbb\db\sql_insert_buffer
{
public function flush()
{
- return (sizeof($this->buffer)) ? true : false;
+ return (count($this->buffer)) ? true : false;
}
public function get_buffer()
diff --git a/tests/notification/base.php b/tests/notification/base.php
index b64e25cf8c..80b9a0d777 100644
--- a/tests/notification/base.php
+++ b/tests/notification/base.php
@@ -163,7 +163,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
'order_dir' => 'ASC',
), $options));
- $this->assertEquals(sizeof($expected), $notifications['unread_count']);
+ $this->assertEquals(count($expected), $notifications['unread_count']);
$i = 0;
foreach ($notifications['notifications'] as $notification)
diff --git a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml
index 7f069abc59..db1cef2ef6 100644
--- a/tests/notification/fixtures/submit_post_notification.type.bookmark.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml
@@ -29,6 +29,7 @@
</row>
</table>
<table name="phpbb_notifications">
+ <column>notification_id</column>
<column>notification_type_id</column>
<column>user_id</column>
<column>item_id</column>
@@ -37,6 +38,7 @@
<column>notification_data</column>
<row>
<value>1</value>
+ <value>1</value>
<value>5</value>
<value>1</value>
<value>1</value>
diff --git a/tests/notification/fixtures/submit_post_notification.type.post.xml b/tests/notification/fixtures/submit_post_notification.type.post.xml
index a4bf9d3ee4..920b271525 100644
--- a/tests/notification/fixtures/submit_post_notification.type.post.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.post.xml
@@ -21,6 +21,7 @@
</row>
</table>
<table name="phpbb_notifications">
+ <column>notification_id</column>
<column>notification_type_id</column>
<column>user_id</column>
<column>item_id</column>
@@ -29,6 +30,7 @@
<column>notification_data</column>
<row>
<value>1</value>
+ <value>1</value>
<value>5</value>
<value>1</value>
<value>1</value>
@@ -36,6 +38,7 @@
<value></value>
</row>
<row>
+ <value>2</value>
<value>1</value>
<value>8</value>
<value>1</value>
diff --git a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml
index 0a955c48d2..12e73b0ff2 100644
--- a/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_notifications">
+ <column>notification_id</column>
<column>notification_type_id</column>
<column>user_id</column>
<column>item_id</column>
@@ -9,6 +10,7 @@
<column>notification_data</column>
<row>
<value>1</value>
+ <value>1</value>
<value>6</value>
<value>1</value>
<value>1</value>
diff --git a/tests/notification/fixtures/submit_post_notification.type.quote.xml b/tests/notification/fixtures/submit_post_notification.type.quote.xml
index c66830fbf5..9f4ba91475 100644
--- a/tests/notification/fixtures/submit_post_notification.type.quote.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.quote.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_notifications">
+ <column>notification_id</column>
<column>notification_type_id</column>
<column>user_id</column>
<column>item_id</column>
@@ -9,6 +10,7 @@
<column>notification_data</column>
<row>
<value>1</value>
+ <value>1</value>
<value>5</value>
<value>1</value>
<value>1</value>
diff --git a/tests/notification/fixtures/submit_post_notification.type.topic.xml b/tests/notification/fixtures/submit_post_notification.type.topic.xml
index e0f6583f48..1f96ed2ee7 100644
--- a/tests/notification/fixtures/submit_post_notification.type.topic.xml
+++ b/tests/notification/fixtures/submit_post_notification.type.topic.xml
@@ -21,6 +21,7 @@
</row>
</table>
<table name="phpbb_notifications">
+ <column>notification_id</column>
<column>notification_type_id</column>
<column>user_id</column>
<column>item_id</column>
@@ -29,6 +30,7 @@
<column>notification_data</column>
<row>
<value>1</value>
+ <value>1</value>
<value>8</value>
<value>1</value>
<value>1</value>
diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php
index ec42aa193c..6bbabfc602 100644
--- a/tests/notification/notification_test.php
+++ b/tests/notification/notification_test.php
@@ -108,7 +108,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base
$types = array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test');
foreach ($types as $id => $type)
{
- $this->db->sql_query('INSERT INTO phpbb_notification_types ' .
+ $this->getConnection()->createQueryTable('insertNotification', 'INSERT INTO phpbb_notification_types ' .
$this->db->sql_build_array('INSERT', array(
'notification_type_id' => ($id + 1),
'notification_type_name' => $type,
diff --git a/tests/search/fixtures/posts.xml b/tests/search/fixtures/posts.xml
index 16232b8f39..4916cd188b 100644
--- a/tests/search/fixtures/posts.xml
+++ b/tests/search/fixtures/posts.xml
@@ -1,25 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_posts">
+ <column>post_id</column>
<column>post_username</column>
<column>post_subject</column>
<column>post_text</column>
<row>
+ <value>1</value>
<value>foo</value>
<value>foo</value>
<value>foo</value>
</row>
<row>
+ <value>2</value>
<value>bar</value>
<value>bar</value>
<value>bar</value>
</row>
<row>
+ <value>3</value>
<value>commonword</value>
<value>commonword</value>
<value>commonword</value>
</row>
<row>
+ <value>4</value>
<value>baaz</value>
<value>baaz</value>
<value>baaz</value>
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index b7386e9a3e..606c40a623 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -142,9 +142,86 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
$manager->database_synchronisation($table_column_map);
}
+ /**
+ * Create xml data set for insertion into database
+ *
+ * @param string $path Path to fixture XML
+ * @return PHPUnit_Extensions_Database_DataSet_DefaultDataSet|PHPUnit_Extensions_Database_DataSet_XmlDataSet
+ */
public function createXMLDataSet($path)
{
$this->fixture_xml_data = parent::createXMLDataSet($path);
+
+ // Extend XML data set on MSSQL
+ if (strpos($this->get_database_config()['dbms'], 'mssql') !== false)
+ {
+ $newXmlData = new PHPUnit_Extensions_Database_DataSet_DefaultDataSet();
+ $db = $this->new_dbal();
+ foreach ($this->fixture_xml_data as $key => $value)
+ {
+ /** @var \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData $tableMetaData */
+ $tableMetaData = $value->getTableMetaData();
+ $columns = $tableMetaData->getColumns();
+ $primaryKeys = $tableMetaData->getPrimaryKeys();
+
+ $sql = "SELECT COLUMN_NAME AS identity_column
+ FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE COLUMNPROPERTY(object_id(TABLE_SCHEMA + '.' + TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1
+ AND TABLE_NAME = '$key'
+ ORDER BY TABLE_NAME";
+ $result = $db->sql_query($sql);
+ $identity_columns = $db->sql_fetchrowset($result);
+ $has_default_identity = false;
+ $add_primary_keys = false;
+
+ // Iterate over identity columns to check for missing primary
+ // keys in data set and special identity column 'mssqlindex'
+ // that might have been added when no default identity column
+ // exists in the current table.
+ foreach ($identity_columns as $column)
+ {
+ if (in_array($column['identity_column'], $columns) && !in_array($column['identity_column'], $primaryKeys))
+ {
+ $primaryKeys[] = $column['identity_column'];
+ $add_primary_keys = true;
+ }
+
+ if ($column['identity_column'] === 'mssqlindex')
+ {
+ $has_default_identity = true;
+ break;
+ }
+ }
+
+ if ($has_default_identity || $add_primary_keys)
+ {
+ // Add default identity column to columns list
+ if ($has_default_identity)
+ {
+ $columns[] = 'mssqlindex';
+ }
+
+ $newMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($key, $columns, $primaryKeys);
+ $newTable = new PHPUnit_Extensions_Database_DataSet_DefaultTable($newMetaData);
+ for ($i = 0; $i < $value->getRowCount(); $i++)
+ {
+ $dataRow = $value->getRow($i);
+ if ($has_default_identity)
+ {
+ $dataRow['mssqlindex'] = $i + 1;
+ }
+ $newTable->addRow($dataRow);
+ }
+ $newXmlData->addTable($newTable);
+ }
+ else
+ {
+ $newXmlData->addTable($value);
+ }
+ }
+
+ $this->fixture_xml_data = $newXmlData;
+ }
return $this->fixture_xml_data;
}
@@ -229,7 +306,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
{
// http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important
// but one array_diff is not enough!
- if (sizeof(array_diff($one, $two)) || sizeof(array_diff($two, $one)))
+ if (count(array_diff($one, $two)) || count(array_diff($two, $one)))
{
// get a nice error message
$this->assertEquals($one, $two);
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index 147029d699..f3adbefc1b 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -222,6 +222,14 @@ class phpbb_database_test_connection_manager
$this->purge_extras();
break;
+ case 'phpbb\db\driver\mssql':
+ case 'phpbb\db\driver\mssqlnative':
+ $this->connect();
+ // Drop all tables
+ $this->pdo->exec("EXEC sp_MSforeachtable 'DROP TABLE ?'");
+ $this->purge_extras();
+ break;
+
default:
$this->connect(false);
@@ -621,7 +629,7 @@ class phpbb_database_test_connection_manager
}
// Combine all of the SETVALs into one query
- if (sizeof($setval_queries))
+ if (count($setval_queries))
{
$queries[] = 'SELECT ' . implode(', ', $setval_queries);
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index c9943c4302..2be16c7198 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -425,7 +425,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$meta_refresh = $crawler->filter('meta[http-equiv="refresh"]');
// Wait for extension to be fully enabled
- while (sizeof($meta_refresh))
+ while (count($meta_refresh))
{
preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match);
$url = $match[1];
@@ -509,7 +509,6 @@ class phpbb_functional_test_case extends phpbb_test_case
else
{
$db->sql_multi_insert(STYLES_TABLE, array(array(
- 'style_id' => $style_id,
'style_name' => $style_path,
'style_copyright' => '',
'style_active' => 1,
@@ -990,7 +989,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$this->assertEquals(
1,
- sizeof($result),
+ count($result),
$message ?: 'Failed asserting that exactly one checkbox with name' .
" $name exists in crawler scope."
);
diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php
index b875d3212b..d38d14f45c 100644
--- a/tests/test_framework/phpbb_ui_test_case.php
+++ b/tests/test_framework/phpbb_ui_test_case.php
@@ -317,7 +317,7 @@ class phpbb_ui_test_case extends phpbb_test_case
$meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
// Wait for extension to be fully enabled
- while (sizeof($meta_refresh))
+ while (count($meta_refresh))
{
preg_match('#url=.+/(adm+.+)#', $meta_refresh->getAttribute('content'), $match);
$this->getDriver()->execute(array('method' => 'post', 'url' => $match[1]));
diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php
index 3daa75b2e4..498c6a69a2 100644
--- a/tests/tree/nestedset_forum_base.php
+++ b/tests/tree/nestedset_forum_base.php
@@ -69,7 +69,7 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
static $forums;
if (empty($forums))
- {
+ {
$this->create_forum('Parent with two flat children');
$this->create_forum('Flat child #1', 1);
$this->create_forum('Flat child #2', 1);
@@ -86,7 +86,7 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
// Updating forum_parents column here so it's not empty
// This is required, so we can see whether the methods
- // correctly clear the values.
+ // correctly clear the values.
$sql = "UPDATE phpbb_forums
SET forum_parents = 'a:0:{}'";
$this->db->sql_query($sql);
@@ -100,6 +100,13 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
}
else
{
+ // Turn on identity insert on mssql to be able to insert into
+ // identity columns (e.g. forum_id)
+ if (strpos($this->db->sql_layer, 'mssql') !== false)
+ {
+ $sql = 'SET IDENTITY_INSERT phpbb_forums ON';
+ $this->db->sql_query($sql);
+ }
$buffer = new \phpbb\db\sql_insert_buffer($this->db, 'phpbb_forums');
$buffer->insert_all($forums);
$buffer->flush();
@@ -107,7 +114,14 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
$this->database_synchronisation(array(
'phpbb_forums' => array('forum_id'),
));
- }
+
+ // Disable identity insert on mssql again
+ if (strpos($this->db->sql_layer, 'mssql') !== false)
+ {
+ $sql = 'SET IDENTITY_INSERT phpbb_forums OFF';
+ $this->db->sql_query($sql);
+ }
+ }
}
protected function create_forum($name, $parent_id = 0)
diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php
index fb72823f08..5b3357237d 100644
--- a/tests/upload/fileupload_test.php
+++ b/tests/upload/fileupload_test.php
@@ -173,7 +173,7 @@ class phpbb_fileupload_test extends phpbb_test_case
->set_max_filesize(1000);
$file = $this->gen_valid_filespec();
$upload->common_checks($file);
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
}
public function test_local_upload()
@@ -184,7 +184,7 @@ class phpbb_fileupload_test extends phpbb_test_case
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
$this->assertFalse($file->additional_checks());
$this->assertTrue($file->move_file('../tests/upload/fixture/copies', true));
$file->remove();
@@ -198,10 +198,10 @@ class phpbb_fileupload_test extends phpbb_test_case
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
$this->assertFalse($file->move_file('../tests/upload/fixture'));
$this->assertFalse($file->get('file_moved'));
- $this->assertEquals(1, sizeof($file->error));
+ $this->assertEquals(1, count($file->error));
}
public function test_move_existent_file_overwrite()
@@ -213,9 +213,9 @@ class phpbb_fileupload_test extends phpbb_test_case
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
$file->move_file('../tests/upload/fixture/copies', true);
- $this->assertEquals(0, sizeof($file->error));
+ $this->assertEquals(0, count($file->error));
unlink($this->path . 'copies/jpg.jpg');
}
diff --git a/tests/wrapper/version_compare_test.php b/tests/wrapper/version_compare_test.php
index 8260d99504..ee23fe779c 100644
--- a/tests/wrapper/version_compare_test.php
+++ b/tests/wrapper/version_compare_test.php
@@ -66,7 +66,7 @@ class phpbb_wrapper_version_compare_test extends phpbb_test_case
'3.2-A1',
);
- for ($i = 0, $size = sizeof($releases); $i < $size - 1; ++$i)
+ for ($i = 0, $size = count($releases); $i < $size - 1; ++$i)
{
$version1 = $releases[$i];
$version2 = $releases[$i + 1];