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 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_functional_forum_password_test
0.00% covered (danger)
0.00%
0 / 25
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 test_setup_forum_with_password
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
 data_enter_forum_with_password
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 test_enter_forum_with_password
0.00% covered (danger)
0.00%
0 / 8
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*/
17class phpbb_functional_forum_password_test extends phpbb_functional_test_case
18{
19    public function test_setup_forum_with_password()
20    {
21        $this->login();
22        $this->admin_login();
23
24        $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
25        $form = $crawler->selectButton('addforum')->form(array(
26            'forum_name'    => 'Password protected',
27        ));
28        $crawler = self::submit($form);
29        $form = $crawler->selectButton('update')->form(array(
30            'forum_perm_from'        => 2,
31            'forum_password'        => 'foobar',
32            'forum_password_confirm'    => 'foobar',
33        ));
34        $crawler = self::submit($form);
35    }
36
37    public static function data_enter_forum_with_password()
38    {
39        return array(
40            array('foowrong', 'WRONG_PASSWORD'),
41            array('foobar', 'NO_TOPICS'),
42        );
43    }
44
45    /**
46    * @dataProvider data_enter_forum_with_password
47    */
48    public function test_enter_forum_with_password($password, $message)
49    {
50        $crawler = self::request('GET', "index.php?sid={$this->sid}");
51        preg_match('/.?f=([0-9])/', $crawler->selectLink('Password protected')->link()->getUri(), $match);
52        $crawler = self::request('GET', "viewforum.php?f={$match[1]}&sid={$this->sid}");
53        $form = $crawler->selectButton('login')->form(array(
54            'password'    => $password,
55        ));
56        $crawler = self::submit($form);
57        $this->assertContainsLang($message, $crawler->text());
58    }
59}