Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
27.27% covered (danger)
27.27%
12 / 44
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_acp_board_select_auth_method_test
27.27% covered (danger)
27.27%
12 / 44
66.67% covered (warning)
66.67%
2 / 3
6.46
0.00% covered (danger)
0.00%
0 / 1
 select_auth_method_data
0.00% covered (danger)
0.00%
0 / 32
0.00% covered (danger)
0.00%
0 / 1
2
 setUp
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
1
 test_select_auth_method
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
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
14require_once __DIR__ . '/../../phpBB/includes/acp/acp_board.php';
15require_once __DIR__ . '/auth_provider/invalid.php';
16require_once __DIR__ . '/auth_provider/valid.php';
17
18class phpbb_acp_board_select_auth_method_test extends phpbb_test_case
19{
20    protected $acp_board;
21
22    public static function select_auth_method_data()
23    {
24        return [
25            [
26                'acp_board_valid',
27                [
28                    'options' => [
29                        0 => [
30                            'value'        => 'acp_board_valid',
31                            'label'        => 'Acp_board_valid',
32                            'selected'    => true,
33                            'data'         => [
34                                'toggle-setting' => '#auth_acp_board_valid_settings',
35                            ],
36                        ]
37                    ],
38                ]
39            ],
40            [
41                'acp_board_invalid',
42                [
43                    'options' => [
44                        0 => [
45                            'value'        => 'acp_board_valid',
46                            'label'        => 'Acp_board_valid',
47                            'selected'    => false,
48                            'data'         => [
49                                'toggle-setting' => '#auth_acp_board_valid_settings',
50                            ],
51                        ]    
52                    ],
53                ]
54            ],
55        ];
56    }
57
58    protected function setUp(): void
59    {
60        parent::setUp();
61
62        global $phpbb_container, $config;
63        $phpbb_container = new phpbb_mock_container_builder();
64        $config = new \phpbb\config\config([]);
65
66        // Create auth provider service collection
67        $auth_provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config);
68        $phpbb_container->set('auth.provider_collection', $auth_provider_collection);
69
70        // Create auth provider services
71        $phpbb_container->set('auth.provider.acp_board_valid', new phpbb\auth\provider\acp\board_valid);
72        $phpbb_container->set('auth.provider.acp_board_invalid', new phpbb\auth\provider\acp\board_invalid);
73
74        // Add auth provider servives to the service collection
75        $auth_provider_collection->add('auth.provider.acp_board_valid');
76        $auth_provider_collection->add('auth.provider.acp_board_invalid');
77
78        $this->acp_board = new acp_board();
79    }
80
81    /**
82    * @dataProvider select_auth_method_data
83    */
84    public function test_select_auth_method($selected, $expected)
85    {
86        $this->assertEquals($expected, $this->acp_board->select_auth_method($selected));
87    }
88}