ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
IsNullConstraintTest Class Reference
+ Inheritance diagram for IsNullConstraintTest:
+ Collaboration diagram for IsNullConstraintTest:

Public Member Functions

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

Detailed Description

Definition at line 10 of file IsNullConstraintTest.php.

Member Function Documentation

◆ setUp()

IsNullConstraintTest::setUp ( )

Definition at line 12 of file IsNullConstraintTest.php.

12  : void
13  {
14  $this->df = new Data\Factory();
15  $this->lng = $this->createMock(\ilLanguage::class);
16  $this->f = new Factory($this->df, $this->lng);
17 
18  $this->c = $this->f->null();
19  }
Builds data types.
Definition: Factory.php:19

◆ testAccepts()

IsNullConstraintTest::testAccepts ( )

Definition at line 21 of file IsNullConstraintTest.php.

22  {
23  $this->assertTrue($this->c->accepts(null));
24  }

◆ testCheckFails()

IsNullConstraintTest::testCheckFails ( )

Definition at line 37 of file IsNullConstraintTest.php.

38  {
39  $this->expectException(\UnexpectedValueException::class);
40  $this->c->check(2);
41  }

◆ testCheckSucceed()

IsNullConstraintTest::testCheckSucceed ( )

Definition at line 31 of file IsNullConstraintTest.php.

32  {
33  $this->c->check(null);
34  $this->assertTrue(true); // does not throw
35  }

◆ testNoProblemWith()

IsNullConstraintTest::testNoProblemWith ( )

Definition at line 43 of file IsNullConstraintTest.php.

44  {
45  $this->assertNull($this->c->problemWith(null));
46  }

◆ testNotAccepts()

IsNullConstraintTest::testNotAccepts ( )

Definition at line 26 of file IsNullConstraintTest.php.

27  {
28  $this->assertFalse($this->c->accepts(2));
29  }

◆ testProblemWith()

IsNullConstraintTest::testProblemWith ( )

Definition at line 48 of file IsNullConstraintTest.php.

49  {
50  $this->lng
51  ->expects($this->once())
52  ->method("txt")
53  ->with("not_a_null")
54  ->willReturn("-%s-");
55 
56  $this->assertEquals("-integer-", $this->c->problemWith(2));
57  }

◆ testRestrictError()

IsNullConstraintTest::testRestrictError ( )

Definition at line 75 of file IsNullConstraintTest.php.

References $res.

76  {
77  $error = $this->df->error("error");
78 
79  $res = $this->c->applyTo($error);
80  $this->assertSame($error, $res);
81  }
foreach($_POST as $key=> $value) $res

◆ testRestrictNotOk()

IsNullConstraintTest::testRestrictNotOk ( )

Definition at line 67 of file IsNullConstraintTest.php.

References $res.

68  {
69  $not_ok = $this->df->ok(2);
70 
71  $res = $this->c->applyTo($not_ok);
72  $this->assertFalse($res->isOk());
73  }
foreach($_POST as $key=> $value) $res

◆ testRestrictOk()

IsNullConstraintTest::testRestrictOk ( )

Definition at line 59 of file IsNullConstraintTest.php.

References $ok, and $res.

60  {
61  $ok = $this->df->ok(null);
62 
63  $res = $this->c->applyTo($ok);
64  $this->assertTrue($res->isOk());
65  }
foreach($_POST as $key=> $value) $res

◆ testWithProblemBuilder()

IsNullConstraintTest::testWithProblemBuilder ( )

Definition at line 83 of file IsNullConstraintTest.php.

84  {
85  $new_c = $this->c->withProblemBuilder(function () {
86  return "This was a fault";
87  });
88  $this->assertEquals("This was a fault", $new_c->problemWith(2));
89  }

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