1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<?php
namespace SMW\Tests;
use SMW\Exception\DataItemException;
/**
* @covers SMWDIGeoCoord
* @covers SMWDataItem
*
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
class SMWDIGeoCoordTest extends \PHPUnit_Framework_TestCase {
use PHPUnitCompat;
public function testConstructorWithArrayArgumentForm() {
$coordinate = new \SMWDIGeoCoord( [ 'lat' => 13.37, 'lon' => 42.42 ] );
$this->assertSame( 13.37, $coordinate->getLatitude() );
$this->assertSame( 42.42, $coordinate->getLongitude() );
}
public function testConstructorWithMultipleArgumentsForm() {
$coordinate = new \SMWDIGeoCoord( 13.37, 42.42 );
$this->assertSame( 13.37, $coordinate->getLatitude() );
$this->assertSame( 42.42, $coordinate->getLongitude() );
}
public function testWhenConstructingWithIntegers_gettersReturnFloats() {
$coordinate = new \SMWDIGeoCoord( 13, 42 );
$this->assertSame( 13.0, $coordinate->getLatitude() );
$this->assertSame( 42.0, $coordinate->getLongitude() );
}
public function testWhenOnlyProvidingLatitudeArgument_constructorThrowsException() {
$this->setExpectedException( DataItemException::class );
new \SMWDIGeoCoord( 13 );
}
public function testWhenProvidingNonNumericalArgument_constructorThrowsException() {
$this->setExpectedException( DataItemException::class );
new \SMWDIGeoCoord( 13, null );
}
public function testWhenProvidingArrayWithNonNumericalArgument_constructorThrowsException() {
$this->setExpectedException( DataItemException::class );
new \SMWDIGeoCoord( [ 'lat' => null, 'lon' => 42.42 ] );
}
public function testObjectEqualsItself() {
$coordinate = new \SMWDIGeoCoord( 13, 42 );
$this->assertTrue( $coordinate->equals( $coordinate ) );
}
public function testObjectEqualsDifferentInstancesWithEqualValues() {
$coordinate = new \SMWDIGeoCoord( 13, 42 );
$this->assertTrue( $coordinate->equals( new \SMWDIGeoCoord( 13.0, 42.0 ) ) );
}
public function testObjectDoesNotEqualInstancesWithDifferentValues() {
$coordinate = new \SMWDIGeoCoord( 13, 42 );
$this->assertFalse( $coordinate->equals( new \SMWDIGeoCoord( 1, 2 ) ) );
}
}
|