aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/report_post_captcha_test.php
blob: 36a1a9ee4d79609ca260ac7cad9341486a1526f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?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.
*
*/

/**
 * @group functional
 */
class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_case
{
	public function test_guest_report_post()
	{
		$crawler = self::request('GET', 'app.php/post/1/report', array(), false);
		$this->assert_response_html(403);
		$this->add_lang('mcp');
		$this->assertContains($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text());

		$this->set_reporting_guest(1);
		$crawler = self::request('GET', 'app.php/post/1/report');
		$this->assertContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());
		$this->set_reporting_guest(-1);
	}

	public function test_user_report_post()
	{
		$this->login();
		$crawler = self::request('GET', 'app.php/post/1/report');
		$this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());

		$this->add_lang('mcp');
		$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
		$crawler = self::submit($form);
		$this->assertContains($this->lang('POST_REPORTED_SUCCESS'), $crawler->text());
	}

	protected function set_reporting_guest($report_post_allowed)
	{
		$this->login();
		$this->admin_login();

		$crawler = self::request('GET', 'adm/index.php?i=permissions&icat=12&mode=setting_group_local&sid=' . $this->sid);
		$form = $crawler->selectButton('Submit')->form();
		$values = $form->getValues();
		$values["group_id[0]"] = 1;
		$form->setValues($values);
		$crawler = self::submit($form);

		$form = $crawler->selectButton('Submit')->form();
		$values = $form->getValues();
		$values["forum_id"] = 2;
		$form->setValues($values);
		$crawler = self::submit($form);

		$this->add_lang('acp/permissions');
		$form = $crawler->selectButton($this->lang('APPLY_ALL_PERMISSIONS'))->form();
		$values = $form->getValues();
		$values["setting[1][2][f_report]"] = $report_post_allowed;
		$form->setValues($values);
		$crawler = self::submit($form);

		$crawler = self::request('GET', 'ucp.php?mode=logout&sid=' . $this->sid);
	}
}