diff options
author | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-05-29 16:04:56 +0200 |
---|---|---|
committer | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-05-29 16:04:56 +0200 |
commit | 2aecb9406811cfa6fa9a6de1094479d4b62990f0 (patch) | |
tree | 6d7da95f85ecd99374b221ca05984d335602dda7 /tests | |
parent | a3d46575c7f520dc9731ed4e9221c636c5c7c31e (diff) | |
parent | c76d797cb2c4abb97c4e887b8c175626c7c9ba1e (diff) | |
download | forums-2aecb9406811cfa6fa9a6de1094479d4b62990f0.tar forums-2aecb9406811cfa6fa9a6de1094479d4b62990f0.tar.gz forums-2aecb9406811cfa6fa9a6de1094479d4b62990f0.tar.bz2 forums-2aecb9406811cfa6fa9a6de1094479d4b62990f0.tar.xz forums-2aecb9406811cfa6fa9a6de1094479d4b62990f0.zip |
Merge pull request #3383 from nickvergessen/ticket/9109
Ticket/9109 Properly document and calculate the group settings with value 0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml | 83 | ||||
-rw-r--r-- | tests/functions_privmsgs/get_max_setting_from_group_test.php | 64 |
2 files changed, 147 insertions, 0 deletions
diff --git a/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml b/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml new file mode 100644 index 0000000000..c78d63f7cb --- /dev/null +++ b/tests/functions_privmsgs/fixtures/get_max_setting_from_group.xml @@ -0,0 +1,83 @@ +<?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> + <row> + <value>4</value> + <value></value> + <value>0</value> + <value>5</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> + <row> + <value>4</value> + <value>4</value> + <value>0</value> + </row> + <row> + <value>5</value> + <value>3</value> + <value>1</value> + </row> + <row> + <value>5</value> + <value>2</value> + <value>0</value> + </row> + </table> +</dataset> diff --git a/tests/functions_privmsgs/get_max_setting_from_group_test.php b/tests/functions_privmsgs/get_max_setting_from_group_test.php new file mode 100644 index 0000000000..3eb7866802 --- /dev/null +++ b/tests/functions_privmsgs/get_max_setting_from_group_test.php @@ -0,0 +1,64 @@ +<?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(4, 0, 'message_limit'), + array(5, 2, 'message_limit'), + array(1, 0, 'max_recipients'), + array(2, 4, 'max_recipients'), + array(3, 0, 'max_recipients'), + array(4, 5, 'max_recipients'), + array(5, 4, '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'); + } +} |