Skip to content

Commit

Permalink
rename class and file according to spec. and additional linting (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
semteacher authored and ibernhardf committed Jan 16, 2025
1 parent fa2ba51 commit b47ddb8
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions tests/base_tests.php → tests/base_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
use local_wunderbyte_table\filters\types\standardfilter;
use moodle_exception;

defined('MOODLE_INTERNAL') || die();
global $CFG;

/**
* Test base functionality of wunderbyte_table
*
Expand All @@ -46,7 +43,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
*/
final class base_tests extends advanced_testcase {
final class base_test extends advanced_testcase {
/**
* Tests set up.
*/
Expand Down Expand Up @@ -78,23 +75,23 @@ public function test_query_db_cached(): void {
$nrofrows = $this->get_rowscount_for_table($table);

// Now we get back exactly 10.
$this->assertEquals($nrofrows, 10);
$this->assertEquals(10, $nrofrows);

// Now we create another three courses.
$this->create_test_courses(3, ['fullname' => 'filtercourse']);

$nrofrows = $this->get_rowscount_for_table($table);

// Because of caching kicking in, we still get 10 items.
$this->assertEquals($nrofrows, 10);
$this->assertEquals(10, $nrofrows);

// Now we purge the cache.
cache_helper::purge_by_event('changesinwunderbytetable');

$nrofrows = $this->get_rowscount_for_table($table);

// After purging, we expect 13.
$this->assertEquals($nrofrows, 13);
$this->assertEquals(13, $nrofrows);

// Now we want to test pagination.
$this->create_test_courses(30);
Expand All @@ -104,12 +101,12 @@ public function test_query_db_cached(): void {

$nrofrows = $this->get_rowscount_for_table($table);

$this->assertEquals($nrofrows, 20);
$this->assertEquals(20, $nrofrows);

// Now we fetch the third page. With 43 coures, we expect only three rows now.
$nrofrows = $this->get_rowscount_for_table($table, 2);

$this->assertEquals($nrofrows, 3);
$this->assertEquals(3, $nrofrows);

// Now we fetch the third page. With 43 coures, we expect only three rows now.
$nrofrows = $this->get_rowscount_for_table(
Expand All @@ -123,9 +120,7 @@ public function test_query_db_cached(): void {
'{"fullname":["filtercourse"]}'
);

$this->assertEquals($nrofrows, 3);

// throw new moodle_exception('x', 'x', '', json_encode($table->rawdata));
$this->assertEquals(3, $nrofrows);
}

/**
Expand Down Expand Up @@ -173,6 +168,7 @@ public function create_demo2_table() {
* Create a defined number of testcourses.
*
* @param int $coursestocreate
* @param array $options
* @return array
*
*/
Expand Down

0 comments on commit b47ddb8

Please sign in to comment.