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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
<?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_ucp_preferences_test extends phpbb_functional_test_case
{
public function test_submitting_preferences_view()
{
$this->add_lang('ucp');
$this->login();
$crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view');
$this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text());
$form = $crawler->selectButton('Submit')->form(array(
'topic_sk' => 'a',
'topic_sd' => 'a',
'topic_st' => '1',
'post_sk' => 'a',
'post_sd' => 'a',
'post_st' => '1',
));
$crawler = self::submit($form);
$this->assertContainsLang('PREFERENCES_UPDATED', $crawler->filter('#message')->text());
}
public function test_submitting_invalid_preferences_view()
{
$this->add_lang('ucp');
$this->login();
$crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view');
$this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text());
$form = $crawler->selectButton('Submit')->form();
if (!method_exists($form, 'disableValidation'))
{
$this->markTestIncomplete('The crawler cannot select invalid values, until Symfony 2.4!');
}
$form = $form->disableValidation();
$form['topic_sk']->select('z');
$form['topic_sd']->select('z');
$form['topic_st']->select('test');
$form['post_sk']->select('z');
$form['post_sd']->select('z');
$form['post_st']->select('test');
$crawler = self::submit($form);
$this->assertContainsLang('WRONG_DATA_POST_SD', $crawler->filter('#cp-main')->text());
$this->assertContainsLang('WRONG_DATA_POST_SK', $crawler->filter('#cp-main')->text());
$this->assertContainsLang('WRONG_DATA_TOPIC_SD', $crawler->filter('#cp-main')->text());
$this->assertContainsLang('WRONG_DATA_TOPIC_SK', $crawler->filter('#cp-main')->text());
}
public function test_read_preferences_view()
{
$this->add_lang('ucp');
$this->login();
$crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view');
$this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text());
$form = $crawler->selectButton('Submit')->form();
$this->assertEquals('a', $form->get('topic_sk')->getValue());
$this->assertEquals('a', $form->get('topic_sd')->getValue());
$this->assertEquals('1', $form->get('topic_st')->getValue());
$this->assertEquals('a', $form->get('post_sk')->getValue());
$this->assertEquals('a', $form->get('post_sd')->getValue());
$this->assertEquals('1', $form->get('post_st')->getValue());
}
}
|