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

Public Member Functions

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

Detailed Description

Definition at line 9 of file IsStringConstraintTest.php.

Member Function Documentation

◆ setUp()

IsStringConstraintTest::setUp ( )

Definition at line 11 of file IsStringConstraintTest.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->c = $this->f->isString();
18  }

◆ testAccepts()

IsStringConstraintTest::testAccepts ( )

Definition at line 20 of file IsStringConstraintTest.php.

21  {
22  $this->assertTrue($this->c->accepts("string"));
23  }

◆ testCheckFails()

IsStringConstraintTest::testCheckFails ( )

Definition at line 36 of file IsStringConstraintTest.php.

37  {
38  $this->expectException(\UnexpectedValueException::class);
39  $this->c->check(2);
40  }

◆ testCheckSucceed()

IsStringConstraintTest::testCheckSucceed ( )

Definition at line 30 of file IsStringConstraintTest.php.

31  {
32  $this->c->check("string");
33  $this->assertTrue(true); // does not throw
34  }

◆ testNoProblemWith()

IsStringConstraintTest::testNoProblemWith ( )

Definition at line 42 of file IsStringConstraintTest.php.

43  {
44  $this->assertNull($this->c->problemWith("string"));
45  }

◆ testNotAccepts()

IsStringConstraintTest::testNotAccepts ( )

Definition at line 25 of file IsStringConstraintTest.php.

26  {
27  $this->assertFalse($this->c->accepts(2));
28  }

◆ testProblemWith()

IsStringConstraintTest::testProblemWith ( )

Definition at line 47 of file IsStringConstraintTest.php.

References Sabre\Event\once().

48  {
49  $this->lng
50  ->expects($this->once())
51  ->method("txt")
52  ->with("not_a_string")
53  ->willReturn("-%s-");
54 
55  $this->assertEquals("-double-", $this->c->problemWith(2.2));
56  }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
+ Here is the call graph for this function:

◆ testRestrictError()

IsStringConstraintTest::testRestrictError ( )

Definition at line 74 of file IsStringConstraintTest.php.

References $res.

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

◆ testRestrictNotOk()

IsStringConstraintTest::testRestrictNotOk ( )

Definition at line 66 of file IsStringConstraintTest.php.

References $res.

67  {
68  $not_ok = $this->df->ok(2);
69 
70  $res = $this->c->restrict($not_ok);
71  $this->assertFalse($res->isOk());
72  }
foreach($_POST as $key=> $value) $res

◆ testRestrictOk()

IsStringConstraintTest::testRestrictOk ( )

Definition at line 58 of file IsStringConstraintTest.php.

References $ok, and $res.

59  {
60  $ok = $this->df->ok("string");
61 
62  $res = $this->c->restrict($ok);
63  $this->assertTrue($res->isOk());
64  }
foreach($_POST as $key=> $value) $res

◆ testWithProblemBuilder()

IsStringConstraintTest::testWithProblemBuilder ( )

Definition at line 82 of file IsStringConstraintTest.php.

83  {
84  $new_c = $this->c->withProblemBuilder(function () {
85  return "This was a fault";
86  });
87  $this->assertEquals("This was a fault", $new_c->problemWith(2.2));
88  }

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