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

TestCase for the factory of constraints. More...

+ Inheritance diagram for NotTest:
+ Collaboration diagram for NotTest:

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

Member Function Documentation

◆ constraintsProvider()

NotTest::constraintsProvider ( )

Definition at line 89 of file NotTest.php.

References array.

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

◆ testAccept()

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

constraintsProvider

Definition at line 18 of file NotTest.php.

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

◆ testCheck()

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

constraintsProvider

Definition at line 27 of file NotTest.php.

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

◆ testProblemWith()

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

constraintsProvider

Definition at line 52 of file NotTest.php.

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

◆ testRestrict()

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

constraintsProvider

Definition at line 61 of file NotTest.php.

References $error, $ok, and $result.

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

◆ testWithProblemBuilder()

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

constraintsProvider

Definition at line 81 of file NotTest.php.

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

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