ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 

Private Attributes

 $df
 
 $lng
 
 $refinery
 

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 15 of file ParallelConstraintsTest.php.

Member Function Documentation

◆ setUp()

ParallelTest::setUp ( )
protected

Definition at line 32 of file ParallelConstraintsTest.php.

32  : void
33  {
34  $this->df = new Data\Factory();
35  $this->lng = $this->createMock(\ilLanguage::class);
36  $this->refinery = new \ILIAS\Refinery\Factory($this->df, $this->lng);
37 
38  $group = $this->refinery->custom();
39 
40  $this->less_than_3 = $group->constraint(
41  function ($value) {
42  return $value < 3;
43  },
44  "not_less_than_3"
45  );
46 
47  $this->less_than_5 = $group->constraint(
48  function ($value) {
49  return $value < 5;
50  },
51  "not_less_than_5"
52  );
53 
54  $this->c = $this->refinery
55  ->logical()
56  ->parallel([$this->less_than_3, $this->less_than_5]);
57  }

◆ testAccepts()

ParallelTest::testAccepts ( )

Definition at line 59 of file ParallelConstraintsTest.php.

60  {
61  $this->assertTrue($this->c->accepts(2));
62  }

◆ testCheckFails()

ParallelTest::testCheckFails ( )

Definition at line 75 of file ParallelConstraintsTest.php.

76  {
77  $this->expectException(\UnexpectedValueException::class);
78  $this->c->check(6);
79  }

◆ testCheckSucceed()

ParallelTest::testCheckSucceed ( )

Definition at line 69 of file ParallelConstraintsTest.php.

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

◆ testNoProblemWith()

ParallelTest::testNoProblemWith ( )

Definition at line 81 of file ParallelConstraintsTest.php.

82  {
83  $this->assertNull($this->c->problemWith(2));
84  }

◆ testNotAccepts()

ParallelTest::testNotAccepts ( )

Definition at line 64 of file ParallelConstraintsTest.php.

65  {
66  $this->assertFalse($this->c->accepts(4));
67  }

◆ testProblemWith1()

ParallelTest::testProblemWith1 ( )

Definition at line 86 of file ParallelConstraintsTest.php.

87  {
88  $this->lng
89  ->expects($this->never())
90  ->method("txt");
91 
92  $this->assertEquals("not_less_than_3", $this->c->problemWith(4));
93  }

◆ testProblemWith2()

ParallelTest::testProblemWith2 ( )

Definition at line 95 of file ParallelConstraintsTest.php.

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

◆ testRestrictError()

ParallelTest::testRestrictError ( )

Definition at line 120 of file ParallelConstraintsTest.php.

References $res.

121  {
122  $error = $this->df->error("error");
123 
124  $res = $this->c->applyTo($error);
125  $this->assertSame($error, $res);
126  }
foreach($_POST as $key=> $value) $res

◆ testRestrictNotOk()

ParallelTest::testRestrictNotOk ( )

Definition at line 112 of file ParallelConstraintsTest.php.

References $res.

113  {
114  $not_ok = $this->df->ok(7);
115 
116  $res = $this->c->applyTo($not_ok);
117  $this->assertFalse($res->isOk());
118  }
foreach($_POST as $key=> $value) $res

◆ testRestrictOk()

ParallelTest::testRestrictOk ( )

Definition at line 104 of file ParallelConstraintsTest.php.

References $ok, and $res.

105  {
106  $ok = $this->df->ok(2);
107 
108  $res = $this->c->applyTo($ok);
109  $this->assertTrue($res->isOk());
110  }
foreach($_POST as $key=> $value) $res

◆ testWithProblemBuilder()

ParallelTest::testWithProblemBuilder ( )

Definition at line 128 of file ParallelConstraintsTest.php.

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

Field Documentation

◆ $df

ParallelTest::$df
private

Definition at line 20 of file ParallelConstraintsTest.php.

◆ $lng

ParallelTest::$lng
private

Definition at line 25 of file ParallelConstraintsTest.php.

◆ $refinery

ParallelTest::$refinery
private

Definition at line 30 of file ParallelConstraintsTest.php.


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