ILIAS  trunk Revision v11.0_alpha-2658-ge2404539063
RangeTest Class Reference
+ Inheritance diagram for RangeTest:
+ Collaboration diagram for RangeTest:

Public Member Functions

 testFactory ()
 
 testValues (Range $range)
 
 testEndCalculation (Range $range)
 
 testWithLength (Range $range)
 
 testWithStart (Range $range)
 
 testUnpack (Range $range)
 
 testNegativeStart (Range $range)
 
 testNegativeLength (Range $range)
 
 testConstructionWrongStart ()
 
 testConstructionWrongLength ()
 
 testCroppedTo ($start, $length, $max, $has_changed)
 

Static Public Member Functions

static cropCases ()
 

Detailed Description

Member Function Documentation

◆ cropCases()

static RangeTest::cropCases ( )
static

Definition at line 122 of file RangeTest.php.

122  : array
123  {
124  return [
125  [0, 100, 1000, false],
126  [0, 1000, 100, true],
127  [50, 100, 75, true],
128  [50, 100, 200, false],
129  [100, 100, 50, true]
130  ];
131  }

◆ testConstructionWrongLength()

RangeTest::testConstructionWrongLength ( )

Definition at line 100 of file RangeTest.php.

References Vendor\Package\$f, and ILIAS\UI\Implementation\Component\Table\$range.

100  : void
101  {
102  $this->expectException(InvalidArgumentException::class);
103  $f = new ILIAS\Data\Factory();
104  $range = $f->range(1, -2);
105  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testConstructionWrongStart()

RangeTest::testConstructionWrongStart ( )

Definition at line 93 of file RangeTest.php.

References Vendor\Package\$f, and ILIAS\UI\Implementation\Component\Table\$range.

93  : void
94  {
95  $this->expectException(InvalidArgumentException::class);
96  $f = new ILIAS\Data\Factory();
97  $range = $f->range(-1, 2);
98  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testCroppedTo()

RangeTest::testCroppedTo (   $start,
  $length,
  $max,
  $has_changed 
)

Definition at line 108 of file RangeTest.php.

References Vendor\Package\$f, ILIAS\UI\Implementation\Component\Table\$range, and ILIAS\Data\Range\croppedTo().

108  : void
109  {
110  $f = new ILIAS\Data\Factory();
111  $range = $f->range($start, $length);
112  $cropped = $range->croppedTo($max);
113 
114  if (!$has_changed) {
115  $this->assertEquals($range, $cropped);
116  } else {
117  $this->assertEquals(min($max, $start), $cropped->getStart());
118  $this->assertEquals($max, $cropped->getEnd());
119  }
120  }
croppedTo(int $max)
This will create a range that is guaranteed to not exceed $max.
Definition: Range.php:98
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testEndCalculation()

RangeTest::testEndCalculation ( Range  $range)

Definition at line 45 of file RangeTest.php.

References ILIAS\Data\Range\getEnd().

45  : void
46  {
47  $this->assertEquals(3, $range->getEnd());
48  }
+ Here is the call graph for this function:

◆ testFactory()

RangeTest::testFactory ( )

Definition at line 29 of file RangeTest.php.

References Vendor\Package\$f, and ILIAS\UI\Implementation\Component\Table\$range.

29  : Range
30  {
31  $f = new ILIAS\Data\Factory();
32  $range = $f->range(1, 2);
33  $this->assertInstanceOf(Range::class, $range);
34  return $range;
35  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28

◆ testNegativeLength()

RangeTest::testNegativeLength ( Range  $range)

Definition at line 87 of file RangeTest.php.

References ILIAS\Data\Range\withLength().

87  : void
88  {
89  $this->expectException(InvalidArgumentException::class);
90  $range = $range->withLength(-1);
91  }
withLength(int $length)
Definition: Range.php:87
+ Here is the call graph for this function:

◆ testNegativeStart()

RangeTest::testNegativeStart ( Range  $range)

Definition at line 80 of file RangeTest.php.

References ILIAS\Data\Range\withStart().

80  : void
81  {
82  $this->expectException(InvalidArgumentException::class);
83  $range = $range->withStart(-5);
84  }
withStart(int $start)
Definition: Range.php:79
+ Here is the call graph for this function:

◆ testUnpack()

RangeTest::testUnpack ( Range  $range)

Definition at line 71 of file RangeTest.php.

References ILIAS\Data\Range\unpack().

71  : void
72  {
73  $this->assertEquals(
74  [3,3],
75  $range->unpack()
76  );
77  }
+ Here is the call graph for this function:

◆ testValues()

RangeTest::testValues ( Range  $range)

Definition at line 38 of file RangeTest.php.

References ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

38  : void
39  {
40  $this->assertEquals(1, $range->getStart());
41  $this->assertEquals(2, $range->getLength());
42  }
+ Here is the call graph for this function:

◆ testWithLength()

RangeTest::testWithLength ( Range  $range)

Definition at line 51 of file RangeTest.php.

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getEnd(), ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), and ILIAS\Data\Range\withLength().

51  : Range
52  {
53  $range = $range->withLength(3);
54  $this->assertEquals(1, $range->getStart());
55  $this->assertEquals(3, $range->getLength());
56  $this->assertEquals(4, $range->getEnd());
57  return $range;
58  }
withLength(int $length)
Definition: Range.php:87
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28
+ Here is the call graph for this function:

◆ testWithStart()

RangeTest::testWithStart ( Range  $range)

Definition at line 61 of file RangeTest.php.

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getEnd(), ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), and ILIAS\Data\Range\withStart().

61  : Range
62  {
63  $range = $range->withStart(3);
64  $this->assertEquals(3, $range->getStart());
65  $this->assertEquals(3, $range->getLength());
66  $this->assertEquals(6, $range->getEnd());
67  return $range;
68  }
withStart(int $start)
Definition: Range.php:79
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28
+ Here is the call graph for this function:

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