ILIAS  release_8 Revision v8.24
ClientIdReadObjectiveTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
23use ILIAS\Setup;
25use PHPUnit\Framework\TestCase;
26
27class ClientIdReadObjectiveTest extends TestCase
28{
29 public function setUp(): void
30 {
31 $this->o = new class () extends ClientIdReadObjective {
32 public function _getDataDirectoryPath()
33 {
34 return $this->getDataDirectoryPath();
35 }
36 };
37 }
38
39 public function testGetHash(): void
40 {
41 $this->assertIsString($this->o->getHash());
42 }
43
44 public function testGetLabel(): void
45 {
46 $this->assertIsString($this->o->getLabel());
47 }
48
49 public function testIsNotable(): void
50 {
51 $this->assertFalse($this->o->isNotable());
52 }
53
54 public function testGetPreconditions(): void
55 {
56 $env = $this->createMock(Setup\Environment::class);
57
58 $pre = $this->o->getPreconditions($env);
59 $this->assertEquals([], $pre);
60 }
61
62 public function testAchieve(): void
63 {
64 $env = $this->createMock(Setup\Environment::class);
65
66 $mock = $this->getMockBuilder(ClientIdReadObjective::class)
67 ->onlyMethods(["getDataDirectoryPath", "scanDirectory", "isDirectory"])
68 ->getMock();
69
70 $DATA_DIR = "/foo/bar/data";
71 $SOME_DIR = "clientid";
72 $SOME_FILE = "some_file";
73 $SCAN_RESULT = [".", "..", $SOME_DIR, $SOME_FILE];
74
75 $mock
76 ->expects($this->once())
77 ->method("getDataDirectoryPath")
78 ->willReturn($DATA_DIR);
79
80 $mock
81 ->expects($this->once())
82 ->method("scanDirectory")
83 ->with($DATA_DIR)
84 ->willReturn($SCAN_RESULT);
85
86 $mock
87 ->expects($this->exactly(2))
88 ->method("isDirectory")
89 ->withConsecutive([$DATA_DIR . "/" . $SOME_DIR], [$DATA_DIR . "/" . $SOME_FILE])
90 ->will($this->onConsecutiveCalls(true, false));
91
92 $env
93 ->expects($this->once())
94 ->method("withResource")
95 ->with(Setup\Environment::RESOURCE_CLIENT_ID, $SOME_DIR)
96 ->willReturn($env);
97
98 $res = $mock->achieve($env);
99 $this->assertSame($env, $res);
100 }
101
102 public function testGetDataDirectoryPath(): void
103 {
104 $base = dirname(__DIR__, 3);
105 $this->assertEquals($base . "/data", $this->o->_getDataDirectoryPath());
106 }
107}
Read the client id of the installation from the data directory.
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$base
Definition: index.php:4