Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 25
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_functional_common_groups_test_case
0.00% covered (danger)
0.00%
0 / 25
0.00% covered (danger)
0.00%
0 / 5
30
0.00% covered (danger)
0.00%
0 / 1
 get_url
n/a
0 / 0
n/a
0 / 0
0
 get_group_manage_form
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 group_manage_login
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 enable_all_avatars
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 groups_manage_test_data
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 test_groups_manage
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
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*/
17abstract class phpbb_functional_common_groups_test_case extends phpbb_functional_test_case
18{
19    abstract protected function get_url();
20
21    /**
22    * Get group_manage form
23    * @param int $group_id ID of the group that should be managed
24    */
25    protected function get_group_manage_form($group_id = 5)
26    {
27        // Manage Administrators group
28        $crawler = self::request('GET', $this->get_url() . "&g=$group_id&sid=" . $this->sid);
29        $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
30        return $form;
31    }
32
33    /**
34    * Execute login calls and add_lang() calls for tests
35    */
36    protected function group_manage_login()
37    {
38        $this->login();
39        $this->admin_login();
40        $this->add_lang(array('ucp', 'acp/groups'));
41    }
42
43    // Enable all avatars in the ACP
44    protected function enable_all_avatars()
45    {
46        $this->add_lang('acp/board');
47
48        $crawler = self::request('GET', 'adm/index.php?i=board&mode=avatar&sid=' . $this->sid);
49        // Check the default entries we should have
50        $this->assertStringContainsString($this->lang('ALLOW_AVATARS'), $crawler->text());
51        $this->assertStringContainsString($this->lang('ALLOW_LOCAL'), $crawler->text());
52
53        // Now start setting the needed settings
54        $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
55        $form['config[allow_avatar_local]']->select(1);
56        $crawler = self::submit($form);
57        $this->assertStringContainsString($this->lang('CONFIG_UPDATED'), $crawler->text());
58    }
59
60    public static function groups_manage_test_data()
61    {
62        return array(
63            array('', 'GROUP_UPDATED'),
64            array('aa0000', 'GROUP_UPDATED'),
65
66            array('AAG000','WRONG_DATA_COLOUR'),
67            array('#AA0000', 'WRONG_DATA_COLOUR'),
68        );
69    }
70
71    /**
72    * @dataProvider groups_manage_test_data
73    */
74    public function test_groups_manage($input, $expected)
75    {
76        $this->group_manage_login();
77
78        // Manage Administrators group
79        $form = $this->get_group_manage_form();
80        $form['group_colour']->setValue($input);
81        $crawler = self::submit($form);
82        $this->assertStringContainsString($this->lang($expected), $crawler->text());
83    }
84}