ILIAS  release_8 Revision v8.24
ForumNotificationCacheTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22
27class ForumNotificationCacheTest extends TestCase
28{
30 {
31 $this->expectException(InvalidArgumentException::class);
32
33 $cache = new ilForumNotificationCache();
34 $cache->fetch('item');
35 }
36
37 public function testCacheItemResultsInCacheHit(): void
38 {
39 $cache = new ilForumNotificationCache();
40 $cache->store('item', 'ilias');
41
42 $this->assertTrue($cache->exists('item'));
43 $this->assertSame('ilias', $cache->fetch('item'));
44 }
45
46 public function nonScalarValuesProvider(): array
47 {
48 return [
49 'Array Type' => [[4]],
50 'Object Type' => [new stdClass()],
51 'Ressource Type' => [fopen('php://temp', 'rb')]
52 ];
53 }
54
60 {
61 $this->expectException(InvalidArgumentException::class);
62
63 $cache = new ilForumNotificationCache();
64 $key = $cache->createKeyByValues([$nonScalarValue, $nonScalarValue]);
65 }
66
67 public function scalarValuesAndNullProvider(): array
68 {
69 return [
70 'Float Type' => [4.0],
71 'String Type' => ['4'],
72 'Boolean Type' => [false],
73 'Integer Type' => [4],
74 'Null Type' => [null],
75 ];
76 }
77
82 public function testCacheKeyCouldBeGeneratedByArray($scalarValue): void
83 {
84 $cache = new ilForumNotificationCache();
85 $key = $cache->createKeyByValues([$scalarValue, $scalarValue]);
86
87 $this->assertNotEmpty($key);
88 $this->assertSame(32, strlen($key));
89 }
90}
Class ForumNotificationCacheTest.
testExceptionIsRaisedWhenKeyShouldBeBuiltWithNonScalarValues($nonScalarValue)
Class ilForumNotificationCache.
string $key
Consumer key/client ID value.
Definition: System.php:193