1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-29 12:23:43 +02:00

[ticket/11413] Don't use the database for the convert test

Different databases seem to work slightly differently here and are causing
errors

PHPBB3-11413
This commit is contained in:
Nathaniel Guse 2013-04-30 21:38:40 -05:00
parent f2e618a05d
commit 2f2feaa4e8
2 changed files with 26 additions and 22 deletions
phpBB/includes/db/migration/data/310
tests/notification

@ -100,7 +100,16 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration
public function convert_notifications()
{
$insert_table = $this->table_prefix . 'user_notifications';
$insert_buffer = new phpbb_db_sql_insert_buffer($this->db, $insert_table);
$this->perform_conversion($insert_buffer, $insert_table);
}
/**
* Perform the conversion (separate for testability)
*/
public function perform_conversion($insert_buffer, $insert_table)
{
$sql = 'DELETE FROM ' . $insert_table;
$this->db->sql_query($sql);
@ -108,7 +117,6 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration
FROM ' . USERS_TABLE;
$result = $this->db->sql_query($sql);
$insert_buffer = new phpbb_db_sql_insert_buffer($this->db, $insert_table);
while ($row = $this->db->sql_fetchrow($result))
{
$notification_methods = array();
@ -162,6 +170,7 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration
'item_type' => $item_type,
'item_id' => (int) $item_id,
'user_id' => (int) $user_id,
'notify' => 1
);
foreach ($methods as $method)

@ -38,38 +38,33 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
public function test_convert()
{
$this->migration->convert_notifications();
$buffer = new phpbb_mock_sql_insert_buffer($this->db, 'phpbb_user_notifications');
$this->migration->perform_conversion($buffer, 'phpbb_user_notifications');
$expected = array_merge(
$this->create_expected('post', 1, 'email'),
$this->create_expected('topic', 1, 'email'),
$this->create_expected('pm', 2, 'email'),
$this->create_expected('post', 2, 'email'),
$this->create_expected('topic', 2, 'email'),
$this->create_expected('pm', 2, 'email'),
$this->create_expected('post', 3, 'jabber'),
$this->create_expected('topic', 3, 'jabber'),
$this->create_expected('pm', 4, 'jabber'),
$this->create_expected('post', 4, 'jabber'),
$this->create_expected('topic', 4, 'jabber'),
$this->create_expected('pm', 4, 'jabber'),
$this->create_expected('post', 5, 'both'),
$this->create_expected('topic', 5, 'both'),
$this->create_expected('pm', 6, 'both'),
$this->create_expected('post', 6, 'both'),
$this->create_expected('topic', 6, 'both')
$this->create_expected('topic', 6, 'both'),
$this->create_expected('pm', 6, 'both')
);
$sql = 'SELECT * FROM phpbb_user_notifications
ORDER BY user_id ASC, item_type ASC';
$result = $this->db->sql_query($sql);
$rowset = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
$this->assertEquals($expected, $rowset);
$this->assertEquals($expected, $buffer->get_buffer());
}
protected function create_expected($type, $user_id, $method = '')
@ -80,10 +75,10 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
{
$return[] = array(
'item_type' => $type,
'item_id' => '0',
'user_id' => (string) $user_id,
'item_id' => 0,
'user_id' => $user_id,
'method' => '',
'notify' => '1',
'notify' => 1,
);
}
@ -91,10 +86,10 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
{
$return[] = array(
'item_type' => $type,
'item_id' => '0',
'user_id' => (string) $user_id,
'item_id' => 0,
'user_id' => $user_id,
'method' => 'email',
'notify' => '1',
'notify' => 1,
);
}
@ -102,10 +97,10 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
{
$return[] = array(
'item_type' => $type,
'item_id' => '0',
'user_id' => (string) $user_id,
'item_id' => 0,
'user_id' => $user_id,
'method' => 'jabber',
'notify' => '1',
'notify' => 1,
);
}