ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ParallelTest Class Reference

TestCase for the parellel constraint. More...

+ Inheritance diagram for ParallelTest:
+ Collaboration diagram for ParallelTest:

Public Member Functions

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

Protected Member Functions

 setUp ()
 

Detailed Description

TestCase for the parellel 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 ParallelConstraintsTest.php.

Member Function Documentation

◆ setUp()

ParallelTest::setUp ( )
protected

Definition at line 16 of file ParallelConstraintsTest.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->less_than_3 = $this->f->custom(
23  function ($value) {
24  return $value < 3;
25  },
26  "not_less_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->parallel([$this->less_than_3, $this->less_than_5]);
37  }

◆ testAccepts()

ParallelTest::testAccepts ( )

Definition at line 39 of file ParallelConstraintsTest.php.

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

◆ testCheckFails()

ParallelTest::testCheckFails ( )

Definition at line 55 of file ParallelConstraintsTest.php.

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

◆ testCheckSucceed()

ParallelTest::testCheckSucceed ( )

Definition at line 49 of file ParallelConstraintsTest.php.

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

◆ testNoProblemWith()

ParallelTest::testNoProblemWith ( )

Definition at line 61 of file ParallelConstraintsTest.php.

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

◆ testNotAccepts()

ParallelTest::testNotAccepts ( )

Definition at line 44 of file ParallelConstraintsTest.php.

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

◆ testProblemWith1()

ParallelTest::testProblemWith1 ( )

Definition at line 66 of file ParallelConstraintsTest.php.

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

◆ testProblemWith2()

ParallelTest::testProblemWith2 ( )

Definition at line 75 of file ParallelConstraintsTest.php.

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

◆ testRestrictError()

ParallelTest::testRestrictError ( )

Definition at line 100 of file ParallelConstraintsTest.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()

ParallelTest::testRestrictNotOk ( )

Definition at line 92 of file ParallelConstraintsTest.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()

ParallelTest::testRestrictOk ( )

Definition at line 84 of file ParallelConstraintsTest.php.

References $ok, and $res.

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

◆ testWithProblemBuilder()

ParallelTest::testWithProblemBuilder ( )

Definition at line 108 of file ParallelConstraintsTest.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: