ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
HasMinLengthConstraintTest Class Reference
+ Inheritance diagram for HasMinLengthConstraintTest:
+ Collaboration diagram for HasMinLengthConstraintTest:

Public Member Functions

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

Protected Member Functions

 setUp ()
 

Private Attributes

DataFactory $df
 
ilLanguage $lng
 
int $min_length
 
Constraint $c
 

Detailed Description

Definition at line 26 of file HasMinLengthConstraintTest.php.

Member Function Documentation

◆ setUp()

HasMinLengthConstraintTest::setUp ( )
protected

Definition at line 33 of file HasMinLengthConstraintTest.php.

References ILIAS\Repository\lng().

33  : void
34  {
35  $this->df = new DataFactory();
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  }
+ Here is the call graph for this function:

◆ testAccepts1()

HasMinLengthConstraintTest::testAccepts1 ( )

Definition at line 47 of file HasMinLengthConstraintTest.php.

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

◆ testAccepts2()

HasMinLengthConstraintTest::testAccepts2 ( )

Definition at line 52 of file HasMinLengthConstraintTest.php.

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

◆ testCheckFails()

HasMinLengthConstraintTest::testCheckFails ( )

Definition at line 68 of file HasMinLengthConstraintTest.php.

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

◆ testCheckSucceed()

HasMinLengthConstraintTest::testCheckSucceed ( )

Definition at line 62 of file HasMinLengthConstraintTest.php.

62  : void
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.

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

◆ testNotAccepts()

HasMinLengthConstraintTest::testNotAccepts ( )

Definition at line 57 of file HasMinLengthConstraintTest.php.

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

◆ testProblemWith()

HasMinLengthConstraintTest::testProblemWith ( )

Definition at line 79 of file HasMinLengthConstraintTest.php.

References ILIAS\Repository\lng().

79  : void
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  }
+ Here is the call graph for this function:

◆ testRestrictError()

HasMinLengthConstraintTest::testRestrictError ( )

Definition at line 106 of file HasMinLengthConstraintTest.php.

References $res.

106  : void
107  {
108  $error = $this->df->error("error");
109 
110  $res = $this->c->applyTo($error);
111  $this->assertSame($error, $res);
112  }
$res
Definition: ltiservices.php:69

◆ testRestrictNotOk()

HasMinLengthConstraintTest::testRestrictNotOk ( )

Definition at line 98 of file HasMinLengthConstraintTest.php.

References $res.

98  : void
99  {
100  $not_ok = $this->df->ok("1234");
101 
102  $res = $this->c->applyTo($not_ok);
103  $this->assertFalse($res->isOk());
104  }
$res
Definition: ltiservices.php:69

◆ testRestrictOk()

HasMinLengthConstraintTest::testRestrictOk ( )

Definition at line 90 of file HasMinLengthConstraintTest.php.

References $res.

90  : void
91  {
92  $ok = $this->df->ok("1234567890");
93 
94  $res = $this->c->applyTo($ok);
95  $this->assertTrue($res->isOk());
96  }
$res
Definition: ltiservices.php:69

◆ testWithProblemBuilder()

HasMinLengthConstraintTest::testWithProblemBuilder ( )

Definition at line 114 of file HasMinLengthConstraintTest.php.

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

Field Documentation

◆ $c

Constraint HasMinLengthConstraintTest::$c
private

Definition at line 31 of file HasMinLengthConstraintTest.php.

◆ $df

DataFactory HasMinLengthConstraintTest::$df
private

Definition at line 28 of file HasMinLengthConstraintTest.php.

◆ $lng

ilLanguage HasMinLengthConstraintTest::$lng
private

Definition at line 29 of file HasMinLengthConstraintTest.php.

◆ $min_length

int HasMinLengthConstraintTest::$min_length
private

Definition at line 30 of file HasMinLengthConstraintTest.php.


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