ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Tests\Setup\Objective\ClientIdReadObjectiveTest Class Reference
+ Inheritance diagram for ILIAS\Tests\Setup\Objective\ClientIdReadObjectiveTest:
+ Collaboration diagram for ILIAS\Tests\Setup\Objective\ClientIdReadObjectiveTest:

Public Member Functions

 setUp ()
 
 testGetHash ()
 
 testGetLabel ()
 
 testIsNotable ()
 
 testGetPreconditions ()
 
 testAchieve ()
 
 testGetDataDirectoryPath ()
 

Protected Attributes

ClientIdReadObjective $o
 

Detailed Description

Definition at line 27 of file ClientIdReadObjectiveTest.php.

Member Function Documentation

◆ setUp()

ILIAS\Tests\Setup\Objective\ClientIdReadObjectiveTest::setUp ( )

Definition at line 31 of file ClientIdReadObjectiveTest.php.

31 : void
32 {
33 $this->o = new class () extends ClientIdReadObjective {
34 public function _getDataDirectoryPath()
35 {
36 return $this->getDataDirectoryPath();
37 }
38 };
39 }

◆ testAchieve()

ILIAS\Tests\Setup\Objective\ClientIdReadObjectiveTest::testAchieve ( )

Definition at line 64 of file ClientIdReadObjectiveTest.php.

64 : void
65 {
66 $env = $this->createMock(Setup\Environment::class);
67
68 $mock = $this->getMockBuilder(ClientIdReadObjective::class)
69 ->onlyMethods(["getDataDirectoryPath", "scanDirectory", "isDirectory"])
70 ->getMock();
71
72 $DATA_DIR = "/foo/bar/data";
73 $SOME_DIR = "clientid";
74 $SOME_FILE = "some_file";
75 $SCAN_RESULT = [".", "..", $SOME_DIR, $SOME_FILE];
76
77 $mock
78 ->expects($this->once())
79 ->method("getDataDirectoryPath")
80 ->willReturn($DATA_DIR);
81
82 $mock
83 ->expects($this->once())
84 ->method("scanDirectory")
85 ->with($DATA_DIR)
86 ->willReturn($SCAN_RESULT);
87
88 $consecutive = [
89 [$DATA_DIR . "/" . $SOME_DIR, true],
90 [$DATA_DIR . "/" . $SOME_FILE, false]
91 ];
92 $mock
93 ->expects($this->exactly(2))
94 ->method("isDirectory")
95 ->willReturnCallback(
96 function ($path) use (&$consecutive): bool {
97 list($expected, $return) = array_shift($consecutive);
98 $this->assertEquals($expected, $path);
99 return $return;
100 }
101 );
102
103 $env
104 ->expects($this->once())
105 ->method("withResource")
106 ->with(Setup\Environment::RESOURCE_CLIENT_ID, $SOME_DIR)
107 ->willReturn($env);
108
109 $res = $mock->achieve($env);
110 $this->assertSame($env, $res);
111 }
$path
Definition: ltiservices.php:30
$res
Definition: ltiservices.php:69

References $path, $res, and ILIAS\Setup\Environment\RESOURCE_CLIENT_ID.

◆ testGetDataDirectoryPath()

ILIAS\Tests\Setup\Objective\ClientIdReadObjectiveTest::testGetDataDirectoryPath ( )

Definition at line 113 of file ClientIdReadObjectiveTest.php.

113 : void
114 {
115 $base = dirname(__DIR__, 5);
116 $this->assertEquals($base . "/public/data", $this->o->_getDataDirectoryPath());
117 }

◆ testGetHash()

ILIAS\Tests\Setup\Objective\ClientIdReadObjectiveTest::testGetHash ( )

Definition at line 41 of file ClientIdReadObjectiveTest.php.

41 : void
42 {
43 $this->assertIsString($this->o->getHash());
44 }

◆ testGetLabel()

ILIAS\Tests\Setup\Objective\ClientIdReadObjectiveTest::testGetLabel ( )

Definition at line 46 of file ClientIdReadObjectiveTest.php.

46 : void
47 {
48 $this->assertIsString($this->o->getLabel());
49 }

◆ testGetPreconditions()

ILIAS\Tests\Setup\Objective\ClientIdReadObjectiveTest::testGetPreconditions ( )

Definition at line 56 of file ClientIdReadObjectiveTest.php.

56 : void
57 {
58 $env = $this->createMock(Setup\Environment::class);
59
60 $pre = $this->o->getPreconditions($env);
61 $this->assertEquals([], $pre);
62 }

◆ testIsNotable()

ILIAS\Tests\Setup\Objective\ClientIdReadObjectiveTest::testIsNotable ( )

Definition at line 51 of file ClientIdReadObjectiveTest.php.

51 : void
52 {
53 $this->assertFalse($this->o->isNotable());
54 }

Field Documentation

◆ $o

ClientIdReadObjective ILIAS\Tests\Setup\Objective\ClientIdReadObjectiveTest::$o
protected

Definition at line 29 of file ClientIdReadObjectiveTest.php.


The documentation for this class was generated from the following file: