ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LessThanConstraintTest Class Reference
+ Inheritance diagram for LessThanConstraintTest:
+ Collaboration diagram for LessThanConstraintTest:

Public Member Functions

 setUp ()
 
 testAccepts ()
 
 testNotAccepts ()
 
 testCheckSucceed ()
 
 testCheckFails ()
 
 testNoProblemWith ()
 
 testProblemWith ()
 
 testRestrictOk ()
 
 testRestrictNotOk ()
 
 testRestrictError ()
 
 testWithProblemBuilder ()
 

Detailed Description

Definition at line 9 of file LessThanConstraintTest.php.

Member Function Documentation

◆ setUp()

LessThanConstraintTest::setUp ( )

Definition at line 11 of file LessThanConstraintTest.php.

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 }

◆ testAccepts()

LessThanConstraintTest::testAccepts ( )

Definition at line 22 of file LessThanConstraintTest.php.

23 {
24 $this->assertTrue($this->c->accepts(2));
25 }

◆ testCheckFails()

LessThanConstraintTest::testCheckFails ( )

Definition at line 38 of file LessThanConstraintTest.php.

39 {
40 $this->expectException(\UnexpectedValueException::class);
41 $this->c->check(11);
42 }

◆ testCheckSucceed()

LessThanConstraintTest::testCheckSucceed ( )

Definition at line 32 of file LessThanConstraintTest.php.

33 {
34 $this->c->check(2);
35 $this->assertTrue(true); // does not throw
36 }

◆ testNoProblemWith()

LessThanConstraintTest::testNoProblemWith ( )

Definition at line 44 of file LessThanConstraintTest.php.

45 {
46 $this->assertNull($this->c->problemWith(1));
47 }

◆ testNotAccepts()

LessThanConstraintTest::testNotAccepts ( )

Definition at line 27 of file LessThanConstraintTest.php.

28 {
29 $this->assertFalse($this->c->accepts(10));
30 }

◆ testProblemWith()

LessThanConstraintTest::testProblemWith ( )

Definition at line 49 of file LessThanConstraintTest.php.

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 }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.

References Sabre\Event\once().

+ Here is the call graph for this function:

◆ testRestrictError()

LessThanConstraintTest::testRestrictError ( )

Definition at line 76 of file LessThanConstraintTest.php.

77 {
78 $error = $this->df->error("error");
79
80 $res = $this->c->restrict($error);
81 $this->assertSame($error, $res);
82 }
foreach($_POST as $key=> $value) $res

References $res.

◆ testRestrictNotOk()

LessThanConstraintTest::testRestrictNotOk ( )

Definition at line 68 of file LessThanConstraintTest.php.

69 {
70 $not_ok = $this->df->ok(1234);
71
72 $res = $this->c->restrict($not_ok);
73 $this->assertFalse($res->isOk());
74 }

References $res.

◆ testRestrictOk()

LessThanConstraintTest::testRestrictOk ( )

Definition at line 60 of file LessThanConstraintTest.php.

61 {
62 $ok = $this->df->ok(1);
63
64 $res = $this->c->restrict($ok);
65 $this->assertTrue($res->isOk());
66 }

References $ok, and $res.

◆ testWithProblemBuilder()

LessThanConstraintTest::testWithProblemBuilder ( )

Definition at line 84 of file LessThanConstraintTest.php.

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 }

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