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

TestCase for the factory of constraints. More...

+ Inheritance diagram for IntConstraintsTest:
+ Collaboration diagram for IntConstraintsTest:

Public Member Functions

 testAccept ($constraint, $ok_value, $error_value)
 constraintsProvider More...
 
 testCheck ($constraint, $ok_value, $error_value)
 constraintsProvider More...
 
 testProblemWith ($constraint, $ok_value, $error_value)
 constraintsProvider More...
 
 testRestrict ($constraint, $ok_value, $error_value)
 constraintsProvider More...
 
 testWithProblemBuilder ($constraint, $ok_value, $error_value)
 constraintsProvider More...
 
 constraintsProvider ()
 

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

Member Function Documentation

◆ constraintsProvider()

IntConstraintsTest::constraintsProvider ( )

Definition at line 87 of file IntConstraintsTest.php.

References array.

88  {
89  $f = new Validation\Factory(new Data\Factory());
90 
91  return array(array($f->isInt(), 2, 2.2),
92  array($f->greaterThan(5), 6, 4),
93  array($f->lessThan(5), 4, 6)
94  );
95  }
Builds data types.
Definition: Factory.php:14
Create styles array
The data for the language used.

◆ testAccept()

IntConstraintsTest::testAccept (   $constraint,
  $ok_value,
  $error_value 
)

constraintsProvider

Definition at line 18 of file IntConstraintsTest.php.

19  {
20  $this->assertTrue($constraint->accepts($ok_value));
21  $this->assertFalse($constraint->accepts($error_value));
22  }

◆ testCheck()

IntConstraintsTest::testCheck (   $constraint,
  $ok_value,
  $error_value 
)

constraintsProvider

Definition at line 27 of file IntConstraintsTest.php.

28  {
29  $raised = false;
30  try {
31  $constraint->check($ok_value);
32  } catch (UnexpectedValueException $e) {
33  $raised = true;
34  }
35 
36  $this->assertFalse($raised);
37 
38  try {
39  $constraint->check($error_value);
40  } catch (UnexpectedValueException $e) {
41  $raised = true;
42  }
43 
44  $this->assertTrue($raised);
45  }

◆ testProblemWith()

IntConstraintsTest::testProblemWith (   $constraint,
  $ok_value,
  $error_value 
)

constraintsProvider

Definition at line 50 of file IntConstraintsTest.php.

51  {
52  $this->assertNull($constraint->problemWith($ok_value));
53  $this->assertInternalType("string", $constraint->problemWith($error_value));
54  }

◆ testRestrict()

IntConstraintsTest::testRestrict (   $constraint,
  $ok_value,
  $error_value 
)

constraintsProvider

Definition at line 59 of file IntConstraintsTest.php.

References $error, $ok, and $result.

60  {
61  $rf = new Data\Factory();
62  $ok = $rf->ok($ok_value);
63  $ok2 = $rf->ok($error_value);
64  $error = $rf->error("text");
65 
66  $result = $constraint->restrict($ok);
67  $this->assertTrue($result->isOk());
68 
69  $result = $constraint->restrict($ok2);
70  $this->assertTrue($result->isError());
71 
72  $result = $constraint->restrict($error);
73  $this->assertSame($error, $result);
74  }
$result
$error
Definition: Error.php:17

◆ testWithProblemBuilder()

IntConstraintsTest::testWithProblemBuilder (   $constraint,
  $ok_value,
  $error_value 
)

constraintsProvider

Definition at line 79 of file IntConstraintsTest.php.

80  {
81  $new_constraint = $constraint->withProblemBuilder(function () {
82  return "This was a vault";
83  });
84  $this->assertEquals("This was a vault", $new_constraint->problemWith($error_value));
85  }

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