@@ -59,7 +59,7 @@ public function setUp(): void {
59
59
* Test wb base functionality via webservice external class.
60
60
*
61
61
* @covers \wunderbyte_table::query_db_cached
62
- * @runInSeparateProcess
62
+ * // @runInSeparateProcess
63
63
*
64
64
* @throws \coding_exception
65
65
* @throws \dml_exception
@@ -75,23 +75,23 @@ public function test_query_db_cached(): void {
75
75
$ this ->setUser ($ user );
76
76
77
77
$ table = $ this ->create_demo2_table ();
78
- $ nrofrows = $ this ->return_rows_for_table ($ table );
78
+ $ nrofrows = $ this ->get_rowscount_for_table ($ table );
79
79
80
80
// Now we get back exactly 10.
81
81
$ this ->assertEquals ($ nrofrows , 10 );
82
82
83
83
// Now we create another three courses.
84
84
$ this ->create_test_courses (3 , ['fullname ' => 'filtercourse ' ]);
85
85
86
- $ nrofrows = $ this ->return_rows_for_table ($ table );
86
+ $ nrofrows = $ this ->get_rowscount_for_table ($ table );
87
87
88
88
// Because of caching kicking in, we still get 10 items.
89
89
$ this ->assertEquals ($ nrofrows , 10 );
90
90
91
91
// Now we purge the cache.
92
92
cache_helper::purge_by_event ('changesinwunderbytetable ' );
93
93
94
- $ nrofrows = $ this ->return_rows_for_table ($ table );
94
+ $ nrofrows = $ this ->get_rowscount_for_table ($ table );
95
95
96
96
// After purging, we expect 13.
97
97
$ this ->assertEquals ($ nrofrows , 13 );
@@ -102,17 +102,17 @@ public function test_query_db_cached(): void {
102
102
// Now we purge the cache.
103
103
cache_helper::purge_by_event ('changesinwunderbytetable ' );
104
104
105
- $ nrofrows = $ this ->return_rows_for_table ($ table );
105
+ $ nrofrows = $ this ->get_rowscount_for_table ($ table );
106
106
107
107
$ this ->assertEquals ($ nrofrows , 20 );
108
108
109
109
// Now we fetch the third page. With 43 coures, we expect only three rows now.
110
- $ nrofrows = $ this ->return_rows_for_table ($ table , 2 );
110
+ $ nrofrows = $ this ->get_rowscount_for_table ($ table , 2 );
111
111
112
112
$ this ->assertEquals ($ nrofrows , 3 );
113
113
114
114
// Now we fetch the third page. With 43 coures, we expect only three rows now.
115
- $ nrofrows = $ this ->return_rows_for_table (
115
+ $ nrofrows = $ this ->get_rowscount_for_table (
116
116
$ table ,
117
117
0 ,
118
118
null ,
@@ -205,7 +205,7 @@ public function create_test_courses(int $coursestocreate = 1, $options = []): ar
205
205
* @return int
206
206
*
207
207
*/
208
- public function return_rows_for_table (
208
+ public function get_rowscount_for_table (
209
209
wunderbyte_table $ table ,
210
210
$ page = null ,
211
211
$ tsort = null ,
@@ -217,6 +217,49 @@ public function return_rows_for_table(
217
217
$ searchtext = null
218
218
): int {
219
219
220
+ $ rows = $ this ->get_rows_for_table (
221
+ $ table ,
222
+ $ page ,
223
+ $ tsort ,
224
+ $ thide ,
225
+ $ tshow ,
226
+ $ tdir ,
227
+ $ treset ,
228
+ $ filterobjects ,
229
+ $ searchtext
230
+ );
231
+
232
+ return count ($ rows );
233
+ }
234
+
235
+ /**
236
+ * Returns the actual rows for a table. This only retrieves the rows for the current page.
237
+ *
238
+ * @param wunderbyte_table $table
239
+ * @param int $page
240
+ * @param string $tsort
241
+ * @param string $thide
242
+ * @param string $tshow
243
+ * @param int $tdir
244
+ * @param int $treset
245
+ * @param string $filterobjects
246
+ * @param string $searchtext
247
+ *
248
+ * @return array
249
+ *
250
+ */
251
+ public function get_rows_for_table (
252
+ wunderbyte_table $ table ,
253
+ $ page = null ,
254
+ $ tsort = null ,
255
+ $ thide = null ,
256
+ $ tshow = null ,
257
+ $ tdir = null ,
258
+ $ treset = null ,
259
+ $ filterobjects = null ,
260
+ $ searchtext = null
261
+ ): array {
262
+
220
263
$ encodedtable = $ table ->return_encoded_table ();
221
264
$ result = load_data::execute (
222
265
$ encodedtable ,
@@ -235,7 +278,6 @@ public function return_rows_for_table(
235
278
throw new moodle_exception ('test ' , 'test ' , '' , json_encode ($ jsonobject ));
236
279
}
237
280
$ rows = $ jsonobject ->table ->rows ?? 0 ;
238
-
239
- return count ($ rows );
281
+ return $ rows ;
240
282
}
241
283
}
0 commit comments