ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
NotTest Class Reference
+ Inheritance diagram for NotTest:
+ Collaboration diagram for NotTest:

Public Member Functions

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

Protected Member Functions

 setUp ()
 

Private Attributes

DataFactory $df
 
ilLanguage $lng
 
Refinery $refinery
 
Constraint $not_true
 
Constraint $not_false
 

Detailed Description

Definition at line 26 of file NotConstraintTest.php.

Member Function Documentation

◆ setUp()

NotTest::setUp ( )
protected

Definition at line 34 of file NotConstraintTest.php.

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

34  : void
35  {
36  $this->df = new DataFactory();
37  $this->lng = $this->createMock(ilLanguage::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  }
+ Here is the call graph for this function:

◆ testAccepts()

NotTest::testAccepts ( )

Definition at line 57 of file NotConstraintTest.php.

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

◆ testCheckFails()

NotTest::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()

NotTest::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()

NotTest::testNoProblemWith ( )

Definition at line 79 of file NotConstraintTest.php.

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

◆ testNotAccepts()

NotTest::testNotAccepts ( )

Definition at line 62 of file NotConstraintTest.php.

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

◆ testProblemWith()

NotTest::testProblemWith ( )

Definition at line 84 of file NotConstraintTest.php.

References ILIAS\Repository\lng().

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  }
+ Here is the call graph for this function:

◆ testRestrictError()

NotTest::testRestrictError ( )

Definition at line 111 of file NotConstraintTest.php.

References $res.

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

◆ testRestrictNotOk()

NotTest::testRestrictNotOk ( )

Definition at line 103 of file NotConstraintTest.php.

References $res.

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  }
$res
Definition: ltiservices.php:69

◆ testRestrictOk()

NotTest::testRestrictOk ( )

Definition at line 95 of file NotConstraintTest.php.

References $res.

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

◆ testWithProblemBuilder()

NotTest::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 NotTest::$df
private

Definition at line 28 of file NotConstraintTest.php.

◆ $lng

ilLanguage NotTest::$lng
private

Definition at line 29 of file NotConstraintTest.php.

◆ $not_false

Constraint NotTest::$not_false
private

Definition at line 32 of file NotConstraintTest.php.

◆ $not_true

Constraint NotTest::$not_true
private

Definition at line 31 of file NotConstraintTest.php.

◆ $refinery

Refinery NotTest::$refinery
private

Definition at line 30 of file NotConstraintTest.php.


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