Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_ucp_allow_pm_test | |
0.00% |
0 / 23 |
|
0.00% |
0 / 5 |
30 | |
0.00% |
0 / 1 |
| setUp | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| test_enabled_pm_user_to_user | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| test_disabled_pm_user_to_user | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| test_disabled_pm_admin_to_user | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| set_user_allow_pm | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | /** |
| 15 | * @group functional |
| 16 | */ |
| 17 | class phpbb_functional_ucp_allow_pm_test extends phpbb_functional_test_case |
| 18 | { |
| 19 | protected static $data = array(); |
| 20 | |
| 21 | protected function setUp(): void |
| 22 | { |
| 23 | parent::setUp(); |
| 24 | |
| 25 | $this->setBackupStaticPropertiesExcludeList([ |
| 26 | 'phpbb_functional_ucp_allow_pm_test' => ['data'], |
| 27 | ]); |
| 28 | } |
| 29 | |
| 30 | // user A sends a PM to user B where B accepts PM |
| 31 | public function test_enabled_pm_user_to_user() |
| 32 | { |
| 33 | // setup |
| 34 | $this->create_user('test_ucp_allow_pm_sender'); |
| 35 | $this->login('test_ucp_allow_pm_sender'); |
| 36 | self::$data['recipient_id'] = $this->create_user('test_ucp_allow_pm_recipient'); |
| 37 | self::$data['pm_url'] = "ucp.php?i=pm&mode=compose&u=" . (int) self::$data['recipient_id'] . "&sid={$this->sid}"; |
| 38 | |
| 39 | // the actual test |
| 40 | $this->set_user_allow_pm(self::$data['recipient_id'], 1); |
| 41 | $crawler = self::request('GET', self::$data['pm_url']); |
| 42 | $this->assertNotContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('html')->text()); |
| 43 | } |
| 44 | |
| 45 | // user A sends a PM to user B where B does not accept PM |
| 46 | public function test_disabled_pm_user_to_user() |
| 47 | { |
| 48 | $this->login('test_ucp_allow_pm_sender'); |
| 49 | $this->set_user_allow_pm(self::$data['recipient_id'], 0); |
| 50 | $crawler = self::request('GET', self::$data['pm_url']); |
| 51 | $this->assertContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('.error')->text()); |
| 52 | } |
| 53 | |
| 54 | |
| 55 | // An admin sends a PM to user B where B does not accept PM, but cannot |
| 56 | // ignore a PM from an admin |
| 57 | public function test_disabled_pm_admin_to_user() |
| 58 | { |
| 59 | $this->login(); |
| 60 | $crawler = self::request('GET', self::$data['pm_url']); |
| 61 | $this->assertNotContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('html')->text()); |
| 62 | } |
| 63 | |
| 64 | // enable or disable PM for a user, like from ucp |
| 65 | protected function set_user_allow_pm($user_id, $allow) |
| 66 | { |
| 67 | $sql = 'UPDATE ' . USERS_TABLE . " |
| 68 | SET user_allow_pm = " . $allow . " |
| 69 | WHERE user_id = " . $user_id; |
| 70 | $result = $this->db->sql_query($sql); |
| 71 | $this->db->sql_freeresult($result); |
| 72 | } |
| 73 | } |