Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 48 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_acp_profile_field_test | |
0.00% |
0 / 48 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
| setUp | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| data_add_profile_field | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
2 | |||
| test_add_profile_field | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| test_edit_profile_fields | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
6 | |||
| 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 | */ |
| 17 | class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case |
| 18 | { |
| 19 | protected function setUp(): void |
| 20 | { |
| 21 | parent::setUp(); |
| 22 | |
| 23 | $this->login(); |
| 24 | $this->admin_login(); |
| 25 | $this->add_lang('acp/profile'); |
| 26 | } |
| 27 | |
| 28 | public static function data_add_profile_field() |
| 29 | { |
| 30 | return array( |
| 31 | array('profilefields.type.bool', |
| 32 | array( |
| 33 | 'field_ident' => 'bool', |
| 34 | 'lang_name' => 'bool', |
| 35 | 'lang_options[0]' => 'foo', |
| 36 | 'lang_options[1]' => 'bar', |
| 37 | ), |
| 38 | ), |
| 39 | array('profilefields.type.dropdown', |
| 40 | array( |
| 41 | 'field_ident' => 'dropdown', |
| 42 | 'lang_name' => 'dropdown', |
| 43 | 'lang_options' => "foo\nbar\nbar\nfoo", |
| 44 | ), |
| 45 | ), |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @dataProvider data_add_profile_field |
| 51 | */ |
| 52 | public function test_add_profile_field($type, $page1_settings) |
| 53 | { |
| 54 | // Custom profile fields page |
| 55 | $crawler = self::request('GET', 'adm/index.php?i=acp_profile&mode=profile&sid=' . $this->sid); |
| 56 | // these language strings are html |
| 57 | $form = $crawler->selectButton('Create new field')->form(array( |
| 58 | 'field_type' => $type, |
| 59 | )); |
| 60 | $crawler = self::submit($form); |
| 61 | |
| 62 | // Fill form for profile field options |
| 63 | $form = $crawler->selectButton('Profile type specific options')->form($page1_settings); |
| 64 | $crawler = self::submit($form); |
| 65 | |
| 66 | // Fill form for profile field specific options |
| 67 | $form = $crawler->selectButton('Save')->form(); |
| 68 | $crawler= self::submit($form); |
| 69 | |
| 70 | $this->assertContainsLang('ADDED_PROFILE_FIELD', $crawler->text()); |
| 71 | } |
| 72 | |
| 73 | public function test_edit_profile_fields() |
| 74 | { |
| 75 | // Custom profile fields page |
| 76 | $crawler = self::request('GET', 'adm/index.php?i=acp_profile&mode=profile&sid=' . $this->sid); |
| 77 | |
| 78 | // Get all profile fields edit URLs |
| 79 | $edits = $crawler->filter('td.actions a') |
| 80 | ->reduce( |
| 81 | function ($node, $i) { |
| 82 | $url = $node->attr('href'); |
| 83 | return ((bool) strpos($url, 'action=edit')); |
| 84 | }) |
| 85 | ->each( |
| 86 | function ($node, $i) { |
| 87 | $url = $node->attr('href'); |
| 88 | return ($url); |
| 89 | }); |
| 90 | |
| 91 | foreach ($edits as $edit_url) |
| 92 | { |
| 93 | $crawler = self::request('GET', 'adm/' . $edit_url . '&sid=' . $this->sid); |
| 94 | $form = $crawler->selectButton('Save')->form(); |
| 95 | $crawler= self::submit($form); |
| 96 | |
| 97 | $this->assertContainsLang('CHANGED_PROFILE_FIELD', $crawler->text()); |
| 98 | } |
| 99 | } |
| 100 | } |