Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Friedman <[email protected]>
  • Loading branch information
iMattPro committed Jun 26, 2024
1 parent 9725c24 commit 655c5a4
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ jobs:
db: "mysql:5.7"
- php: '8.3'
db: "mysql:5.7"
- php: '8.4'
db: "mysql:5.7"

name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}

Expand Down Expand Up @@ -270,6 +272,8 @@ jobs:
db: "postgres:14"
- php: '8.3'
db: "postgres:14"
- php: '8.4'
db: "postgres:14"

name: PHP ${{ matrix.php }} - ${{ matrix.db }}

Expand Down
40 changes: 24 additions & 16 deletions tests/controller/acp_controller_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function test_list_announcements()
'announcement_enabled' => 1,
'announcement_timestamp' => 734284394,
'announcement_expiry' => 0,
'announcement_indexonly' => 0,
'announcement_locations' => '',
'announcement_users' => 0,
],
[
Expand All @@ -207,7 +207,7 @@ public function test_list_announcements()
'announcement_enabled' => 1,
'announcement_timestamp' => 797442794,
'announcement_expiry' => 0,
'announcement_indexonly' => 0,
'announcement_locations' => '["index",1]',
'announcement_users' => 0,
],
[
Expand All @@ -216,7 +216,7 @@ public function test_list_announcements()
'announcement_enabled' => 1,
'announcement_timestamp' => 681493994,
'announcement_expiry' => 1644162794,
'announcement_indexonly' => 0,
'announcement_locations' => '[]',
'announcement_users' => 0,
],
];
Expand Down Expand Up @@ -262,7 +262,7 @@ public function action_add_data()
'announcement_description' => 'Announcement 1',
'announcement_bgcolor' => '',
'announcement_enabled' => true,
'announcement_indexonly' => false,
'announcement_locations' => '',
'announcement_dismissable' => true,
'announcement_users' => \phpbb\boardannouncements\ext::ALL,
'announcement_timestamp' => '',
Expand All @@ -277,7 +277,7 @@ public function action_add_data()
'announcement_description' => 'Announcement 2',
'announcement_bgcolor' => '',
'announcement_enabled' => true,
'announcement_indexonly' => false,
'announcement_locations' => '',
'announcement_dismissable' => true,
'announcement_users' => \phpbb\boardannouncements\ext::ALL,
'announcement_timestamp' => '',
Expand Down Expand Up @@ -321,7 +321,7 @@ public function test_action_add($id, $data)
'announcement_description' => '',
'announcement_bgcolor' => '',
'announcement_enabled' => true,
'announcement_indexonly' => false,
'announcement_locations' => '',
'announcement_dismissable' => true,
'announcement_users' => \phpbb\boardannouncements\ext::ALL,
'announcement_timestamp' => 0,
Expand Down Expand Up @@ -350,15 +350,15 @@ public function test_action_add($id, $data)
public function action_add_submit_data()
{
return [
[0, ['add', 0, 'Announcement Text 0', 'Announcement Description 0', 'ffffff', true, 0, false, true, '', false, false, false], false, true, true, false], // submit
[1, ['add', 1, 'Announcement Text 1', 'Announcement Description 1', 'ffffff', true, 0, false, true, '', false, false, false], false, true, true, false], // submit
[0, ['add', 0, 'Announcement Text 0', 'Announcement Description 0', 'ffffff', true, 0, false, true, '', false, false, false], false, true, false, true], // submit, bad form
[0, ['add', 0, '', 'Announcement Description 0', 'ffffff', true, 0, false, true, '', false, false, false], false, true, true, true], // submit, bad text
[0, ['add', 0, 'Announcement Text 0', 'Announcement Description 0', 'ffffff', true, 0, false, true, 'foo', false, false, false], false, true, true, true], // submit, bad expiry
[0, ['add', 0, 'Announcement Text 0', 'Announcement Description 0', 'ffffff', true, 0, false, true, '', false, false, false], true, false, true, null], // preview
[0, ['add', 0, 'Announcement Text 0', 'Announcement Description 0', 'ffffff', true, 0, false, true, '', false, false, false], true, false, false, null], // preview, bad form
[1, ['add', 1, 'Announcement Text 1', 'Announcement Description 1', 'ffffff', true, 0, false, true, '', false, false, false], true, false, true, null], // preview
[1, ['add', 1, 'Announcement Text 1', 'Announcement Description 1', 'ffffff', true, 0, false, true, '', false, false, false], true, false, false, null], // preview, bad form
[0, ['add', 0, 'Announcement Text 0', 'Announcement Description 0', 'ffffff', true, 0, [''], true, '', false, false, false], false, true, true, false], // submit
[1, ['add', 1, 'Announcement Text 1', 'Announcement Description 1', 'ffffff', true, 0, [''], true, '', false, false, false], false, true, true, false], // submit
[0, ['add', 0, 'Announcement Text 0', 'Announcement Description 0', 'ffffff', true, 0, [''], true, '', false, false, false], false, true, false, true], // submit, bad form
[0, ['add', 0, '', 'Announcement Description 0', 'ffffff', true, 0, [''], true, '', false, false, false], false, true, true, true], // submit, bad text
[0, ['add', 0, 'Announcement Text 0', 'Announcement Description 0', 'ffffff', true, 0, [''], true, 'foo', false, false, false], false, true, true, true], // submit, bad expiry
[0, ['add', 0, 'Announcement Text 0', 'Announcement Description 0', 'ffffff', true, 0, [''], true, '', false, false, false], true, false, true, null], // preview
[0, ['add', 0, 'Announcement Text 0', 'Announcement Description 0', 'ffffff', true, 0, [''], true, '', false, false, false], true, false, false, null], // preview, bad form
[1, ['add', 1, 'Announcement Text 1', 'Announcement Description 1', 'ffffff', true, 0, [''], true, '', false, false, false], true, false, true, null], // preview
[1, ['add', 1, 'Announcement Text 1', 'Announcement Description 1', 'ffffff', true, 0, [''], true, '', false, false, false], true, false, false, null], // preview, bad form
];
}

