ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ValidationFactoryTest.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2017 Stefan Hecken <stefan.hecken@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
6 use ILIAS\Data;
7 
14 {
15  protected function setUp()
16  {
17  $this->f = new Validation\Factory(new Data\Factory());
18  }
19 
20  protected function tearDown()
21  {
22  $this->f = null;
23  }
24 
25  public function testIsInt()
26  {
27  $is_int = $this->f->isInt();
28  $this->assertInstanceOf(Validation\Constraint::class, $is_int);
29  }
30 
31  public function testGreaterThan()
32  {
33  $gt = $this->f->greaterThan(5);
34  $this->assertInstanceOf(Validation\Constraint::class, $gt);
35  }
36 
37  public function testLessThan()
38  {
39  $lt = $this->f->lessThan(5);
40  $this->assertInstanceOf(Validation\Constraint::class, $lt);
41  }
42 
43  public function testCustom()
44  {
45  $custom = $this->f->custom(function ($value) {
46  return "This was fault";
47  }, 5);
48  $this->assertInstanceOf(Validation\Constraint::class, $custom);
49  }
50 
51  public function testSequential()
52  {
53  $constraints = array(
54  $this->f->greaterThan(5),
55  $this->f->lessThan(15)
56  );
57 
58  $sequential = $this->f->sequential($constraints);
59  $this->assertInstanceOf(Validation\Constraint::class, $sequential);
60  }
61 
62  public function testParallel()
63  {
64  $constraints = array(
65  $this->f->greaterThan(5),
66  $this->f->lessThan(15)
67  );
68 
69  $parallel = $this->f->parallel($constraints);
70  $this->assertInstanceOf(Validation\Constraint::class, $parallel);
71  }
72 
73  public function testNot()
74  {
75  $constraint = $this->f->greaterThan(5);
76  $not = $this->f->not($constraint);
77  $this->assertInstanceOf(Validation\Constraint::class, $not);
78  }
79 }
Builds data types.
Definition: Factory.php:14
Create styles array
The data for the language used.
TestCase for the factory of constraints.