1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 14:00:31 +02:00

[ticket/11162] Move to a separate file to avoid blowing out functions.php.

PHPBB3-11162
This commit is contained in:
Oleg Pudeyev
2012-12-04 23:35:34 -05:00
parent 2fc43e6ed7
commit 0f96b1aad3
4 changed files with 104 additions and 88 deletions

View File

@@ -1,56 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_topics_watch">
<column>user_id</column>
<column>topic_id</column>
<column>notify_status</column>
<!-- one entry for this topic -->
<row>
<value>1</value>
<value>1</value>
<value>1</value>
</row>
<!-- non-conflicting entries -->
<row>
<value>2</value>
<value>2</value>
<value>1</value>
</row>
<row>
<value>3</value>
<value>3</value>
<value>1</value>
</row>
<!-- conflicting entries -->
<row>
<value>1</value>
<value>4</value>
<value>1</value>
</row>
<row>
<value>1</value>
<value>5</value>
<value>1</value>
</row>
<!-- conflicting and non-conflicting entries -->
<row>
<value>1</value>
<value>6</value>
<value>1</value>
</row>
<row>
<value>1</value>
<value>7</value>
<value>1</value>
</row>
<row>
<value>2</value>
<value>6</value>
<value>1</value>
</row>
</table>
</dataset>

View File

@@ -1,71 +0,0 @@
<?php
/**
*
* @package testing
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_update_rows_avoiding_duplicates_test extends phpbb_database_test_case
{
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/duplicates.xml');
}
public static function fixture_data()
{
return array(
// description
// from array
// to value
// expected count with to value post update
array(
'trivial',
array(1),
10,
1,
),
array(
'no conflict',
array(2),
3,
2,
),
array(
'conflict',
array(4),
5,
1,
),
array(
'conflict and no conflict',
array(6),
7,
2,
),
);
}
/**
* @dataProvider fixture_data
*/
public function test_trivial_update($description, $from, $to, $expected_result_count)
{
$db = $this->new_dbal();
phpbb_update_rows_avoiding_duplicates($db, TOPICS_WATCH_TABLE, 'topic_id', $from, $to);
$sql = 'SELECT COUNT(*) AS remaining_rows
FROM ' . TOPICS_WATCH_TABLE . '
WHERE topic_id = ' . (int) $to;
$result = $db->sql_query($sql);
$result_count = $db->sql_fetchfield('remaining_rows');
$db->sql_freeresult($result);
$this->assertEquals($expected_result_count, $result_count);
}
}