ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
NotTest Class Reference
+ Inheritance diagram for NotTest:
+ Collaboration diagram for NotTest:

Public Member Functions

 setUp ()
 
 testAccepts ()
 
 testNotAccepts ()
 
 testCheckSucceed ()
 
 testCheckFails ()
 
 testNoProblemWith ()
 
 testProblemWith ()
 
 testRestrictOk ()
 
 testRestrictNotOk ()
 
 testRestrictError ()
 
 testWithProblemBuilder ()
 

Private Attributes

 $df
 
 $lng
 
 $refinery
 
 $not_true
 
 $not_false
 

Detailed Description

Definition at line 10 of file NotConstraintTest.php.

Member Function Documentation

◆ setUp()

NotTest::setUp ( )

Definition at line 37 of file NotConstraintTest.php.

37 : void
38 {
39 $this->df = new Data\Factory();
40 $this->lng = $this->createMock(\ilLanguage::class);
41 $this->refinery = new \ILIAS\Refinery\Factory($this->df, $this->lng);
42
43 $group = $this->refinery->custom();
44
45 $this->not_true = $this->refinery->logical()->not($group->constraint(
46 function ($v) {
47 return true;
48 },
49 "not_true"
50 ));
51
52 $this->not_false = $this->refinery->logical()->not($group->constraint(
53 function ($v) {
54 return false;
55 },
56 "not_false"
57 ));
58 }

◆ testAccepts()

NotTest::testAccepts ( )

Definition at line 60 of file NotConstraintTest.php.

61 {
62 $this->assertTrue($this->not_false->accepts(null));
63 }

◆ testCheckFails()

NotTest::testCheckFails ( )

Definition at line 76 of file NotConstraintTest.php.

77 {
78 $this->expectException(\UnexpectedValueException::class);
79 $this->not_true->check(null);
80 }

◆ testCheckSucceed()

NotTest::testCheckSucceed ( )

Definition at line 70 of file NotConstraintTest.php.

71 {
72 $this->not_false->check(null);
73 $this->assertTrue(true); // does not throw
74 }

◆ testNoProblemWith()

NotTest::testNoProblemWith ( )

Definition at line 82 of file NotConstraintTest.php.

83 {
84 $this->assertNull($this->not_false->problemWith(null));
85 }

◆ testNotAccepts()

NotTest::testNotAccepts ( )

Definition at line 65 of file NotConstraintTest.php.

66 {
67 $this->assertFalse($this->not_true->accepts(null));
68 }

◆ testProblemWith()

NotTest::testProblemWith ( )

Definition at line 87 of file NotConstraintTest.php.

88 {
89 $this->lng
90 ->expects($this->once())
91 ->method("txt")
92 ->with("not_generic")
93 ->willReturn("-%s-");
94
95 $this->assertEquals("-not_true-", $this->not_true->problemWith(null));
96 }

◆ testRestrictError()

NotTest::testRestrictError ( )

Definition at line 114 of file NotConstraintTest.php.

115 {
116 $error = $this->df->error("error");
117
118 $res = $this->not_false->applyTo($error);
119 $this->assertSame($error, $res);
120 }
foreach($_POST as $key=> $value) $res

References $res.

◆ testRestrictNotOk()

NotTest::testRestrictNotOk ( )

Definition at line 106 of file NotConstraintTest.php.

107 {
108 $not_ok = $this->df->ok(null);
109
110 $res = $this->not_true->applyTo($not_ok);
111 $this->assertFalse($res->isOk());
112 }

References $res.

◆ testRestrictOk()

NotTest::testRestrictOk ( )

Definition at line 98 of file NotConstraintTest.php.

99 {
100 $ok = $this->df->ok(null);
101
102 $res = $this->not_false->applyTo($ok);
103 $this->assertTrue($res->isOk());
104 }

References $ok, and $res.

◆ testWithProblemBuilder()

NotTest::testWithProblemBuilder ( )

Definition at line 122 of file NotConstraintTest.php.

123 {
124 $new_c = $this->not_true->withProblemBuilder(function () {
125 return "This was a fault";
126 });
127 $this->assertEquals("This was a fault", $new_c->problemWith(null));
128 }

Field Documentation

◆ $df

NotTest::$df
private

Definition at line 15 of file NotConstraintTest.php.

◆ $lng

NotTest::$lng
private

Definition at line 20 of file NotConstraintTest.php.

◆ $not_false

NotTest::$not_false
private

Definition at line 35 of file NotConstraintTest.php.

◆ $not_true

NotTest::$not_true
private

Definition at line 30 of file NotConstraintTest.php.

◆ $refinery

NotTest::$refinery
private

Definition at line 25 of file NotConstraintTest.php.


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