ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
NotConstraintTest Class Reference
+ Inheritance diagram for NotConstraintTest:
+ Collaboration diagram for NotConstraintTest:

Public Member Functions

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

Protected Member Functions

 setUp ()
 

Private Attributes

DataFactory $df
 
ILIAS Language Language $lng
 
Refinery $refinery
 
Constraint $not_true
 
Constraint $not_false
 

Detailed Description

Definition at line 26 of file NotConstraintTest.php.

Member Function Documentation

◆ setUp()

NotConstraintTest::setUp ( )
protected

Definition at line 34 of file NotConstraintTest.php.

34 : void
35 {
36 $this->df = new DataFactory();
37 $this->lng = $this->createMock(ILIAS\Language\Language::class);
38 $this->refinery = new Refinery($this->df, $this->lng);
39
40 $group = $this->refinery->custom();
41
42 $this->not_true = $this->refinery->logical()->not($group->constraint(
43 static function ($v): bool {
44 return true;
45 },
46 "not_true"
47 ));
48
49 $this->not_false = $this->refinery->logical()->not($group->constraint(
50 static function ($v): bool {
51 return false;
52 },
53 "not_false"
54 ));
55 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ testAccepts()

NotConstraintTest::testAccepts ( )

Definition at line 57 of file NotConstraintTest.php.

57 : void
58 {
59 $this->assertTrue($this->not_false->accepts(null));
60 }

◆ testCheckFails()

NotConstraintTest::testCheckFails ( )

Definition at line 73 of file NotConstraintTest.php.

73 : void
74 {
75 $this->expectException(UnexpectedValueException::class);
76 $this->not_true->check(null);
77 }

◆ testCheckSucceed()

NotConstraintTest::testCheckSucceed ( )

Definition at line 67 of file NotConstraintTest.php.

67 : void
68 {
69 $this->not_false->check(null);
70 $this->assertTrue(true); // does not throw
71 }

◆ testNoProblemWith()

NotConstraintTest::testNoProblemWith ( )

Definition at line 79 of file NotConstraintTest.php.

79 : void
80 {
81 $this->assertNull($this->not_false->problemWith(null));
82 }

◆ testNotAccepts()

NotConstraintTest::testNotAccepts ( )

Definition at line 62 of file NotConstraintTest.php.

62 : void
63 {
64 $this->assertFalse($this->not_true->accepts(null));
65 }

◆ testProblemWith()

NotConstraintTest::testProblemWith ( )

Definition at line 84 of file NotConstraintTest.php.

84 : void
85 {
86 $this->lng
87 ->expects($this->once())
88 ->method("txt")
89 ->with("not_generic")
90 ->willReturn("-%s-");
91
92 $this->assertEquals("-not_true-", $this->not_true->problemWith(null));
93 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testRestrictError()

NotConstraintTest::testRestrictError ( )

Definition at line 111 of file NotConstraintTest.php.

111 : void
112 {
113 $error = $this->df->error("error");
114
115 $res = $this->not_false->applyTo($error);
116 $this->assertSame($error, $res);
117 }
$res
Definition: ltiservices.php:69

References $res.

◆ testRestrictNotOk()

NotConstraintTest::testRestrictNotOk ( )

Definition at line 103 of file NotConstraintTest.php.

103 : void
104 {
105 $not_ok = $this->df->ok(null);
106
107 $res = $this->not_true->applyTo($not_ok);
108 $this->assertFalse($res->isOk());
109 }

References $res.

◆ testRestrictOk()

NotConstraintTest::testRestrictOk ( )

Definition at line 95 of file NotConstraintTest.php.

95 : void
96 {
97 $ok = $this->df->ok(null);
98
99 $res = $this->not_false->applyTo($ok);
100 $this->assertTrue($res->isOk());
101 }

References $res.

◆ testWithProblemBuilder()

NotConstraintTest::testWithProblemBuilder ( )

Definition at line 119 of file NotConstraintTest.php.

119 : void
120 {
121 $new_c = $this->not_true->withProblemBuilder(static function (): string {
122 return "This was a fault";
123 });
124 $this->assertEquals("This was a fault", $new_c->problemWith(null));
125 }

Field Documentation

◆ $df

DataFactory NotConstraintTest::$df
private

Definition at line 28 of file NotConstraintTest.php.

◆ $lng

ILIAS Language Language NotConstraintTest::$lng
private

Definition at line 29 of file NotConstraintTest.php.

◆ $not_false

Constraint NotConstraintTest::$not_false
private

Definition at line 32 of file NotConstraintTest.php.

◆ $not_true

Constraint NotConstraintTest::$not_true
private

Definition at line 31 of file NotConstraintTest.php.

◆ $refinery

Refinery NotConstraintTest::$refinery
private

Definition at line 30 of file NotConstraintTest.php.


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