ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
GreaterThanConstraintTest.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
GreatherThanConstraintTest
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->greater_than = 10;
18
19
$this->c = $this->f->greaterThan($this->greater_than);
20
}
21
22
public
function
testAccepts
()
23
{
24
$this->assertTrue($this->c->accepts(12));
25
}
26
27
public
function
testNotAccepts
()
28
{
29
$this->assertFalse($this->c->accepts(2));
30
}
31
32
public
function
testCheckSucceed
()
33
{
34
$this->c->check(12);
35
$this->assertTrue(
true
);
// does not throw
36
}
37
38
public
function
testCheckFails
()
39
{
40
$this->expectException(\UnexpectedValueException::class);
41
$this->c->check(2);
42
}
43
44
public
function
testNoProblemWith
()
45
{
46
$this->assertNull($this->c->problemWith(12));
47
}
48
49
public
function
testProblemWith
()
50
{
51
$this->lng
52
->expects($this->
once
())
53
->method(
"txt"
)
54
->with(
"not_greater_than"
)
55
->willReturn(
"-%s-%s-"
);
56
57
$this->assertEquals(
"-2-10-"
, $this->c->problemWith(2));
58
}
59
60
public
function
testRestrictOk
()
61
{
62
$ok
= $this->df->ok(12);
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(2);
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(2));
90
}
91
}
GreatherThanConstraintTest\testCheckFails
testCheckFails()
Definition:
GreaterThanConstraintTest.php:38
GreatherThanConstraintTest\testRestrictNotOk
testRestrictNotOk()
Definition:
GreaterThanConstraintTest.php:68
GreatherThanConstraintTest\testRestrictOk
testRestrictOk()
Definition:
GreaterThanConstraintTest.php:60
GreatherThanConstraintTest\testNotAccepts
testNotAccepts()
Definition:
GreaterThanConstraintTest.php:27
ILIAS\Validation
Definition:
Constraint.php:5
GreatherThanConstraintTest\testAccepts
testAccepts()
Definition:
GreaterThanConstraintTest.php:22
PHPUnit_Framework_TestCase
GreatherThanConstraintTest
Definition:
GreaterThanConstraintTest.php:9
GreatherThanConstraintTest\testCheckSucceed
testCheckSucceed()
Definition:
GreaterThanConstraintTest.php:32
GreatherThanConstraintTest\testWithProblemBuilder
testWithProblemBuilder()
Definition:
GreaterThanConstraintTest.php:84
GreatherThanConstraintTest\setUp
setUp()
Definition:
GreaterThanConstraintTest.php:11
GreatherThanConstraintTest\testProblemWith
testProblemWith()
Definition:
GreaterThanConstraintTest.php:49
GreatherThanConstraintTest\testRestrictError
testRestrictError()
Definition:
GreaterThanConstraintTest.php:76
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
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
php
GreatherThanConstraintTest\testNoProblemWith
testNoProblemWith()
Definition:
GreaterThanConstraintTest.php:44
ILIAS\Data
Definition:
ClientId.php:4
tests
Validation
Constraints
GreaterThanConstraintTest.php
Generated on Thu Jan 16 2025 19:02:39 for ILIAS by
1.8.13 (using
Doxyfile
)