ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SequentialTest Class Reference

TestCase for the factory of constraints. More...

+ Inheritance diagram for SequentialTest:
+ Collaboration diagram for SequentialTest:

Public Member Functions

 testAccept ()
 
 testCheck ()
 
 testProblemWith ()
 
 testRestrict ()
 
 testWithProblemBuilder ()
 
 testCorrectErrorMessagesAfterMultiAccept ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Detailed Description

TestCase for the factory of constraints.

Author
Stefan Hecken stefa.nosp@m.n.he.nosp@m.cken@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de

Definition at line 13 of file SequentialTest.php.

Member Function Documentation

◆ setUp()

SequentialTest::setUp ( )
protected

Definition at line 15 of file SequentialTest.php.

16  {
17  $this->f = new Validation\Factory(new Data\Factory());
18  }
Builds data types.
Definition: Factory.php:14

◆ tearDown()

SequentialTest::tearDown ( )
protected

Definition at line 20 of file SequentialTest.php.

21  {
22  $this->f = null;
23  }

◆ testAccept()

SequentialTest::testAccept ( )

Definition at line 25 of file SequentialTest.php.

References array.

26  {
27  $constraint = $this->f->sequential(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
28 
29  $this->assertTrue($constraint->accepts(4));
30  $this->assertFalse($constraint->accepts(2));
31  }
Create styles array
The data for the language used.

◆ testCheck()

SequentialTest::testCheck ( )

Definition at line 33 of file SequentialTest.php.

References array.

34  {
35  $constraint = $this->f->sequential(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
36  $raised = false;
37 
38  try {
39  $constraint->check(4);
40  } catch (UnexpectedValueException $e) {
41  $raised = true;
42  }
43 
44  $this->assertFalse($raised);
45 
46  try {
47  $constraint->check(2);
48  $raised = false;
49  } catch (UnexpectedValueException $e) {
50  $this->assertEquals("'2' is not greater than '3'.", $e->getMessage());
51  $raised = true;
52  }
53 
54  $this->assertTrue($raised);
55  }
Create styles array
The data for the language used.

◆ testCorrectErrorMessagesAfterMultiAccept()

SequentialTest::testCorrectErrorMessagesAfterMultiAccept ( )

Definition at line 94 of file SequentialTest.php.

References array.

95  {
96  $constraint = $this->f->sequential(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(2)));
97  $constraint->accepts("A");
98  $constraint->accepts(2);
99  $constraint->accepts(4);
100 
101  $this->assertEquals("'string' is not an integer.", $constraint->problemWith("A"));
102  $this->assertEquals("'2' is not greater than '3'.", $constraint->problemWith(2));
103  $this->assertEquals("'4' is greater than '2'.", $constraint->problemWith(4));
104  }
Create styles array
The data for the language used.

◆ testProblemWith()

SequentialTest::testProblemWith ( )

Definition at line 57 of file SequentialTest.php.

References array.

58  {
59  $constraint = $this->f->sequential(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
60 
61  $this->assertNull($constraint->problemWith(4));
62  $this->assertInternalType("string", $constraint->problemWith(2));
63  }
Create styles array
The data for the language used.

◆ testRestrict()

SequentialTest::testRestrict ( )

Definition at line 65 of file SequentialTest.php.

References $error, $ok, $result, and array.

66  {
67  $constraint = $this->f->sequential(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
68 
69  $rf = new Data\Factory();
70  $ok = $rf->ok(4);
71  $ok2 = $rf->ok(2);
72  $error = $rf->error("text");
73 
74  $result = $constraint->restrict($ok);
75  $this->assertTrue($result->isOk());
76 
77  $result = $constraint->restrict($ok2);
78  $this->assertTrue($result->isError());
79 
80  $result = $constraint->restrict($error);
81  $this->assertSame($error, $result);
82  }
$result
$error
Definition: Error.php:17
Create styles array
The data for the language used.

◆ testWithProblemBuilder()

SequentialTest::testWithProblemBuilder ( )

Definition at line 84 of file SequentialTest.php.

References array.

85  {
86  $constraint = $this->f->sequential(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
87 
88  $new_constraint = $constraint->withProblemBuilder(function () {
89  return "This was a vault";
90  });
91  $this->assertEquals("This was a vault", $new_constraint->problemWith(2));
92  }
Create styles array
The data for the language used.

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