ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
IsNumericConstraintTest Class Reference
+ Inheritance diagram for IsNumericConstraintTest:
+ Collaboration diagram for IsNumericConstraintTest:

Public Member Functions

 setUp ()
 
 testAccepts1 ()
 
 testAccepts2 ()
 
 testAccepts3 ()
 
 testAccepts4 ()
 
 testAccepts5 ()
 
 testAccepts6 ()
 
 testAccepts7 ()
 
 testAccepts8 ()
 
 testNotAccepts1 ()
 
 testNotAccepts2 ()
 
 testCheckSucceed ()
 
 testCheckFails ()
 
 testNoProblemWith ()
 
 testProblemWith ()
 
 testRestrictOk ()
 
 testRestrictNotOk ()
 
 testRestrictError ()
 
 testWithProblemBuilder ()
 

Detailed Description

Definition at line 9 of file IsNumericConstraintTest.php.

Member Function Documentation

◆ setUp()

IsNumericConstraintTest::setUp ( )

Definition at line 11 of file IsNumericConstraintTest.php.

12  {
13  $this->df = new Data\Factory();
14  $this->lng = $this->createMock(\ilLanguage::class);
15  $this->f = new Validation\Factory($this->df, $this->lng);
16 
17  $this->c = $this->f->isNumeric();
18  }

◆ testAccepts1()

IsNumericConstraintTest::testAccepts1 ( )

Definition at line 20 of file IsNumericConstraintTest.php.

21  {
22  $this->assertTrue($this->c->accepts(0));
23  }

◆ testAccepts2()

IsNumericConstraintTest::testAccepts2 ( )

Definition at line 25 of file IsNumericConstraintTest.php.

26  {
27  $this->assertTrue($this->c->accepts("1"));
28  }

◆ testAccepts3()

IsNumericConstraintTest::testAccepts3 ( )

Definition at line 30 of file IsNumericConstraintTest.php.

31  {
32  $this->assertTrue($this->c->accepts(1));
33  }

◆ testAccepts4()

IsNumericConstraintTest::testAccepts4 ( )

Definition at line 35 of file IsNumericConstraintTest.php.

36  {
37  $this->assertTrue($this->c->accepts(0x102));
38  }

◆ testAccepts5()

IsNumericConstraintTest::testAccepts5 ( )

Definition at line 40 of file IsNumericConstraintTest.php.

41  {
42  $this->assertTrue($this->c->accepts(0102));
43  }

◆ testAccepts6()

IsNumericConstraintTest::testAccepts6 ( )

Definition at line 45 of file IsNumericConstraintTest.php.

46  {
47  $this->assertTrue($this->c->accepts(0b101));
48  }

◆ testAccepts7()

IsNumericConstraintTest::testAccepts7 ( )

Definition at line 50 of file IsNumericConstraintTest.php.

51  {
52  $this->assertTrue($this->c->accepts(192e0));
53  }

◆ testAccepts8()

IsNumericConstraintTest::testAccepts8 ( )

Definition at line 55 of file IsNumericConstraintTest.php.

56  {
57  $this->assertTrue($this->c->accepts(9.1));
58  }

◆ testCheckFails()

IsNumericConstraintTest::testCheckFails ( )

Definition at line 76 of file IsNumericConstraintTest.php.

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

◆ testCheckSucceed()

IsNumericConstraintTest::testCheckSucceed ( )

Definition at line 70 of file IsNumericConstraintTest.php.

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

◆ testNoProblemWith()

IsNumericConstraintTest::testNoProblemWith ( )

Definition at line 82 of file IsNumericConstraintTest.php.

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

◆ testNotAccepts1()

IsNumericConstraintTest::testNotAccepts1 ( )

Definition at line 60 of file IsNumericConstraintTest.php.

61  {
62  $this->assertFalse($this->c->accepts(null));
63  }

◆ testNotAccepts2()

IsNumericConstraintTest::testNotAccepts2 ( )

Definition at line 65 of file IsNumericConstraintTest.php.

66  {
67  $this->assertFalse($this->c->accepts("foo"));
68  }

◆ testProblemWith()

IsNumericConstraintTest::testProblemWith ( )

Definition at line 87 of file IsNumericConstraintTest.php.

References Sabre\Event\once().

88  {
89  $this->lng
90  ->expects($this->once())
91  ->method("txt")
92  ->with("not_numeric")
93  ->willReturn("-%s-");
94 
95  $this->assertEquals("-aa-", $this->c->problemWith("aa"));
96  }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
+ Here is the call graph for this function:

◆ testRestrictError()

IsNumericConstraintTest::testRestrictError ( )

Definition at line 114 of file IsNumericConstraintTest.php.

References $res.

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

◆ testRestrictNotOk()

IsNumericConstraintTest::testRestrictNotOk ( )

Definition at line 106 of file IsNumericConstraintTest.php.

References $res.

107  {
108  $not_ok = $this->df->ok("");
109 
110  $res = $this->c->restrict($not_ok);
111  $this->assertFalse($res->isOk());
112  }
foreach($_POST as $key=> $value) $res

◆ testRestrictOk()

IsNumericConstraintTest::testRestrictOk ( )

Definition at line 98 of file IsNumericConstraintTest.php.

References $ok, and $res.

99  {
100  $ok = $this->df->ok(2);
101 
102  $res = $this->c->restrict($ok);
103  $this->assertTrue($res->isOk());
104  }
foreach($_POST as $key=> $value) $res

◆ testWithProblemBuilder()

IsNumericConstraintTest::testWithProblemBuilder ( )

Definition at line 122 of file IsNumericConstraintTest.php.

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

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