ILIAS  release_8 Revision v8.24
ilServicesGlobalCacheTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21use PHPUnit\Framework\TestCase;
22
23class ilServicesGlobalCacheTest extends TestCase
24{
29 {
31 $settings->setActive(true);
32 $settings->setActivatedComponents(['test']);
34 return $settings;
35 }
36
37 public function testService(): void
38 {
39 $settings = $this->getSettings();
41
42 $cache = ilGlobalCache::getInstance('test');
43 $this->assertTrue($cache->isActive());
44 $this->assertEquals('test', $cache->getComponent());
45 $this->assertEquals(0, $cache->getServiceType());
46
47 $cache = ilGlobalCache::getInstance('test_2');
48 $this->assertFalse($cache->isActive());
49 $this->assertEquals('test_2', $cache->getComponent());
50 $this->assertEquals(0, $cache->getServiceType());
51 }
52
53 public function testValues(): void
54 {
55 $settings = $this->getSettings();
57 $cache = ilGlobalCache::getInstance('test');
58
59 $this->assertFalse($cache->isValid('test_key'));
60 $cache->set('test_key', 'value');
61 $this->assertTrue($cache->isValid('test_key'));
62 $this->assertEquals('value', $cache->get('test_key'));
63 }
64}
Class ilGlobalCacheSettings.
static setup(ilGlobalCacheSettings $ilGlobalCacheSettings)
static getInstance(?string $component)
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200