ILIAS  release_7 Revision v7.30-3-g800a261c036
HasMinLengthConstraintTest Class Reference
+ Inheritance diagram for HasMinLengthConstraintTest:
+ Collaboration diagram for HasMinLengthConstraintTest:

Public Member Functions

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

Private Attributes

 $df
 
 $lng
 
 $min_length
 
 $c
 

Detailed Description

Definition at line 11 of file HasMinLengthConstraintTest.php.

Member Function Documentation

◆ setUp()

HasMinLengthConstraintTest::setUp ( )

Definition at line 33 of file HasMinLengthConstraintTest.php.

33 : void
34 {
35 $this->df = new Data\Factory();
36 $this->lng = $this->createMock(\ilLanguage::class);
37
38 $this->min_length = 10;
39
40 $this->c = new HasMinLength(
41 $this->min_length,
42 $this->df,
43 $this->lng
44 );
45 }

◆ testAccepts1()

HasMinLengthConstraintTest::testAccepts1 ( )

Definition at line 47 of file HasMinLengthConstraintTest.php.

48 {
49 $this->assertTrue($this->c->accepts("1234567890"));
50 }

◆ testAccepts2()

HasMinLengthConstraintTest::testAccepts2 ( )

Definition at line 52 of file HasMinLengthConstraintTest.php.

53 {
54 $this->assertTrue($this->c->accepts("12345678901"));
55 }

◆ testCheckFails()

HasMinLengthConstraintTest::testCheckFails ( )

Definition at line 68 of file HasMinLengthConstraintTest.php.

69 {
70 $this->expectException(\UnexpectedValueException::class);
71 $this->c->check("");
72 }

◆ testCheckSucceed()

HasMinLengthConstraintTest::testCheckSucceed ( )

Definition at line 62 of file HasMinLengthConstraintTest.php.

63 {
64 $this->c->check("1234567890");
65 $this->assertTrue(true); // does not throw
66 }

◆ testNoProblemWith()

HasMinLengthConstraintTest::testNoProblemWith ( )

Definition at line 74 of file HasMinLengthConstraintTest.php.

75 {
76 $this->assertNull($this->c->problemWith("1234567890"));
77 }

◆ testNotAccepts()

HasMinLengthConstraintTest::testNotAccepts ( )

Definition at line 57 of file HasMinLengthConstraintTest.php.

58 {
59 $this->assertFalse($this->c->accepts("123456789"));
60 }

◆ testProblemWith()

HasMinLengthConstraintTest::testProblemWith ( )

Definition at line 79 of file HasMinLengthConstraintTest.php.

80 {
81 $this->lng
82 ->expects($this->once())
83 ->method("txt")
84 ->with("not_min_length")
85 ->willReturn("-%s-%s-");
86
87 $this->assertEquals("-3-10-", $this->c->problemWith("123"));
88 }

◆ testRestrictError()

HasMinLengthConstraintTest::testRestrictError ( )

Definition at line 106 of file HasMinLengthConstraintTest.php.

107 {
108 $error = $this->df->error("error");
109
110 $res = $this->c->applyTo($error);
111 $this->assertSame($error, $res);
112 }
foreach($_POST as $key=> $value) $res

References $res.

◆ testRestrictNotOk()

HasMinLengthConstraintTest::testRestrictNotOk ( )

Definition at line 98 of file HasMinLengthConstraintTest.php.

99 {
100 $not_ok = $this->df->ok("1234");
101
102 $res = $this->c->applyTo($not_ok);
103 $this->assertFalse($res->isOk());
104 }

References $res.

◆ testRestrictOk()

HasMinLengthConstraintTest::testRestrictOk ( )

Definition at line 90 of file HasMinLengthConstraintTest.php.

91 {
92 $ok = $this->df->ok("1234567890");
93
94 $res = $this->c->applyTo($ok);
95 $this->assertTrue($res->isOk());
96 }

References $ok, and $res.

◆ testWithProblemBuilder()

HasMinLengthConstraintTest::testWithProblemBuilder ( )

Definition at line 114 of file HasMinLengthConstraintTest.php.

115 {
116 $new_c = $this->c->withProblemBuilder(function () {
117 return "This was a fault";
118 });
119 $this->assertEquals("This was a fault", $new_c->problemWith(""));
120 }

Field Documentation

◆ $c

HasMinLengthConstraintTest::$c
private

Definition at line 31 of file HasMinLengthConstraintTest.php.

◆ $df

HasMinLengthConstraintTest::$df
private

Definition at line 16 of file HasMinLengthConstraintTest.php.

◆ $lng

HasMinLengthConstraintTest::$lng
private

Definition at line 21 of file HasMinLengthConstraintTest.php.

◆ $min_length

HasMinLengthConstraintTest::$min_length
private

Definition at line 26 of file HasMinLengthConstraintTest.php.


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