Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
namespace core_cache;
18
 
19
/**
20
 * PHPunit tests for the cache_helper class.
21
 *
1441 ariadna 22
 * @package    core_cache
1 efrain 23
 * @category   cache
24
 * @copyright  2023 Andrew Lyons <andrew@nicols.co.uk>
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
1441 ariadna 26
 * @covers \core_cache\helper
1 efrain 27
 */
1441 ariadna 28
final class cache_helper_test extends \advanced_testcase {
1 efrain 29
    /**
30
     * Test the result_found method.
31
     *
32
     * @param mixed $value
33
     * @param bool $expected
34
     * @dataProvider result_found_provider
35
     */
36
    public function test_result_found($value, bool $expected): void {
1441 ariadna 37
        $this->assertEquals($expected, helper::result_found($value));
1 efrain 38
    }
39
 
40
    /**
41
     * Data provider for result_found tests.
42
     *
43
     * @return array
44
     */
1441 ariadna 45
    public static function result_found_provider(): array {
1 efrain 46
        return [
47
            // Only false values are considered as not found.
48
            [false, false],
49
 
50
            // The rest are considered valid values.
51
            [null, true],
52
            [0, true],
53
            ['', true],
54
            [[], true],
55
            [new \stdClass(), true],
56
            [true, true],
57
            [1, true],
58
            ['a', true],
59
            [[1], true],
60
            [new \stdClass(), true],
61
        ];
62
    }
63
}