mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-70794 reportbuilder: management and further utility classes.
We define the base classes and APIs for reports, that can contain columns and filters instances themselves.
This commit is contained in:
parent
2a20238924
commit
93025be2e7
10 changed files with 1198 additions and 0 deletions
67
reportbuilder/tests/local/helpers/format_test.php
Normal file
67
reportbuilder/tests/local/helpers/format_test.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace core_reportbuilder\local\helpers;
|
||||
|
||||
use advanced_testcase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Unit tests for the format helper
|
||||
*
|
||||
* @package core_reportbuilder
|
||||
* @covers \core_reportbuilder\local\helpers\format
|
||||
* @copyright 2021 Paul Holden <paulh@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class format_testcase extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test userdate method
|
||||
*/
|
||||
public function test_userdate(): void {
|
||||
$now = time();
|
||||
|
||||
$userdate = format::userdate($now, new stdClass());
|
||||
$this->assertEquals(userdate($now), $userdate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for {@see test_boolean_as_text}
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function boolean_as_text_provider(): array {
|
||||
return [
|
||||
[false, get_string('no')],
|
||||
[true, get_string('yes')],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test boolean as text
|
||||
*
|
||||
* @param bool $value
|
||||
* @param string $expected
|
||||
*
|
||||
* @dataProvider boolean_as_text_provider
|
||||
*/
|
||||
public function test_boolean_as_text(bool $value, string $expected): void {
|
||||
$this->assertEquals($expected, format::boolean_as_text($value));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue