Merge branch 'MDL-73974-402' of https://github.com/junpataleta/moodle into MOODLE_402...
[moodle.git] / cache / tests / cache_helper_test.php
blobfb8dc3b1f7e70cbea25ea4e341ceef1a7f12d89b
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.
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/>.
17 namespace core_cache;
19 /**
20 * PHPunit tests for the cache_helper class.
22 * @package core
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
26 * @coversDefaultClass \cache_helper
28 class cache_helper_test extends \advanced_testcase {
29 /**
30 * Test the result_found method.
32 * @param mixed $value
33 * @param bool $expected
34 * @dataProvider result_found_provider
35 * @covers ::result_found
37 public function test_result_found($value, bool $expected): void {
38 $this->assertEquals($expected, \cache_helper::result_found($value));
41 /**
42 * Data provider for result_found tests.
44 * @return array
46 public function result_found_provider(): array {
47 return [
48 // Only false values are considered as not found.
49 [false, false],
51 // The rest are considered valid values.
52 [null, true],
53 [0, true],
54 ['', true],
55 [[], true],
56 [new \stdClass(), true],
57 [true, true],
58 [1, true],
59 ['a', true],
60 [[1], true],
61 [new \stdClass(), true],