ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
HasMaxLengthConstraintTest Class Reference
+ Inheritance diagram for HasMaxLengthConstraintTest:
+ Collaboration diagram for HasMaxLengthConstraintTest:

Public Member Functions

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

Protected Member Functions

 setUp ()
 

Private Attributes

DataFactory $df
 
ILIAS Language Language $lng
 
int $max_length
 
Constraint $c
 

Detailed Description

Definition at line 26 of file HasMaxLengthConstraintTest.php.

Member Function Documentation

◆ setUp()

HasMaxLengthConstraintTest::setUp ( )
protected

Definition at line 33 of file HasMaxLengthConstraintTest.php.

References ILIAS\Repository\lng().

33  : void
34  {
35  $this->df = new DataFactory();
36  $this->lng = $this->createMock(ILIAS\Language\Language::class);
37 
38  $this->max_length = 2;
39 
40  $this->c = new HasMaxLength(
41  $this->max_length,
42  $this->df,
43  $this->lng
44  );
45  }
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testAccepts1()

HasMaxLengthConstraintTest::testAccepts1 ( )

Definition at line 47 of file HasMaxLengthConstraintTest.php.

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

◆ testAccepts2()

HasMaxLengthConstraintTest::testAccepts2 ( )

Definition at line 52 of file HasMaxLengthConstraintTest.php.

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

◆ testCheckFails()

HasMaxLengthConstraintTest::testCheckFails ( )

Definition at line 68 of file HasMaxLengthConstraintTest.php.

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

◆ testCheckSucceed()

HasMaxLengthConstraintTest::testCheckSucceed ( )

Definition at line 62 of file HasMaxLengthConstraintTest.php.

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

◆ testNoProblemWith()

HasMaxLengthConstraintTest::testNoProblemWith ( )

Definition at line 74 of file HasMaxLengthConstraintTest.php.

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

◆ testNotAccepts()

HasMaxLengthConstraintTest::testNotAccepts ( )

Definition at line 57 of file HasMaxLengthConstraintTest.php.

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

◆ testProblemWith()

HasMaxLengthConstraintTest::testProblemWith ( )

Definition at line 79 of file HasMaxLengthConstraintTest.php.

References ILIAS\Repository\lng().

79  : void
80  {
81  $this->lng
82  ->expects($this->once())
83  ->method("txt")
84  ->with("not_max_length")
85  ->willReturn("-%s-");
86 
87  $this->assertEquals("-2-", $this->c->problemWith("123"));
88  }
+ Here is the call graph for this function:

◆ testRestrictError()

HasMaxLengthConstraintTest::testRestrictError ( )

Definition at line 106 of file HasMaxLengthConstraintTest.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:66

◆ testRestrictNotOk()

HasMaxLengthConstraintTest::testRestrictNotOk ( )

Definition at line 98 of file HasMaxLengthConstraintTest.php.

References $res.

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

◆ testRestrictOk()

HasMaxLengthConstraintTest::testRestrictOk ( )

Definition at line 90 of file HasMaxLengthConstraintTest.php.

References $res.

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

◆ testWithProblemBuilder()

HasMaxLengthConstraintTest::testWithProblemBuilder ( )

Definition at line 114 of file HasMaxLengthConstraintTest.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("123"));
120  }

Field Documentation

◆ $c

Constraint HasMaxLengthConstraintTest::$c
private

Definition at line 31 of file HasMaxLengthConstraintTest.php.

◆ $df

DataFactory HasMaxLengthConstraintTest::$df
private

Definition at line 28 of file HasMaxLengthConstraintTest.php.

◆ $lng

ILIAS Language Language HasMaxLengthConstraintTest::$lng
private

Definition at line 29 of file HasMaxLengthConstraintTest.php.

◆ $max_length

int HasMaxLengthConstraintTest::$max_length
private

Definition at line 30 of file HasMaxLengthConstraintTest.php.


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