ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 

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 14 of file SequentialConstraintTest.php.

Member Function Documentation

◆ setUp()

SequentialTest::setUp ( )
protected

Definition at line 16 of file SequentialConstraintTest.php.

17  {
18  $this->df = new Data\Factory();
19  $this->lng = $this->createMock(\ilLanguage::class);
20  $this->f = new Validation\Factory($this->df, $this->lng);
21 
22  $this->greater_than_3 = $this->f->custom(
23  function ($value) {
24  return $value > 3;
25  },
26  "not_greater_than_3"
27  );
28 
29  $this->less_than_5 = $this->f->custom(
30  function ($value) {
31  return $value < 5;
32  },
33  "not_less_than_5"
34  );
35 
36  $this->c = $this->f->sequential([$this->greater_than_3, $this->less_than_5]);
37  }

◆ testAccepts()

SequentialTest::testAccepts ( )

Definition at line 39 of file SequentialConstraintTest.php.

40  {
41  $this->assertTrue($this->c->accepts(4));
42  }

◆ testCheckFails()

SequentialTest::testCheckFails ( )

Definition at line 55 of file SequentialConstraintTest.php.

56  {
57  $this->expectException(\UnexpectedValueException::class);
58  $this->c->check(2);
59  }

◆ testCheckSucceed()

SequentialTest::testCheckSucceed ( )

Definition at line 49 of file SequentialConstraintTest.php.

50  {
51  $this->c->check(4);
52  $this->assertTrue(true); // does not throw
53  }

◆ testNoProblemWith()

SequentialTest::testNoProblemWith ( )

Definition at line 61 of file SequentialConstraintTest.php.

62  {
63  $this->assertNull($this->c->problemWith(4));
64  }

◆ testNotAccepts()

SequentialTest::testNotAccepts ( )

Definition at line 44 of file SequentialConstraintTest.php.

45  {
46  $this->assertFalse($this->c->accepts(2));
47  }

◆ testProblemWith1()

SequentialTest::testProblemWith1 ( )

Definition at line 66 of file SequentialConstraintTest.php.

67  {
68  $this->lng
69  ->expects($this->never())
70  ->method("txt");
71 
72  $this->assertEquals("not_greater_than_3", $this->c->problemWith(2));
73  }

◆ testProblemWith2()

SequentialTest::testProblemWith2 ( )

Definition at line 75 of file SequentialConstraintTest.php.

76  {
77  $this->lng
78  ->expects($this->never())
79  ->method("txt");
80 
81  $this->assertEquals("not_less_than_5", $this->c->problemWith(6));
82  }

◆ testRestrictError()

SequentialTest::testRestrictError ( )

Definition at line 100 of file SequentialConstraintTest.php.

References $res.

101  {
102  $error = $this->df->error("error");
103 
104  $res = $this->c->restrict($error);
105  $this->assertSame($error, $res);
106  }
foreach($_POST as $key=> $value) $res

◆ testRestrictNotOk()

SequentialTest::testRestrictNotOk ( )

Definition at line 92 of file SequentialConstraintTest.php.

References $res.

93  {
94  $not_ok = $this->df->ok(7);
95 
96  $res = $this->c->restrict($not_ok);
97  $this->assertFalse($res->isOk());
98  }
foreach($_POST as $key=> $value) $res

◆ testRestrictOk()

SequentialTest::testRestrictOk ( )

Definition at line 84 of file SequentialConstraintTest.php.

References $ok, and $res.

85  {
86  $ok = $this->df->ok(4);
87 
88  $res = $this->c->restrict($ok);
89  $this->assertTrue($res->isOk());
90  }
foreach($_POST as $key=> $value) $res

◆ testWithProblemBuilder()

SequentialTest::testWithProblemBuilder ( )

Definition at line 108 of file SequentialConstraintTest.php.

109  {
110  $new_c = $this->c->withProblemBuilder(function () {
111  return "This was a fault";
112  });
113  $this->assertEquals("This was a fault", $new_c->problemWith(7));
114  }

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