Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 27... Línea 27...
27
 * @package     core_reportbuilder
27
 * @package     core_reportbuilder
28
 * @covers      \core_reportbuilder\local\helpers\format
28
 * @covers      \core_reportbuilder\local\helpers\format
29
 * @copyright   2021 Paul Holden <paulh@moodle.com>
29
 * @copyright   2021 Paul Holden <paulh@moodle.com>
30
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 */
31
 */
32
class format_test extends advanced_testcase {
32
final class format_test extends advanced_testcase {
Línea 33... Línea 33...
33
 
33
 
34
    /**
34
    /**
35
     * Test userdate method
35
     * Test userdate method
36
     */
36
     */
Línea 40... Línea 40...
40
        $userdate = format::userdate($now, new stdClass());
40
        $userdate = format::userdate($now, new stdClass());
41
        $this->assertEquals(userdate($now), $userdate);
41
        $this->assertEquals(userdate($now), $userdate);
42
    }
42
    }
Línea 43... Línea 43...
43
 
43
 
-
 
44
    /**
-
 
45
     * Data provider for {@see test_format_time}
-
 
46
     *
-
 
47
     * @return array[]
-
 
48
     */
-
 
49
    public static function format_time_provider(): array {
-
 
50
        return [
-
 
51
            [null, 0, ''],
-
 
52
            [0, 0, '0 secs'],
-
 
53
            [2.456, 1, '2.5 secs'],
-
 
54
            [3.2, null, '3 secs'],
-
 
55
        ];
-
 
56
    }
-
 
57
 
-
 
58
    /**
-
 
59
     * Test format time
-
 
60
     *
-
 
61
     * @param float|null $value
-
 
62
     * @param int|null $precision
-
 
63
     * @param string $expected
-
 
64
     *
-
 
65
     * @dataProvider format_time_provider
-
 
66
     */
-
 
67
    public function test_format_time(?float $value, ?int $precision, string $expected): void {
-
 
68
        $this->assertEquals($expected, format::format_time($value, (object) [], $precision));
-
 
69
    }
-
 
70
 
44
    /**
71
    /**
45
     * Data provider for {@see test_boolean_as_text}
72
     * Data provider for {@see test_boolean_as_text}
46
     *
73
     *
47
     * @return array
74
     * @return array[]
48
     */
75
     */
49
    public function boolean_as_text_provider(): array {
76
    public static function boolean_as_text_provider(): array {
50
        return [
77
        return [
51
            [false, get_string('no')],
78
            [false, get_string('no')],
52
            [true, get_string('yes')],
79
            [true, get_string('yes')],
53
        ];
80
        ];