ILIAS  release_7 Revision v7.30-3-g800a261c036
ilGeoLocationCalculatorTest.php
Go to the documentation of this file.
1<?php
2
3use PHPUnit\Framework\TestCase;
4
5class ilGeoLocationCalculatorTest extends TestCase
6{
7
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}
$result
An exception for terminatinating execution or to throw for unit testing.