Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ewallah/moodle-report_payments
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebleu committed Nov 23, 2023
2 parents 225db78 + 99284a0 commit 9befaf6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'master']
php: ['8.1']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE']
database: ['mariadb', 'pgsql']
include:
- php: '7.4'
moodle-branch: 'MOODLE_401_STABLE'
database: 'pgsql'
- php: '8.2'
moodle-branch: 'MOODLE_403_STABLE'
moodle-branch: 'main'
database: 'pgsql'

steps:
Expand Down
8 changes: 7 additions & 1 deletion classes/reportbuilder/local/entities/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ protected function get_all_columns(): array {
->set_type(column::TYPE_TEXT)
->add_field("{$tablealias}.amount")
->set_is_sortable(true)
->add_attributes(['class' => 'text-right']);
->add_callback(function(?string $value): string {
if ($value === '') {
return '0';
}
$floa = floatval($value);
return number_format($floa, 2);
});

// Currency column.
$columns[] = (new column('currency', new lang_string('currency'), $name))
Expand Down
6 changes: 3 additions & 3 deletions tests/event/event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function setUp(): void {
* simply create the event and trigger it.
* @covers \report_payments\event\report_viewed
*/
public function test_report_viewed() {
public function test_report_viewed(): void {
$course = $this->getDataGenerator()->create_course();
$user = $this->getDataGenerator()->create_user();

Expand Down Expand Up @@ -111,7 +111,7 @@ public function test_report_viewed() {
* Tests the report navigation as an admin.
* @coversNothing
*/
public function test_report_payments_navigation() {
public function test_report_payments_navigation(): void {
global $CFG, $PAGE, $USER;
require_once($CFG->dirroot . '/report/payments/lib.php');
$course = $this->getDataGenerator()->create_course();
Expand All @@ -138,7 +138,7 @@ public function test_report_payments_navigation() {
* Tests the report page type list.
* @coversNothing
*/
public function test_report_payments_page_type() {
public function test_report_payments_page_type(): void {
global $CFG, $PAGE;
$course = $this->getDataGenerator()->create_course();
$PAGE->set_url('/course/view.php', ['id' => $course->id]);
Expand Down
2 changes: 1 addition & 1 deletion tests/privacy/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class privacy_test extends provider_testcase {
* Test returning metadata.
* @covers \report_payments\privacy\provider
*/
public function test_get_metadata() {
public function test_get_metadata(): void {
$str = 'report_payments';
$this->resetAfterTest(true);
$collection = new \core_privacy\local\metadata\collection($str);
Expand Down
8 changes: 4 additions & 4 deletions tests/reportbuilder/reports_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function setUp(): void {
* @covers \report_payments\reportbuilder\local\systemreports\payments_global
* @covers \report_payments\reportbuilder\local\entities\payment
*/
public function test_global() {
public function test_global(): void {
$context = \context_system::instance();
$report = system_report_factory::create(payments_global::class, $context);
$this->assertEquals($report->get_name(), 'Payments');
Expand All @@ -100,7 +100,7 @@ public function test_global() {
* @covers \report_payments\reportbuilder\local\systemreports\payments_course
* @covers \report_payments\reportbuilder\local\entities\payment
*/
public function test_course() {
public function test_course(): void {
$report = system_report_factory::create(payments_course::class, \context_course::instance($this->course->id));
$this->assertEquals($report->get_name(), 'Payments');
}
Expand All @@ -111,7 +111,7 @@ public function test_course() {
* @covers \report_payments\reportbuilder\local\systemreports\payments_user
* @covers \report_payments\reportbuilder\local\entities\payment
*/
public function test_user() {
public function test_user(): void {
$report = system_report_factory::create(payments_user::class, \context_user::instance($this->userid));
$this->assertEquals($report->get_name(), 'Payments');
}
Expand All @@ -122,7 +122,7 @@ public function test_user() {
* @covers \report_payments\reportbuilder\datasource\payments
* @covers \report_payments\reportbuilder\local\entities\payment
*/
public function test_datasource() {
public function test_datasource(): void {
$gen = self::getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $gen->create_report(['name' => 'Pay', 'source' => payments::class, 'default' => true]);
$this->assertEquals($report->get_formatted_name(), 'Pay');
Expand Down

0 comments on commit 9befaf6

Please sign in to comment.