ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SequentialConstraintTest Class Reference
+ Inheritance diagram for SequentialConstraintTest:
+ Collaboration diagram for SequentialConstraintTest:

Public Member Functions

 testAccepts ()
 
 testNotAccepts ()
 
 testCheckSucceed ()
 
 testCheckFails ()
 
 testNoProblemWith ()
 
 testProblemWith1 ()
 
 testProblemWith2 ()
 
 testRestrictOk ()
 
 testRestrictNotOk ()
 
 testRestrictError ()
 
 testWithProblemBuilder ()
 

Protected Member Functions

 setUp ()
 

Private Attributes

DataFactory $df
 
ILIAS Language Language $lng
 
Refinery $refinery
 
Constraint $c
 

Detailed Description

Definition at line 26 of file SequentialConstraintTest.php.

Member Function Documentation

◆ setUp()

SequentialConstraintTest::setUp ( )
protected

Definition at line 33 of file SequentialConstraintTest.php.

33 : void
34 {
35 $this->df = new DataFactory();
36 $this->lng = $this->createMock(ILIAS\Language\Language::class);
37 $this->refinery = new Refinery($this->df, $this->lng);
38
39 $group = $this->refinery->custom();
40
41 $greater_than_3 = $group->constraint(
42 function ($value) {
43 return $value > 3;
44 },
45 "not_greater_than_3"
46 );
47
48 $less_than_5 = $group->constraint(
49 function ($value) {
50 return $value < 5;
51 },
52 "not_less_than_5"
53 );
54
55 $this->c = $this->refinery
56 ->logical()
57 ->sequential([$greater_than_3, $less_than_5]);
58 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ testAccepts()

SequentialConstraintTest::testAccepts ( )

Definition at line 60 of file SequentialConstraintTest.php.

60 : void
61 {
62 $this->assertTrue($this->c->accepts(4));
63 }

◆ testCheckFails()

SequentialConstraintTest::testCheckFails ( )

Definition at line 76 of file SequentialConstraintTest.php.

76 : void
77 {
78 $this->expectException(UnexpectedValueException::class);
79 $this->c->check(2);
80 }

◆ testCheckSucceed()

SequentialConstraintTest::testCheckSucceed ( )

Definition at line 70 of file SequentialConstraintTest.php.

70 : void
71 {
72 $this->c->check(4);
73 $this->assertTrue(true); // does not throw
74 }

◆ testNoProblemWith()

SequentialConstraintTest::testNoProblemWith ( )

Definition at line 82 of file SequentialConstraintTest.php.

82 : void
83 {
84 $this->assertNull($this->c->problemWith(4));
85 }

◆ testNotAccepts()

SequentialConstraintTest::testNotAccepts ( )

Definition at line 65 of file SequentialConstraintTest.php.

65 : void
66 {
67 $this->assertFalse($this->c->accepts(2));
68 }

◆ testProblemWith1()

SequentialConstraintTest::testProblemWith1 ( )

Definition at line 87 of file SequentialConstraintTest.php.

87 : void
88 {
89 $this->lng
90 ->expects($this->never())
91 ->method("txt");
92
93 $this->assertEquals("not_greater_than_3", $this->c->problemWith(2));
94 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testProblemWith2()

SequentialConstraintTest::testProblemWith2 ( )

Definition at line 96 of file SequentialConstraintTest.php.

96 : void
97 {
98 $this->lng
99 ->expects($this->never())
100 ->method("txt");
101
102 $this->assertEquals("not_less_than_5", $this->c->problemWith(6));
103 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testRestrictError()

SequentialConstraintTest::testRestrictError ( )

Definition at line 121 of file SequentialConstraintTest.php.

121 : void
122 {
123 $error = $this->df->error("error");
124
125 $res = $this->c->applyTo($error);
126 $this->assertSame($error, $res);
127 }
$res
Definition: ltiservices.php:69

References $res.

◆ testRestrictNotOk()

SequentialConstraintTest::testRestrictNotOk ( )

Definition at line 113 of file SequentialConstraintTest.php.

113 : void
114 {
115 $not_ok = $this->df->ok(7);
116
117 $res = $this->c->applyTo($not_ok);
118 $this->assertFalse($res->isOk());
119 }

References $res.

◆ testRestrictOk()

SequentialConstraintTest::testRestrictOk ( )

Definition at line 105 of file SequentialConstraintTest.php.

105 : void
106 {
107 $ok = $this->df->ok(4);
108
109 $res = $this->c->applyTo($ok);
110 $this->assertTrue($res->isOk());
111 }

References $res.

◆ testWithProblemBuilder()

SequentialConstraintTest::testWithProblemBuilder ( )

Definition at line 129 of file SequentialConstraintTest.php.

129 : void
130 {
131 $new_c = $this->c->withProblemBuilder(static function (): string {
132 return "This was a fault";
133 });
134 $this->assertEquals("This was a fault", $new_c->problemWith(7));
135 }

Field Documentation

◆ $c

Constraint SequentialConstraintTest::$c
private

Definition at line 31 of file SequentialConstraintTest.php.

◆ $df

DataFactory SequentialConstraintTest::$df
private

Definition at line 28 of file SequentialConstraintTest.php.

◆ $lng

ILIAS Language Language SequentialConstraintTest::$lng
private

Definition at line 29 of file SequentialConstraintTest.php.

◆ $refinery

Refinery SequentialConstraintTest::$refinery
private

Definition at line 30 of file SequentialConstraintTest.php.


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