Expand Down Expand Up @@ -397,7 +397,7 @@ public function test_action_add_submit($id, $form, $preview, $submit, $valid_for
['board_announcements_bgcolor', ''],
['board_announcements_enabled', true],
['board_announcements_users', 0],
['board_announcements_index_only', false],
['board_announcements_locations', ['']],
['board_announcements_dismiss', true],
['board_announcements_expiry', ''],
['disable_bbcode', false],
Expand Down Expand Up @@ -673,3 +673,11 @@ function display_custom_bbcodes()
function build_select()
{
}

/**
* Mock make_forum_select()
* Note: use the same namespace as the acp_controller
*/
function make_forum_select()
{
}
7 changes: 7 additions & 0 deletions tests/event/listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ public function test_display_board_announcements($user_id, $page, $enabled, $exp
->method('assign_block_vars')
->withConsecutive(...$expected);

$this->request->expects(self::atMost(2))
->method('variable')
->willReturnMap([
['f', 0, false, \phpbb\request\request_interface::REQUEST, 0],
['_ba_1', '', false, \phpbb\request\request_interface::COOKIE, ''],
]);

$dispatcher = new \phpbb\event\dispatcher();
$dispatcher->addListener('core.page_header_after', [$this->listener, 'display_board_announcements']);
$dispatcher->trigger_event('core.page_header_after');
Expand Down
12 changes: 6 additions & 6 deletions tests/fixtures/board_announcements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<column>announcement_description</column>
<column>announcement_bgcolor</column>
<column>announcement_enabled</column>
<column>announcement_indexonly</column>
<column>announcement_locations</column>
<column>announcement_dismissable</column>
<column>announcement_users</column>
<column>announcement_timestamp</column>
Expand All @@ -24,7 +24,7 @@
<value>ANNOUNCEMENT 1</value>
<value></value>
<value>1</value>
<value>1</value>
<value>["index"]</value>
<value>1</value>
<value>0</value>
<value>1586466410</value>
Expand All @@ -43,7 +43,7 @@
<value>ANNOUNCEMENT 2</value>
<value>ffffff</value>
<value>1</value>
<value>0</value>
<value></value>
<value>1</value>
<value>1</value>
<value>1586466510</value>
Expand All @@ -62,7 +62,7 @@
<value>ANNOUNCEMENT 3</value>
<value>000000</value>
<value>1</value>
<value>0</value>
<value></value>
<value>1</value>
<value>2</value>
<value>1586466610</value>
Expand All @@ -81,7 +81,7 @@
<value>ANNOUNCEMENT 4</value>
<value></value>
<value>1</value>
<value>0</value>
<value></value>
<value>0</value>
<value>0</value>
<value>1586466710</value>
Expand All @@ -100,7 +100,7 @@
<value>ANNOUNCEMENT 5</value>
<value></value>
<value>0</value>
<value>0</value>
<value>[]</value>
<value>0</value>
<value>0</value>
<value>1586466810</value>
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/announcement_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public function test_set_acp_settings()

// Test that our settings fields are found
$this->assertContainsLang('BOARD_ANNOUNCEMENTS_ENABLE', $crawler->text());
$this->assertContainsLang('BOARD_ANNOUNCEMENTS_INDEX_ONLY', $crawler->text());
$this->assertContainsLang('BOARD_ANNOUNCEMENTS_DISMISS', $crawler->text());
$this->assertContainsLang('BOARD_ANNOUNCEMENTS_USERS', $crawler->text());
$this->assertContainsLang('BOARD_ANNOUNCEMENTS_LOCATIONS', $crawler->text());
$this->assertContainsLang('BOARD_ANNOUNCEMENTS_DESC', $crawler->text());
$this->assertContainsLang('BOARD_ANNOUNCEMENTS_EXPIRY', $crawler->text());
$this->assertContainsLang('BOARD_ANNOUNCEMENTS_BGCOLOR', $crawler->text());
Expand All @@ -66,9 +66,9 @@ public function test_set_acp_settings()
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$values = [
'board_announcements_enabled' => true,
'board_announcements_index_only' => true,
'board_announcements_users' => 0,
'board_announcements_dismiss' => true,
'board_announcements_locations' => ["index"],
'board_announcements_bgcolor' => 'ff0000',
'board_announcements_description' => 'Test announcement',
'board_announcements_text' => 'This is a board announcement test.',
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager_get_expired_announcements_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function data_get_expired_announcements()
'announcement_description' => 'ANNOUNCEMENT 4',
'announcement_bgcolor' => '',
'announcement_enabled' => 1,
'announcement_indexonly' => 0,
'announcement_locations' => '',
'announcement_dismissable' => 0,
'announcement_users' => \phpbb\boardannouncements\ext::ALL,
'announcement_timestamp' => 1586466710,
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager_save_announcement_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function data_save_announcement()
'announcement_description' => 'ANNOUNCEMENT 6',
'announcement_bgcolor' => '',
'announcement_enabled' => 1,
'announcement_indexonly' => 1,
'announcement_locations' => json_encode([1,2,3]),
'announcement_dismissable' => 1,
'announcement_users' => 0,
'announcement_timestamp' => time(),
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager_update_announcement_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function data_update_announcement()
'announcement_description' => 'ANNOUNCEMENT 1 Updated',
'announcement_bgcolor' => 'cccccc',
'announcement_enabled' => 0,
'announcement_indexonly' => 0,
'announcement_locations' => json_encode(''),
'announcement_dismissable' => 0,
'announcement_users' => 1,
'announcement_timestamp' => time(),
Expand Down

0 comments on commit 655c5a4

Please sign in to comment.