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

TestCase for the factory of constraints. More...

+ Inheritance diagram for ParallelTest:
+ Collaboration diagram for ParallelTest:

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 ParallelTest.php.

Member Function Documentation

◆ setUp()

ParallelTest::setUp ( )
protected

Definition at line 15 of file ParallelTest.php.

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

◆ tearDown()

ParallelTest::tearDown ( )
protected

Definition at line 20 of file ParallelTest.php.

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

◆ testAccept()

ParallelTest::testAccept ( )

Definition at line 25 of file ParallelTest.php.

26 {
27 $constraint = $this->f->parallel(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 }

◆ testCheck()

ParallelTest::testCheck ( )

Definition at line 33 of file ParallelTest.php.

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 $constraint = $this->f->parallel(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(1)));
47 try {
48 $constraint->check(2);
49 $raised = false;
50 } catch (UnexpectedValueException $e) {
51 $this->assertEquals("'2' is not greater than '3'.'2' is greater than '1'.", $e->getMessage());
52 $raised = true;
53 }
54
55 $this->assertTrue($raised);
56 }

◆ testCorrectErrorMessagesAfterMultiAccept()

ParallelTest::testCorrectErrorMessagesAfterMultiAccept ( )

Definition at line 98 of file ParallelTest.php.

99 {
100 $constraint = $this->f->parallel(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(2)));
101 $constraint->accepts(1);
102 $constraint->accepts(3);
103 $constraint->accepts(4);
104
105 $this->assertEquals("'1' is not greater than '3'.", $constraint->problemWith(1));
106 $this->assertEquals("'3' is not greater than '3'.'3' is greater than '2'.", $constraint->problemWith(3));
107 $this->assertEquals("'4' is greater than '2'.", $constraint->problemWith(4));
108 }

◆ testProblemWith()

ParallelTest::testProblemWith ( )

Definition at line 58 of file ParallelTest.php.

59 {
60 $constraint = $this->f->parallel(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
61
62 $this->assertNull($constraint->problemWith(4));
63
64 $constraint = $this->f->parallel(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(1)));
65 $this->assertInternalType("string", $constraint->problemWith(2));
66 $this->assertEquals("'2' is not greater than '3'.'2' is greater than '1'.", $constraint->problemWith(2));
67 }

◆ testRestrict()

ParallelTest::testRestrict ( )

Definition at line 69 of file ParallelTest.php.

70 {
71 $constraint = $this->f->parallel(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
72
73 $rf = new Data\Factory();
74 $ok = $rf->ok(4);
75 $ok2 = $rf->ok(2);
76 $error = $rf->error("text");
77
78 $result = $constraint->restrict($ok);
79 $this->assertTrue($result->isOk());
80
81 $result = $constraint->restrict($ok2);
82 $this->assertTrue($result->isError());
83
84 $result = $constraint->restrict($error);
85 $this->assertSame($error, $result);
86 }
$result
$error
Definition: Error.php:17

References $error, $ok, and $result.

◆ testWithProblemBuilder()

ParallelTest::testWithProblemBuilder ( )

Definition at line 88 of file ParallelTest.php.

89 {
90 $constraint = $this->f->parallel(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(1)));
91
92 $new_constraint = $constraint->withProblemBuilder(function () {
93 return "This was a vault";
94 });
95 $this->assertEquals("This was a vault", $new_constraint->problemWith(2));
96 }

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