ILIAS  release_8 Revision v8.23
SequentialTest Class Reference
+ Inheritance diagram for SequentialTest:
+ Collaboration diagram for SequentialTest:

Public Member Functions

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

Protected Member Functions

 setUp ()
 

Private Attributes

DataFactory $df
 
ilLanguage $lng
 
Refinery $refinery
 
Constraint $c
 

Detailed Description

Definition at line 26 of file SequentialConstraintTest.php.

Member Function Documentation

◆ setUp()

SequentialTest::setUp ( )
protected

Definition at line 33 of file SequentialConstraintTest.php.

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

33  : void
34  {
35  $this->df = new DataFactory();
36  $this->lng = $this->createMock(ilLanguage::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  }
+ Here is the call graph for this function:

◆ testAccepts()

SequentialTest::testAccepts ( )

Definition at line 60 of file SequentialConstraintTest.php.

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

◆ testCheckFails()

SequentialTest::testCheckFails ( )

Definition at line 76 of file SequentialConstraintTest.php.

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

◆ testCheckSucceed()

SequentialTest::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()

SequentialTest::testNoProblemWith ( )

Definition at line 82 of file SequentialConstraintTest.php.

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

◆ testNotAccepts()

SequentialTest::testNotAccepts ( )

Definition at line 65 of file SequentialConstraintTest.php.

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

◆ testProblemWith1()

SequentialTest::testProblemWith1 ( )

Definition at line 87 of file SequentialConstraintTest.php.

References ILIAS\Repository\lng().

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  }
+ Here is the call graph for this function:

◆ testProblemWith2()

SequentialTest::testProblemWith2 ( )

Definition at line 96 of file SequentialConstraintTest.php.

References ILIAS\Repository\lng().

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  }
+ Here is the call graph for this function:

◆ testRestrictError()

SequentialTest::testRestrictError ( )

Definition at line 121 of file SequentialConstraintTest.php.

References $res.

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

◆ testRestrictNotOk()

SequentialTest::testRestrictNotOk ( )

Definition at line 113 of file SequentialConstraintTest.php.

References $res.

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

◆ testRestrictOk()

SequentialTest::testRestrictOk ( )

Definition at line 105 of file SequentialConstraintTest.php.

References $res.

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

◆ testWithProblemBuilder()

SequentialTest::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 SequentialTest::$c
private

Definition at line 31 of file SequentialConstraintTest.php.

◆ $df

DataFactory SequentialTest::$df
private

Definition at line 28 of file SequentialConstraintTest.php.

◆ $lng

ilLanguage SequentialTest::$lng
private

Definition at line 29 of file SequentialConstraintTest.php.

◆ $refinery

Refinery SequentialTest::$refinery
private

Definition at line 30 of file SequentialConstraintTest.php.


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