Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 44 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_private_messages_test | |
0.00% |
0 / 44 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
| test_setup_config | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| test_inbox_full | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| test_restore_config | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| test_quote_post | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| test_quote_pm | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_quote_forward | |
0.00% |
0 / 6 |
|
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_private_messages_test extends phpbb_functional_test_case |
| 18 | { |
| 19 | public function test_setup_config() |
| 20 | { |
| 21 | $this->login(); |
| 22 | $this->admin_login(); |
| 23 | |
| 24 | $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=board&mode=message"); |
| 25 | |
| 26 | $form = $crawler->selectButton('Submit')->form(); |
| 27 | $values = $form->getValues(); |
| 28 | |
| 29 | // Set the maximum number of private messages per folder to 1 |
| 30 | $values['config[pm_max_msgs]'] = 1; |
| 31 | |
| 32 | $form->setValues($values); |
| 33 | |
| 34 | $crawler = self::submit($form); |
| 35 | $this->assertStringContainsString($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text()); |
| 36 | } |
| 37 | |
| 38 | public function test_inbox_full() |
| 39 | { |
| 40 | $this->login(); |
| 41 | $message_id = $this->create_private_message('Test private message #1', 'This is a test private message sent by the testing framework.', array(2)); |
| 42 | |
| 43 | $crawler = self::request('GET', "ucp.php?i=pm&mode=view&sid{$this->sid}&p={$message_id}"); |
| 44 | $this->assertStringContainsString($this->lang('UCP_PM_VIEW'), $crawler->filter('html')->text()); |
| 45 | |
| 46 | $message_id = $this->create_private_message('Test private message #2', 'This is a test private message sent by the testing framework.', array(2)); |
| 47 | |
| 48 | $crawler = self::request('GET', "ucp.php?i=pm&mode=view&sid{$this->sid}&p={$message_id}"); |
| 49 | $this->assertStringContainsString($this->lang('NO_AUTH_READ_HOLD_MESSAGE'), $crawler->filter('html')->text()); |
| 50 | } |
| 51 | |
| 52 | public function test_restore_config() |
| 53 | { |
| 54 | $this->login(); |
| 55 | $this->admin_login(); |
| 56 | |
| 57 | $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=board&mode=message"); |
| 58 | |
| 59 | $form = $crawler->selectButton('Submit')->form(); |
| 60 | $values = $form->getValues(); |
| 61 | |
| 62 | $values['config[pm_max_msgs]'] = 50; |
| 63 | |
| 64 | $form->setValues($values); |
| 65 | |
| 66 | $crawler = self::submit($form); |
| 67 | $this->assertStringContainsString($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text()); |
| 68 | } |
| 69 | |
| 70 | public function test_quote_post() |
| 71 | { |
| 72 | $text = 'Test post'; |
| 73 | |
| 74 | $this->login(); |
| 75 | $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); |
| 76 | $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); |
| 77 | |
| 78 | $expected = '(\\[quote=admin post_id=' . $post['post_id'] . ' time=\\d+ user_id=2\\]' . $text . '\\[/quote\\])'; |
| 79 | |
| 80 | $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quotepost&p=' . $post['post_id'] . '&sid=' . $this->sid); |
| 81 | |
| 82 | $this->assertMatchesRegularExpression($expected, $crawler->filter('textarea#message')->text()); |
| 83 | } |
| 84 | |
| 85 | public function test_quote_pm() |
| 86 | { |
| 87 | $text = 'This is a test private message sent by the testing framework.'; |
| 88 | $expected = "(\[quote=admin msg_id=[\d]+ time=[\d]+ user_id=2\]\s?" . $text . "\s?\[\/quote\])"; |
| 89 | |
| 90 | $this->login(); |
| 91 | $message_id = $this->create_private_message('Test', $text, array(2)); |
| 92 | |
| 93 | $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quote&p=' . $message_id . '&sid=' . $this->sid); |
| 94 | |
| 95 | $this->assertMatchesRegularExpression($expected, $crawler->filter('textarea#message')->text()); |
| 96 | } |
| 97 | |
| 98 | public function test_quote_forward() |
| 99 | { |
| 100 | $text = 'This is a test private message sent by the testing framework.'; |
| 101 | $expected = "(\[quote=admin\]\s?" . $text . "\s?\[\/quote\])"; |
| 102 | |
| 103 | $this->login(); |
| 104 | $message_id = $this->create_private_message('Test', $text, array(2)); |
| 105 | |
| 106 | $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=forward&f=0&p=' . $message_id . '&sid=' . $this->sid); |
| 107 | |
| 108 | $this->assertMatchesRegularExpression($expected, $crawler->filter('textarea#message')->text()); |
| 109 | } |
| 110 | } |