ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ReadableTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Test\Access\test;
22 
26 use ilAccessHandler;
27 
28 class ReadableTest extends TestCase
29 {
30  public function testConstruct(): void
31  {
32  $access = $this->getMockBuilder(ilAccessHandler::class)->disableOriginalConstructor()->getMock();
33 
34  $this->assertInstanceOf(Readable::class, new Readable($access));
35  }
36 
37  public function testReferences(): void
38  {
39  $access = $this->getMockBuilder(ilAccessHandler::class)->disableOriginalConstructor()->getMock();
40  $access->method('checkAccess')->with('read', '', 123)->willReturn(true);
41 
42  $this->assertTrue((new Readable($access))->references([123]));
43  }
44 
45  public function testObjectId(): void
46  {
47  $access = $this->getMockBuilder(ilAccessHandler::class)->disableOriginalConstructor()->getMock();
48 
49  $access->method('checkAccess')->with('read', '', 456)->willReturn(true);
50 
51  $references_of = fn(int $object_id) => 123 !== $object_id ?: [456];
52 
53  $this->assertTrue((new Readable($access, $references_of))->objectId(123));
54  }
55 }