ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ForumNotificationCacheTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
25 {
27  {
28  $this->expectException(InvalidArgumentException::class);
29 
30  $cache = new ilForumNotificationCache();
31  $cache->fetch('item');
32  }
33 
34  public function testCacheItemResultsInCacheHit(): void
35  {
36  $cache = new ilForumNotificationCache();
37  $cache->store('item', 'ilias');
38 
39  $this->assertTrue($cache->exists('item'));
40  $this->assertSame('ilias', $cache->fetch('item'));
41  }
42 
43  public static function nonScalarValuesProvider(): array
44  {
45  return [
46  'Array Type' => [[4]],
47  'Object Type' => [new stdClass()],
48  'Ressource Type' => [fopen('php://temp', 'rb')]
49  ];
50  }
51 
52  #[DataProvider('nonScalarValuesProvider')]
53  public function testExceptionIsRaisedWhenKeyShouldBeBuiltWithNonScalarValues(mixed $nonScalarValue): void
54  {
55  $this->expectException(InvalidArgumentException::class);
56 
57  $cache = new ilForumNotificationCache();
58  $cache->createKeyByValues([$nonScalarValue, $nonScalarValue]);
59  }
60 
61  public static function scalarValuesAndNullProvider(): array
62  {
63  return [
64  'Float Type' => [4.0],
65  'String Type' => ['4'],
66  'Boolean Type' => [false],
67  'Integer Type' => [4],
68  'Null Type' => [null],
69  ];
70  }
71 
75  #[DataProvider('scalarValuesAndNullProvider')]
76  public function testCacheKeyCouldBeGeneratedByArray($scalarValue): void
77  {
78  $cache = new ilForumNotificationCache();
79  $key = $cache->createKeyByValues([$scalarValue, $scalarValue]);
80 
81  $this->assertNotEmpty($key);
82  $this->assertSame(32, strlen($key));
83  }
84 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class ilForumNotificationCache.
testExceptionIsRaisedWhenKeyShouldBeBuiltWithNonScalarValues(mixed $nonScalarValue)