TestCase for the factory of constraints.
More...
◆ setUp()
SequentialTest::setUp |
( |
| ) |
|
|
protected |
◆ tearDown()
SequentialTest::tearDown |
( |
| ) |
|
|
protected |
◆ testAccept()
SequentialTest::testAccept |
( |
| ) |
|
Definition at line 25 of file SequentialTest.php.
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 }
◆ testCheck()
SequentialTest::testCheck |
( |
| ) |
|
Definition at line 33 of file SequentialTest.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 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 }
◆ testCorrectErrorMessagesAfterMultiAccept()
SequentialTest::testCorrectErrorMessagesAfterMultiAccept |
( |
| ) |
|
Definition at line 94 of file SequentialTest.php.
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 }
◆ testProblemWith()
SequentialTest::testProblemWith |
( |
| ) |
|
Definition at line 57 of file SequentialTest.php.
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 }
◆ testRestrict()
SequentialTest::testRestrict |
( |
| ) |
|
Definition at line 65 of file SequentialTest.php.
66 {
67 $constraint = $this->f->sequential(array($this->f->isInt(), $this->f->greaterThan(3), $this->f->lessThan(5)));
68
69 $rf = new Data\Factory();
71 $ok2 = $rf->ok(2);
72 $error = $rf->error(
"text");
73
75 $this->assertTrue(
$result->isOk());
76
77 $result = $constraint->restrict($ok2);
78 $this->assertTrue(
$result->isError());
79
82 }
References $error, $ok, and $result.
◆ testWithProblemBuilder()
SequentialTest::testWithProblemBuilder |
( |
| ) |
|
Definition at line 84 of file SequentialTest.php.
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 }
The documentation for this class was generated from the following file: