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