4require_once(
"libs/composer/vendor/autoload.php");
8use PHPUnit\Framework\TestCase;
15 $this->lng = $this->createMock(\ilLanguage::class);
16 $this->f =
new Factory($this->df, $this->lng);
18 $this->c = $this->f->numeric()->isNumeric();
23 $this->assertTrue($this->c->accepts(0));
28 $this->assertTrue($this->c->accepts(
"1"));
33 $this->assertTrue($this->c->accepts(1));
38 $this->assertTrue($this->c->accepts(0x102));
43 $this->assertTrue($this->c->accepts(0102));
48 $this->assertTrue($this->c->accepts(0b101));
53 $this->assertTrue($this->c->accepts(192e0));
58 $this->assertTrue($this->c->accepts(9.1));
63 $this->assertFalse($this->c->accepts(
null));
68 $this->assertFalse($this->c->accepts(
"foo"));
74 $this->assertTrue(
true);
79 $this->expectException(\UnexpectedValueException::class);
85 $this->assertNull($this->c->problemWith(2));
91 ->expects($this->once())
96 $this->assertEquals(
"-aa-", $this->c->problemWith(
"aa"));
101 $ok = $this->df->ok(2);
104 $this->assertTrue(
$res->isOk());
109 $not_ok = $this->df->ok(
"");
112 ->expects($this->once())
114 ->with(
"not_numeric_empty_string")
115 ->willReturn(
"-%s-");
117 $res = $this->c->applyTo($not_ok);
118 $this->assertFalse(
$res->isOk());
123 $error = $this->df->error(
"error");
125 $res = $this->c->applyTo($error);
126 $this->assertSame($error,
$res);
131 $new_c = $this->c->withProblemBuilder(
function () {
132 return "This was a fault";
134 $this->assertEquals(
"This was a fault", $new_c->problemWith(
""));
An exception for terminatinating execution or to throw for unit testing.
foreach($_POST as $key=> $value) $res