diff options
author | n-aleha <nick_aleha@myway.com> | 2014-05-07 15:58:51 +0300 |
---|---|---|
committer | n-aleha <nick_aleha@myway.com> | 2014-05-07 23:00:50 +0300 |
commit | 83a905de4b1322deb324edbad024278439b99e83 (patch) | |
tree | 1c02429275136fd7e235c65ff3b7515c9e127d13 | |
parent | 0166493a897c66c5e387aac06a8e2ae2bc17b63f (diff) | |
download | forums-83a905de4b1322deb324edbad024278439b99e83.tar forums-83a905de4b1322deb324edbad024278439b99e83.tar.gz forums-83a905de4b1322deb324edbad024278439b99e83.tar.bz2 forums-83a905de4b1322deb324edbad024278439b99e83.tar.xz forums-83a905de4b1322deb324edbad024278439b99e83.zip |
[ticket/12493] Add functional test
Added a functional test.
PHPBB3-12493
-rw-r--r-- | tests/functional/ucp_allow_pm_test.php | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/functional/ucp_allow_pm_test.php b/tests/functional/ucp_allow_pm_test.php new file mode 100644 index 0000000000..b433ec8e75 --- /dev/null +++ b/tests/functional/ucp_allow_pm_test.php @@ -0,0 +1,70 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @group functional +*/ +class phpbb_functional_ucp_allow_pm_test extends phpbb_functional_test_case +{ + static protected $data = array(); + + public function __construct() + { + parent::__construct(); + + $this->backupStaticAttributesBlacklist += array( + 'phpbb_functional_ucp_allow_pm_test' => array('data'), + ); + } + + // user A sends a PM to user B where B accepts PM + public function test_enabled_pm_user_to_user() + { + // setup + $this->create_user('test_ucp_allow_pm_sender'); + $this->login('test_ucp_allow_pm_sender'); + self::$data['recipient_id'] = $this->create_user('test_ucp_allow_pm_recipient'); + self::$data['pm_url'] = "ucp.php?i=pm&mode=compose&u=" . (int) self::$data['recipient_id'] . "&sid={$this->sid}"; + + // the actual test + $this->set_user_allow_pm(self::$data['recipient_id'], 1); + $crawler = self::request('GET', self::$data['pm_url']); + $this->assertNotContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('html')->text()); + } + + // user A sends a PM to user B where B does not accept PM + public function test_disabled_pm_user_to_user() + { + $this->login('test_ucp_allow_pm_sender'); + $this->set_user_allow_pm(self::$data['recipient_id'], 0); + $crawler = self::request('GET', self::$data['pm_url']); + $this->assertContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('.error')->text()); + } + + + // An admin sends a PM to user B where B does not accept PM, but cannot + // ignore a PM from an admin + public function test_disabled_pm_admin_to_user() + { + $this->login(); + $crawler = self::request('GET', self::$data['pm_url']); + $this->assertNotContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('html')->text()); + } + + // enable or disable PM for a user, like from ucp + protected function set_user_allow_pm($user_id, $allow) + { + $db = $this->get_db(); + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_allow_pm = " . $allow . " + WHERE user_id = " . $user_id; + $result = $db->sql_query($sql); + $db->sql_freeresult($result); + } +} |