1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/9109] Properly document and calculate the group settings with value 0

PHPBB3-9109
This commit is contained in:
Joas Schilling
2015-01-25 00:33:26 +01:00
parent b0c910e49c
commit 291143fe6a
5 changed files with 170 additions and 15 deletions

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_groups">
<column>group_id</column>
<column>group_desc</column>
<column>group_message_limit</column>
<column>group_max_recipients</column>
<row>
<value>1</value>
<value></value>
<value>1</value>
<value>3</value>
</row>
<row>
<value>2</value>
<value></value>
<value>2</value>
<value>4</value>
</row>
<row>
<value>3</value>
<value></value>
<value>0</value>
<value>0</value>
</row>
</table>
<table name="phpbb_user_group">
<column>user_id</column>
<column>group_id</column>
<column>user_pending</column>
<row>
<value>1</value>
<value>1</value>
<value>0</value>
</row>
<row>
<value>1</value>
<value>2</value>
<value>0</value>
</row>
<row>
<value>1</value>
<value>3</value>
<value>0</value>
</row>
<row>
<value>2</value>
<value>1</value>
<value>0</value>
</row>
<row>
<value>2</value>
<value>2</value>
<value>0</value>
</row>
<row>
<value>3</value>
<value>3</value>
<value>0</value>
</row>
</table>
</dataset>

View File

@@ -0,0 +1,60 @@
<?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.
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_privmsgs.php';
class phpbb_functions_privmsgs_get_max_setting_from_group_test extends phpbb_database_test_case
{
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/get_max_setting_from_group.xml');
}
/** @var \phpbb\db\driver\driver_interface */
protected $db;
protected function setUp()
{
parent::setUp();
$this->db = $this->new_dbal();
}
static public function get_max_setting_from_group_data()
{
return array(
array(1, 0, 'message_limit'),
array(2, 2, 'message_limit'),
array(3, 0, 'message_limit'),
array(1, 0, 'max_recipients'),
array(2, 4, 'max_recipients'),
array(3, 0, 'max_recipients'),
);
}
/**
* @dataProvider get_max_setting_from_group_data
*/
public function test_get_max_setting_from_group($user_id, $expected, $setting)
{
$this->assertEquals($expected, phpbb_get_max_setting_from_group($this->db, $user_id, $setting));
}
/**
* @expectedException InvalidArgumentException
*/
public function test_get_max_setting_from_group_throws()
{
phpbb_get_max_setting_from_group($this->db, ANONYMOUS, 'not_a_setting');
}
}