Skip to content

Commit

Permalink
Add a couple more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Jan 31, 2016
1 parent 1a8ca7b commit b2e639b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
16 changes: 15 additions & 1 deletion tests/CartesianTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ public function testHelmertOSWorkedExample()
self::assertEquals(3909460.068, round($c->getX(), 3));
self::assertEquals(-146987.302, round($c->getY(), 3));
self::assertEquals(5019888.070, round($c->getZ(), 3));
}
}

public function testToString() {
$c = new Cartesian(1,2,3, RefEll::wgs84());

self::assertEquals('(1, 2, 3)', $c->__toString());
}

public function testGetters() {
$c = new Cartesian(1,2,3, RefEll::wgs84());
self::assertEquals(1, $c->getX());
self::assertEquals(2, $c->getY());
self::assertEquals(3, $c->getZ());
self::assertEquals(RefEll::wgs84(), $c->getRefEll());
}

}
24 changes: 22 additions & 2 deletions tests/LatLngTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,30 @@ public function testWGS84ToNAD27()
public function testNAD27ToWGS84()
{

$LatLng = new LatLng(12.3, 12.3, 0, RefEll::clarke1866());
$LatLng = new LatLng(12.29939, 12.29855, 0, RefEll::clarke1866());
$LatLng->toWGS84();

$expected = "(12.30061, 12.30145)";
$expected = "(12.3, 12.3)";
self::assertEquals($expected, $LatLng->__toString());
}

public function testWGS84ToIreland75()
{

$LatLng = new LatLng(12.3, 12.3, 0, RefEll::wgs84());
$LatLng->toIreland1975();

$expected = "(12.29557, 12.30201)";
self::assertEquals($expected, $LatLng->__toString());
}

public function testIreland75ToWGS84()
{

$LatLng = new LatLng(12.29557, 12.30201, 0, RefEll::airyModified());
$LatLng->toWGS84();

$expected = "(12.3, 12.3)";
self::assertEquals($expected, $LatLng->__toString());
}

Expand Down
8 changes: 7 additions & 1 deletion tests/OSRefTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,14 @@ public function testIssue7() {

self::assertEquals(52.06186, $osLatLng->getLat());
self::assertEquals(-3.13916, $osLatLng->getLng());
}


public function testGetters() {
$osRef = new OSRef(100000, 200000, 123);
self::assertEquals(100000, $osRef->getX());
self::assertEquals(200000, $osRef->getY());
self::assertEquals(123, $osRef->getH());
self::assertEquals(RefEll::airy1830(), $osRef->getRefEll());
}

}

0 comments on commit b2e639b

Please sign in to comment.