ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
IsIntConstraintTest.php
Go to the documentation of this file.
1
<?
php
2
3
/* Copyright (c) 2018 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
require_once(
"libs/composer/vendor/autoload.php"
);
5
6
use
ILIAS\Validation
;
7
use
ILIAS\Data
;
8
9
class
IsIntConstraintTest
extends
PHPUnit_Framework_TestCase
10
{
11
public
function
setUp
()
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->isInt();
18
}
19
20
public
function
testAccepts
()
21
{
22
$this->assertTrue($this->c->accepts(2));
23
}
24
25
public
function
testNotAccepts
()
26
{
27
$this->assertFalse($this->c->accepts(2.2));
28
}
29
30
public
function
testCheckSucceed
()
31
{
32
$this->c->check(2);
33
$this->assertTrue(
true
);
// does not throw
34
}
35
36
public
function
testCheckFails
()
37
{
38
$this->expectException(\UnexpectedValueException::class);
39
$this->c->check(2.2);
40
}
41
42
public
function
testNoProblemWith
()
43
{
44
$this->assertNull($this->c->problemWith(2));
45
}
46
47
public
function
testProblemWith
()
48
{
49
$this->lng
50
->expects($this->
once
())
51
->method(
"txt"
)
52
->with(
"not_an_int"
)
53
->willReturn(
"-%s-"
);
54
55
$this->assertEquals(
"-2.2-"
, $this->c->problemWith(2.2));
56
}
57
58
public
function
testRestrictOk
()
59
{
60
$ok
= $this->df->ok(2);
61
62
$res
= $this->c->restrict(
$ok
);
63
$this->assertTrue(
$res
->isOk());
64
}
65
66
public
function
testRestrictNotOk
()
67
{
68
$not_ok = $this->df->ok(2.2);
69
70
$res
= $this->c->restrict($not_ok);
71
$this->assertFalse(
$res
->isOk());
72
}
73
74
public
function
testRestrictError
()
75
{
76
$error = $this->df->error(
"error"
);
77
78
$res
= $this->c->restrict($error);
79
$this->assertSame($error,
$res
);
80
}
81
82
public
function
testWithProblemBuilder
()
83
{
84
$new_c = $this->c->withProblemBuilder(
function
() {
85
return
"This was a fault"
;
86
});
87
$this->assertEquals(
"This was a fault"
, $new_c->problemWith(2.2));
88
}
89
}
IsIntConstraintTest\testWithProblemBuilder
testWithProblemBuilder()
Definition:
IsIntConstraintTest.php:82
IsIntConstraintTest\testNotAccepts
testNotAccepts()
Definition:
IsIntConstraintTest.php:25
ILIAS\Validation
Definition:
Constraint.php:5
IsIntConstraintTest\setUp
setUp()
Definition:
IsIntConstraintTest.php:11
IsIntConstraintTest
Definition:
IsIntConstraintTest.php:9
PHPUnit_Framework_TestCase
IsIntConstraintTest\testProblemWith
testProblemWith()
Definition:
IsIntConstraintTest.php:47
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
IsIntConstraintTest\testRestrictNotOk
testRestrictNotOk()
Definition:
IsIntConstraintTest.php:66
IsIntConstraintTest\testCheckFails
testCheckFails()
Definition:
IsIntConstraintTest.php:36
Sabre\Event\once
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
Definition:
EventEmitterTrait.php:59
$ok
$ok
Definition:
UtfNormalTest.php:80
IsIntConstraintTest\testRestrictError
testRestrictError()
Definition:
IsIntConstraintTest.php:74
IsIntConstraintTest\testCheckSucceed
testCheckSucceed()
Definition:
IsIntConstraintTest.php:30
IsIntConstraintTest\testAccepts
testAccepts()
Definition:
IsIntConstraintTest.php:20
php
IsIntConstraintTest\testRestrictOk
testRestrictOk()
Definition:
IsIntConstraintTest.php:58
IsIntConstraintTest\testNoProblemWith
testNoProblemWith()
Definition:
IsIntConstraintTest.php:42
ILIAS\Data
Definition:
ClientId.php:4
tests
Validation
Constraints
IsIntConstraintTest.php
Generated on Thu Jan 16 2025 19:02:39 for ILIAS by
1.8.13 (using
Doxyfile
)