ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 10 of file IsNumericConstraintTest.php.

Member Function Documentation

◆ setUp()

IsNumericConstraintTest::setUp ( )

Definition at line 12 of file IsNumericConstraintTest.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->numeric()->isNumeric();
19  }
Builds data types.
Definition: Factory.php:19

◆ testAccepts1()

IsNumericConstraintTest::testAccepts1 ( )

Definition at line 21 of file IsNumericConstraintTest.php.

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

◆ testAccepts2()

IsNumericConstraintTest::testAccepts2 ( )

Definition at line 26 of file IsNumericConstraintTest.php.

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

◆ testAccepts3()

IsNumericConstraintTest::testAccepts3 ( )

Definition at line 31 of file IsNumericConstraintTest.php.

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

◆ testAccepts4()

IsNumericConstraintTest::testAccepts4 ( )

Definition at line 36 of file IsNumericConstraintTest.php.

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

◆ testAccepts5()

IsNumericConstraintTest::testAccepts5 ( )

Definition at line 41 of file IsNumericConstraintTest.php.

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

◆ testAccepts6()

IsNumericConstraintTest::testAccepts6 ( )

Definition at line 46 of file IsNumericConstraintTest.php.

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

◆ testAccepts7()

IsNumericConstraintTest::testAccepts7 ( )

Definition at line 51 of file IsNumericConstraintTest.php.

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

◆ testAccepts8()

IsNumericConstraintTest::testAccepts8 ( )

Definition at line 56 of file IsNumericConstraintTest.php.

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

◆ testCheckFails()

IsNumericConstraintTest::testCheckFails ( )

Definition at line 77 of file IsNumericConstraintTest.php.

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

◆ testCheckSucceed()

IsNumericConstraintTest::testCheckSucceed ( )

Definition at line 71 of file IsNumericConstraintTest.php.

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

◆ testNoProblemWith()

IsNumericConstraintTest::testNoProblemWith ( )

Definition at line 83 of file IsNumericConstraintTest.php.

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

◆ testNotAccepts1()

IsNumericConstraintTest::testNotAccepts1 ( )

Definition at line 61 of file IsNumericConstraintTest.php.

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

◆ testNotAccepts2()

IsNumericConstraintTest::testNotAccepts2 ( )

Definition at line 66 of file IsNumericConstraintTest.php.

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

◆ testProblemWith()

IsNumericConstraintTest::testProblemWith ( )

Definition at line 88 of file IsNumericConstraintTest.php.

89  {
90  $this->lng
91  ->expects($this->once())
92  ->method("txt")
93  ->with("not_numeric")
94  ->willReturn("-%s-");
95 
96  $this->assertEquals("-aa-", $this->c->problemWith("aa"));
97  }

◆ testRestrictError()

IsNumericConstraintTest::testRestrictError ( )

Definition at line 121 of file IsNumericConstraintTest.php.

References $res.

122  {
123  $error = $this->df->error("error");
124 
125  $res = $this->c->applyTo($error);
126  $this->assertSame($error, $res);
127  }
foreach($_POST as $key=> $value) $res

◆ testRestrictNotOk()

IsNumericConstraintTest::testRestrictNotOk ( )

Definition at line 107 of file IsNumericConstraintTest.php.

References $res.

108  {
109  $not_ok = $this->df->ok("");
110 
111  $this->lng
112  ->expects($this->once())
113  ->method("txt")
114  ->with("not_numeric_empty_string")
115  ->willReturn("-%s-");
116 
117  $res = $this->c->applyTo($not_ok);
118  $this->assertFalse($res->isOk());
119  }
foreach($_POST as $key=> $value) $res

◆ testRestrictOk()

IsNumericConstraintTest::testRestrictOk ( )

Definition at line 99 of file IsNumericConstraintTest.php.

References $ok, and $res.

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

◆ testWithProblemBuilder()

IsNumericConstraintTest::testWithProblemBuilder ( )

Definition at line 129 of file IsNumericConstraintTest.php.

130  {
131  $new_c = $this->c->withProblemBuilder(function () {
132  return "This was a fault";
133  });
134  $this->assertEquals("This was a fault", $new_c->problemWith(""));
135  }

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