ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
SequentialTest Class Reference

TestCase for the sequential constraint. More...

+ 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

 $df
 
 $lng
 
 $refinery
 
 $greater_than_3
 
 $less_than_5
 

Detailed Description

TestCase for the sequential constraint.

Author
Stefan Hecken stefa.nosp@m.n.he.nosp@m.cken@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de

Definition at line 15 of file SequentialConstraintTest.php.

Member Function Documentation

◆ setUp()

SequentialTest::setUp ( )
protected

Definition at line 42 of file SequentialConstraintTest.php.

42  : void
43  {
44  $this->df = new Data\Factory();
45  $this->lng = $this->createMock(\ilLanguage::class);
46  $this->refinery = new \ILIAS\Refinery\Factory($this->df, $this->lng);
47 
48  $group = $this->refinery->custom();
49 
50  $this->greater_than_3 = $group->constraint(
51  function ($value) {
52  return $value > 3;
53  },
54  "not_greater_than_3"
55  );
56 
57  $this->less_than_5 = $group->constraint(
58  function ($value) {
59  return $value < 5;
60  },
61  "not_less_than_5"
62  );
63 
64  $this->c = $this->refinery
65  ->logical()
66  ->sequential([$this->greater_than_3, $this->less_than_5]);
67  }

◆ testAccepts()

SequentialTest::testAccepts ( )

Definition at line 69 of file SequentialConstraintTest.php.

70  {
71  $this->assertTrue($this->c->accepts(4));
72  }

◆ testCheckFails()

SequentialTest::testCheckFails ( )

Definition at line 85 of file SequentialConstraintTest.php.

86  {
87  $this->expectException(\UnexpectedValueException::class);
88  $this->c->check(2);
89  }

◆ testCheckSucceed()

SequentialTest::testCheckSucceed ( )

Definition at line 79 of file SequentialConstraintTest.php.

80  {
81  $this->c->check(4);
82  $this->assertTrue(true); // does not throw
83  }

◆ testNoProblemWith()

SequentialTest::testNoProblemWith ( )

Definition at line 91 of file SequentialConstraintTest.php.

92  {
93  $this->assertNull($this->c->problemWith(4));
94  }

◆ testNotAccepts()

SequentialTest::testNotAccepts ( )

Definition at line 74 of file SequentialConstraintTest.php.

75  {
76  $this->assertFalse($this->c->accepts(2));
77  }

◆ testProblemWith1()

SequentialTest::testProblemWith1 ( )

Definition at line 96 of file SequentialConstraintTest.php.

97  {
98  $this->lng
99  ->expects($this->never())
100  ->method("txt");
101 
102  $this->assertEquals("not_greater_than_3", $this->c->problemWith(2));
103  }

◆ testProblemWith2()

SequentialTest::testProblemWith2 ( )

Definition at line 105 of file SequentialConstraintTest.php.

106  {
107  $this->lng
108  ->expects($this->never())
109  ->method("txt");
110 
111  $this->assertEquals("not_less_than_5", $this->c->problemWith(6));
112  }

◆ testRestrictError()

SequentialTest::testRestrictError ( )

Definition at line 130 of file SequentialConstraintTest.php.

References $res.

131  {
132  $error = $this->df->error("error");
133 
134  $res = $this->c->applyTo($error);
135  $this->assertSame($error, $res);
136  }
foreach($_POST as $key=> $value) $res

◆ testRestrictNotOk()

SequentialTest::testRestrictNotOk ( )

Definition at line 122 of file SequentialConstraintTest.php.

References $res.

123  {
124  $not_ok = $this->df->ok(7);
125 
126  $res = $this->c->applyTo($not_ok);
127  $this->assertFalse($res->isOk());
128  }
foreach($_POST as $key=> $value) $res

◆ testRestrictOk()

SequentialTest::testRestrictOk ( )

Definition at line 114 of file SequentialConstraintTest.php.

References $ok, and $res.

115  {
116  $ok = $this->df->ok(4);
117 
118  $res = $this->c->applyTo($ok);
119  $this->assertTrue($res->isOk());
120  }
foreach($_POST as $key=> $value) $res

◆ testWithProblemBuilder()

SequentialTest::testWithProblemBuilder ( )

Definition at line 138 of file SequentialConstraintTest.php.

139  {
140  $new_c = $this->c->withProblemBuilder(function () {
141  return "This was a fault";
142  });
143  $this->assertEquals("This was a fault", $new_c->problemWith(7));
144  }

Field Documentation

◆ $df

SequentialTest::$df
private

Definition at line 20 of file SequentialConstraintTest.php.

◆ $greater_than_3

SequentialTest::$greater_than_3
private

Definition at line 35 of file SequentialConstraintTest.php.

◆ $less_than_5

SequentialTest::$less_than_5
private

Definition at line 40 of file SequentialConstraintTest.php.

◆ $lng

SequentialTest::$lng
private

Definition at line 25 of file SequentialConstraintTest.php.

◆ $refinery

SequentialTest::$refinery
private

Definition at line 30 of file SequentialConstraintTest.php.


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