ILIAS
release_7 Revision v7.30-3-g800a261c036
◀ ilDoc Overview
ilGeoLocationCalculatorTest.php
Go to the documentation of this file.
1
<?php
2
3
use
PHPUnit\Framework\TestCase
;
4
5
class
ilGeoLocationCalculatorTest
extends
TestCase
6
{
7
12
public
function
calculateNearestExpiration_validTime_correctNearestExpired
()
13
{
14
$now = microtime();
15
$before = microtime() - 1000;
16
17
// Arrange
18
$obj1 =
new
ilGeoLocation
(1,
"older"
, 0, 0,
new
\
DateTimeImmutable
($before));
19
$obj2 =
new
ilGeoLocation
(1,
"newer"
, 0, 0,
new
\
DateTimeImmutable
($now));
20
$mocked_repo = $this->createMock(ilGeoLocationRepository::class);
21
$mocked_repo->expects($this->once())
22
->method(
'getGeoLocationsByCoordinates'
)
23
->with(1, 2)
24
->will($this->returnValue(array($obj1, $obj2)));
25
$calc =
new
ilGeoLocationCalculator
($mocked_repo);
26
27
// Act
28
$result
= $calc->calculateNearestExpiration(1, 2);
29
30
// Assert
31
$this->assertEqual(
$result
, $before);
32
}
33
}
ilGeoLocationCalculatorTest
Definition:
ilGeoLocationCalculatorTest.php:5
DateTimeImmutable
$result
$result
Definition:
CleanUpTest.php:463
ilGeoLocationCalculatorTest\calculateNearestExpiration_validTime_correctNearestExpired
calculateNearestExpiration_validTime_correctNearestExpired()
Definition:
ilGeoLocationCalculatorTest.php:12
ilGeoLocation
Definition:
ilGeoLocation.php:3
TestCase
ilGeoLocationCalculator
Definition:
ilGeoLocationCalculator.php:3
docs
development
code-examples
repository-pattern
03_use_for_unit_tests
ilGeoLocationCalculatorTest.php
Generated on Wed Sep 3 2025 21:00:51 for ILIAS by
1.8.13 (using
Doxyfile
)