Skip to content

Commit 7f27b65

Browse files
committed
Update tests
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 355c293 commit 7f27b65

3 files changed

Lines changed: 66 additions & 19 deletions

File tree

.github/workflows/tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ jobs:
127127
db: "mysql:5.7"
128128
- php: '8.3'
129129
db: "mysql:5.7"
130+
- php: '8.4'
131+
db: "mysql:5.7"
130132

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

@@ -270,6 +272,8 @@ jobs:
270272
db: "postgres:14"
271273
- php: '8.3'
272274
db: "postgres:14"
275+
- php: '8.4'
276+
db: "postgres:14"
273277

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

tests/operators/page_operator_get_pages_test.php

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ class page_operator_get_pages_test extends page_operator_base
1919
*/
2020
public function get_pages_test_data()
2121
{
22-
return array(
23-
array(
24-
array(
25-
array(
22+
return [
23+
[
24+
0,
25+
0,
26+
[
27+
[
2628
'page_id' => 1,
2729
'page_order' => 1,
2830
'page_description' => 'description_1',
@@ -34,8 +36,8 @@ public function get_pages_test_data()
3436
'page_display_to_guests' => 1,
3537
'page_title_switch' => 0,
3638
'page_icon_font' => 'foo-1',
37-
),
38-
array(
39+
],
40+
[
3941
'page_id' => 2,
4042
'page_order' => 2,
4143
'page_description' => 'description_2',
@@ -47,8 +49,8 @@ public function get_pages_test_data()
4749
'page_display_to_guests' => 1,
4850
'page_title_switch' => 0,
4951
'page_icon_font' => '',
50-
),
51-
array(
52+
],
53+
[
5254
'page_id' => 3,
5355
'page_order' => 3,
5456
'page_description' => 'description_3',
@@ -60,8 +62,8 @@ public function get_pages_test_data()
6062
'page_display_to_guests' => 0,
6163
'page_title_switch' => 0,
6264
'page_icon_font' => '',
63-
),
64-
array(
65+
],
66+
[
6567
'page_id' => 4,
6668
'page_order' => 4,
6769
'page_description' => 'description_4',
@@ -73,27 +75,46 @@ public function get_pages_test_data()
7375
'page_display_to_guests' => 0,
7476
'page_title_switch' => 0,
7577
'page_icon_font' => '',
76-
),
77-
),
78-
),
79-
);
78+
],
79+
],
80+
],
81+
[
82+
2,
83+
1,
84+
[
85+
[
86+
'page_id' => 3,
87+
'page_order' => 3,
88+
'page_description' => 'description_3',
89+
'page_description_display' => 0,
90+
'page_route' => 'page_3',
91+
'page_title' => 'title_3',
92+
'page_content' => 'message_3',
93+
'page_display' => 1,
94+
'page_display_to_guests' => 0,
95+
'page_title_switch' => 0,
96+
'page_icon_font' => '',
97+
],
98+
],
99+
],
100+
];
80101
}
81102

82103
/**
83104
* Test getting pages from the database
84105
*
85106
* @dataProvider get_pages_test_data
86107
*/
87-
public function test_get_pages($expected)
108+
public function test_get_pages($start, $limit, $expected)
88109
{
89-
// Setup the operator class
110+
// Set up the operator class
90111
$operator = $this->get_page_operator();
91112

92113
// Grab the page data as an array of entities
93-
$entities = $operator->get_pages();
114+
$entities = $operator->get_pages($limit, $start);
94115

95116
// Map the fields to the getters
96-
$map = array(
117+
$map = [
97118
'page_id' => 'get_id',
98119
'page_order' => 'get_order',
99120
'page_description' => 'get_description',
@@ -105,7 +126,7 @@ public function test_get_pages($expected)
105126
'page_display_to_guests' => 'get_page_display_to_guests',
106127
'page_title_switch' => 'get_page_title_switch',
107128
'page_icon_font' => 'get_icon_font',
108-
);
129+
];
109130

110131
// Test through each entity in the array of entities
111132
$i = 0;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
*
4+
* Pages extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2024 phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
namespace phpbb\pages\tests\operators;
12+
13+
class page_operator_get_total_pages_test extends page_operator_base
14+
{
15+
public function test_get_total_pages()
16+
{
17+
// Set up the operator class
18+
$operator = $this->get_page_operator();
19+
20+
self::assertEquals(4, $operator->get_total_pages());
21+
}
22+
}

0 commit comments

Comments
 (0)