ILIAS  release_8 Revision v8.24
RangeTest Class Reference
+ Inheritance diagram for RangeTest:
+ Collaboration diagram for RangeTest:

Public Member Functions

 testFactory ()
 
 testValues (Range $range)
 @depends testFactory More...
 
 testEndCalculation (Range $range)
 @depends testFactory More...
 
 testWithLength (Range $range)
 @depends testFactory More...
 
 testWithStart (Range $range)
 @depends testWithLength More...
 
 testUnpack (Range $range)
 @depends testWithStart More...
 
 testNegativeStart (Range $range)
 @depends testFactory More...
 
 testNegativeLength (Range $range)
 @depends testFactory More...
 
 testConstructionWrongStart ()
 
 testConstructionWrongLength ()
 
 testCroppedTo ($start, $length, $max, $has_changed)
 @dataProvider cropCases More...
 
 cropCases ()
 

Detailed Description

Member Function Documentation

◆ cropCases()

RangeTest::cropCases ( )

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 98 of file RangeTest.php.

98 : void
99 {
100 $this->expectException(InvalidArgumentException::class);
101 $f = new ILIAS\Data\Factory();
102 $range = $f->range(1, -2);
103 }
Builds data types.
Definition: Factory.php:21

References Vendor\Package\$f.

◆ testConstructionWrongStart()

RangeTest::testConstructionWrongStart ( )

Definition at line 91 of file RangeTest.php.

91 : void
92 {
93 $this->expectException(InvalidArgumentException::class);
94 $f = new ILIAS\Data\Factory();
95 $range = $f->range(-1, 2);
96 }

References Vendor\Package\$f.

◆ testCroppedTo()

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

@dataProvider cropCases

Definition at line 108 of file RangeTest.php.

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 }

References Vendor\Package\$f.

◆ testEndCalculation()

RangeTest::testEndCalculation ( Range  $range)

@depends testFactory

Definition at line 33 of file RangeTest.php.

33 : void
34 {
35 $this->assertEquals(3, $range->getEnd());
36 }
getEnd()
getEnd will return the (excluded) endpoint.
Definition: Range.php:76

References ILIAS\Data\Range\getEnd().

+ Here is the call graph for this function:

◆ testFactory()

RangeTest::testFactory ( )

Definition at line 13 of file RangeTest.php.

13 : Range
14 {
15 $f = new ILIAS\Data\Factory();
16 $range = $f->range(1, 2);
17 $this->assertInstanceOf(Range::class, $range);
18 return $range;
19 }
A simple class to express a range of whole positive numbers.
Definition: Range.php:31

References Vendor\Package\$f.

◆ testNegativeLength()

RangeTest::testNegativeLength ( Range  $range)

@depends testFactory

Definition at line 85 of file RangeTest.php.

85 : void
86 {
87 $this->expectException(InvalidArgumentException::class);
88 $range = $range->withLength(-1);
89 }
withLength(int $length)
Definition: Range.php:93

References ILIAS\Data\Range\withLength().

+ Here is the call graph for this function:

◆ testNegativeStart()

RangeTest::testNegativeStart ( Range  $range)

@depends testFactory

Definition at line 76 of file RangeTest.php.

76 : void
77 {
78 $this->expectException(InvalidArgumentException::class);
79 $range = $range->withStart(-5);
80 }
withStart(int $start)
Definition: Range.php:85

References ILIAS\Data\Range\withStart().

+ Here is the call graph for this function:

◆ testUnpack()

RangeTest::testUnpack ( Range  $range)

@depends testWithStart

Definition at line 65 of file RangeTest.php.

65 : void
66 {
67 $this->assertEquals(
68 [3,3],
69 $range->unpack()
70 );
71 }

References ILIAS\Data\Range\unpack().

+ Here is the call graph for this function:

◆ testValues()

RangeTest::testValues ( Range  $range)

@depends testFactory

Definition at line 24 of file RangeTest.php.

24 : void
25 {
26 $this->assertEquals(1, $range->getStart());
27 $this->assertEquals(2, $range->getLength());
28 }

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

+ Here is the call graph for this function:

◆ testWithLength()

RangeTest::testWithLength ( Range  $range)

@depends testFactory

Definition at line 41 of file RangeTest.php.

41 : Range
42 {
43 $range = $range->withLength(3);
44 $this->assertEquals(1, $range->getStart());
45 $this->assertEquals(3, $range->getLength());
46 $this->assertEquals(4, $range->getEnd());
47 return $range;
48 }

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

+ Here is the call graph for this function:

◆ testWithStart()

RangeTest::testWithStart ( Range  $range)

@depends testWithLength

Definition at line 53 of file RangeTest.php.

53 : Range
54 {
55 $range = $range->withStart(3);
56 $this->assertEquals(3, $range->getStart());
57 $this->assertEquals(3, $range->getLength());
58 $this->assertEquals(6, $range->getEnd());
59 return $range;
60 }

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

+ Here is the call graph for this function:

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