ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ValidationFactoryTest Class Reference

TestCase for the factory of constraints. More...

+ Inheritance diagram for ValidationFactoryTest:
+ Collaboration diagram for ValidationFactoryTest:

Public Member Functions

 testIsInt ()
 
 testIsNumeric ()
 
 testGreaterThan ()
 
 testLessThan ()
 
 testHasMinLength ()
 
 testCustom ()
 
 testSequential ()
 
 testParallel ()
 
 testNot ()
 
 testLoadsLanguageModule ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Protected Attributes

 $f = null
 

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 14 of file ValidationFactoryTest.php.

Member Function Documentation

◆ setUp()

ValidationFactoryTest::setUp ( )
protected

Definition at line 21 of file ValidationFactoryTest.php.

22  {
23  $this->lng = $this->createMock(\ilLanguage::class);
24  $this->f = new Validation\Factory(new Data\Factory(), $this->lng);
25  }
Builds data types.
Definition: Factory.php:14

◆ tearDown()

ValidationFactoryTest::tearDown ( )
protected

Definition at line 27 of file ValidationFactoryTest.php.

28  {
29  $this->f = null;
30  }

◆ testCustom()

ValidationFactoryTest::testCustom ( )

Definition at line 62 of file ValidationFactoryTest.php.

63  {
64  $custom = $this->f->custom(function ($value) {
65  return "This was fault";
66  }, 5);
67  $this->assertInstanceOf(Validation\Constraint::class, $custom);
68  }

◆ testGreaterThan()

ValidationFactoryTest::testGreaterThan ( )

Definition at line 44 of file ValidationFactoryTest.php.

45  {
46  $gt = $this->f->greaterThan(5);
47  $this->assertInstanceOf(Validation\Constraint::class, $gt);
48  }

◆ testHasMinLength()

ValidationFactoryTest::testHasMinLength ( )

Definition at line 56 of file ValidationFactoryTest.php.

57  {
58  $min = $this->f->hasMinLength(1);
59  $this->assertInstanceOf(Validation\Constraint::class, $min);
60  }

◆ testIsInt()

ValidationFactoryTest::testIsInt ( )

Definition at line 32 of file ValidationFactoryTest.php.

33  {
34  $is_numeric = $this->f->isNumeric();
35  $this->assertInstanceOf(Validation\Constraint::class, $is_numeric);
36  }

◆ testIsNumeric()

ValidationFactoryTest::testIsNumeric ( )

Definition at line 38 of file ValidationFactoryTest.php.

39  {
40  $is_int = $this->f->isInt();
41  $this->assertInstanceOf(Validation\Constraint::class, $is_int);
42  }

◆ testLessThan()

ValidationFactoryTest::testLessThan ( )

Definition at line 50 of file ValidationFactoryTest.php.

51  {
52  $lt = $this->f->lessThan(5);
53  $this->assertInstanceOf(Validation\Constraint::class, $lt);
54  }

◆ testLoadsLanguageModule()

ValidationFactoryTest::testLoadsLanguageModule ( )

Definition at line 99 of file ValidationFactoryTest.php.

References $lng, and Sabre\Event\once().

100  {
101  $lng = $this->createMock(\ilLanguage::class);
102 
103  $lng
104  ->expects($this->once())
105  ->method("loadLanguageModule")
106  ->with(Validation\Factory::LANGUAGE_MODULE);
107 
108  new Validation\Factory(new Data\Factory(), $lng);
109  }
$lng
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
Builds data types.
Definition: Factory.php:14
+ Here is the call graph for this function:

◆ testNot()

ValidationFactoryTest::testNot ( )

Definition at line 92 of file ValidationFactoryTest.php.

93  {
94  $constraint = $this->f->greaterThan(5);
95  $not = $this->f->not($constraint);
96  $this->assertInstanceOf(Validation\Constraint::class, $not);
97  }

◆ testParallel()

ValidationFactoryTest::testParallel ( )

Definition at line 81 of file ValidationFactoryTest.php.

82  {
83  $constraints = array(
84  $this->f->greaterThan(5),
85  $this->f->lessThan(15)
86  );
87 
88  $parallel = $this->f->parallel($constraints);
89  $this->assertInstanceOf(Validation\Constraint::class, $parallel);
90  }

◆ testSequential()

ValidationFactoryTest::testSequential ( )

Definition at line 70 of file ValidationFactoryTest.php.

71  {
72  $constraints = array(
73  $this->f->greaterThan(5),
74  $this->f->lessThan(15)
75  );
76 
77  $sequential = $this->f->sequential($constraints);
78  $this->assertInstanceOf(Validation\Constraint::class, $sequential);
79  }

Field Documentation

◆ $f

ValidationFactoryTest::$f = null
protected

Definition at line 19 of file ValidationFactoryTest.php.


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