Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 14... Línea 14...
14
// You should have received a copy of the GNU General Public License
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/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea 16...
16
 
16
 
Línea 17... Línea 17...
17
namespace cachestore_file;
17
namespace cachestore_file;
18
 
18
 
19
use cache_definition;
19
use core_cache\definition;
Línea 20... Línea 20...
20
use cache_store;
20
use core_cache\store;
Línea 21... Línea 21...
21
use cachestore_file;
21
use cachestore_file;
Línea 33... Línea 33...
33
 * @package    cachestore_file
33
 * @package    cachestore_file
34
 * @copyright  2013 Sam Hemelryk
34
 * @copyright  2013 Sam Hemelryk
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 * @covers \cachestore_file
36
 * @covers \cachestore_file
37
 */
37
 */
38
class store_test extends \cachestore_tests {
38
final class store_test extends \cachestore_tests {
39
    /**
39
    /**
40
     * Returns the file class name
40
     * Returns the file class name
41
     * @return string
41
     * @return string
42
     */
42
     */
43
    protected function get_class_name() {
43
    protected function get_class_name() {
44
        return 'cachestore_file';
44
        return 'cachestore_file';
45
    }
45
    }
Línea 46... Línea 46...
46
 
46
 
-
 
47
    /**
-
 
48
     * Provider for set/get tests with all combinations of serializer.
-
 
49
     *
-
 
50
     * @return array
-
 
51
     */
-
 
52
    public static function getset_serialization_test_provider(): array {
-
 
53
        $data = [
-
 
54
            [
-
 
55
                'PHP serializer',
-
 
56
                \cachestore_file::SERIALIZER_PHP,
-
 
57
            ],
-
 
58
        ];
-
 
59
        if (function_exists('igbinary_serialize')) {
-
 
60
            $data[] = [
-
 
61
                'Igbinary serializer',
-
 
62
                \cachestore_file::SERIALIZER_IGBINARY,
-
 
63
            ];
-
 
64
        }
-
 
65
 
-
 
66
        return $data;
-
 
67
    }
-
 
68
 
-
 
69
    /**
-
 
70
     * Test get and set function correctly with all combinations of serializer.
-
 
71
     *
-
 
72
     * @dataProvider getset_serialization_test_provider
-
 
73
     * @param string $name
-
 
74
     * @param string $serializer
-
 
75
     */
-
 
76
    public function test_getset_serialization(string $name, string $serializer): void {
-
 
77
        $definition = definition::load_adhoc(store::MODE_APPLICATION, 'cachestore_file', 'phpunit_test');
-
 
78
        $store = new \cachestore_file('Test', ['serializer' => $serializer]);
-
 
79
        $store->initialise($definition);
-
 
80
        $originalvalue = 'value12345';
-
 
81
        $store->set('key', $originalvalue);
-
 
82
        $unserializedvalue = $store->get('key');
-
 
83
        self::assertSame($originalvalue, $unserializedvalue, "Invalid serialisation/unserialisation for: {$name}");
-
 
84
    }
-
 
85
 
47
    /**
86
    /**
48
     * Testing cachestore_file::get with prescan enabled and with
87
     * Testing cachestore_file::get with prescan enabled and with
49
     * deleting the cache between the prescan and the call to get.
88
     * deleting the cache between the prescan and the call to get.
50
     *
89
     *
51
     * The deleting of cache simulates some other process purging
90
     * The deleting of cache simulates some other process purging
52
     * the cache.
91
     * the cache.
53
     */
92
     */
54
    public function test_cache_get_with_prescan_and_purge(): void {
93
    public function test_cache_get_with_prescan_and_purge(): void {
Línea 55... Línea 94...
55
        global $CFG;
94
        global $CFG;
56
 
95
 
Línea 57... Línea 96...
57
        $definition = cache_definition::load_adhoc(cache_store::MODE_REQUEST, 'cachestore_file', 'phpunit_test');
96
        $definition = definition::load_adhoc(store::MODE_REQUEST, 'cachestore_file', 'phpunit_test');
58
        $name = 'File test';
97
        $name = 'File test';
59
 
98
 
Línea 76... Línea 115...
76
 
115
 
77
    /**
116
    /**
78
     * Tests the get_last_read byte count.
117
     * Tests the get_last_read byte count.
79
     */
118
     */
80
    public function test_get_last_io_bytes(): void {
119
    public function test_get_last_io_bytes(): void {
81
        $definition = cache_definition::load_adhoc(cache_store::MODE_REQUEST, 'cachestore_file', 'phpunit_test');
120
        $definition = definition::load_adhoc(store::MODE_REQUEST, 'cachestore_file', 'phpunit_test');
82
        $store = new \cachestore_file('Test');
121
        $store = new \cachestore_file('Test');
Línea 83... Línea 122...
83
        $store->initialise($definition);
122
        $store->initialise($definition);
84
 
123