Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
Get tests pass in php7
Browse files Browse the repository at this point in the history
  • Loading branch information
treffynnon committed Feb 18, 2016
1 parent 5ae81ce commit 3a44b20
Show file tree
Hide file tree
Showing 16 changed files with 210 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ before_install:
install:
- composer install
script:
- ./vendor/bin/phpunit --colors --bootstrap tests/bootstrap.php --coverage-text tests
- ./vendor/bin/phpunit --coverage-text
12 changes: 12 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<phpunit backupGlobals="true"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
cacheTokens="false"
colors="true">
<testsuites>
<testsuite name="Navigator Test Suite">
<directory suffix="Test.php">tests</directory>
<directory suffix="TestUnder7.php" phpVersion="6" phpVersionOperator="&lt;=">tests</directory>
</testsuite>
</testsuites>
</phpunit>
8 changes: 0 additions & 8 deletions tests/Treffynnon/Navigator/CoordinateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ public function testCorrectParser() {
$this->assertInstanceOf('Treffynnon\Navigator\Coordinate\DecimalParser', $Coordinate->getParser());
}

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testIncorrectParser() {
$Coordinate = new N\Coordinate;
$Coordinate->setParser(new stdClass());
}

public function testDefaultParser() {
$Coordinate = new N\Coordinate;
$this->assertInstanceOf('Treffynnon\Navigator\Coordinate\DecimalParser', $Coordinate->getParser());
Expand Down
23 changes: 23 additions & 0 deletions tests/Treffynnon/Navigator/CoordinateTestUnder7.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Navigator: a geographic calculation library for PHP
* @link http://navigator.simonholywell.com
* @license http://www.opensource.org/licenses/bsd-license.php BSD 2-Clause License
* @copyright 2012, Simon Holywell
* @author Simon Holywell <treffynnon@php.net>
*/
use Treffynnon\Navigator as N;
use Treffynnon\Navigator\Coordinate as C;

class CoordinateTestUnder7 extends PHPUnit_Framework_TestCase {

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testIncorrectParser() {
$Coordinate = new N\Coordinate;
$Coordinate->setParser(new stdClass());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@

class CosineLawTest extends PHPUnit_Framework_TestCase {

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedCalculator() {
$CosineLaw = new C\CosineLaw;
$CosineLaw->calculate(new stdClass, new stdClass);
}

public function testCalculate() {
$CosineLaw = new C\CosineLaw;
$point1 = new N\LatLong(new N\Coordinate(80.9), new N\Coordinate(20.1));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Navigator: a geographic calculation library for PHP
* @link http://navigator.simonholywell.com
* @license http://www.opensource.org/licenses/bsd-license.php BSD 2-Clause License
* @copyright 2012, Simon Holywell
* @author Simon Holywell <treffynnon@php.net>
*/
use Treffynnon\Navigator as N;
use Treffynnon\Navigator\Distance\Calculator as C;

class CosineLawTestUnder7 extends PHPUnit_Framework_TestCase {

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedCalculator() {
$CosineLaw = new C\CosineLaw;
$CosineLaw->calculate(new stdClass, new stdClass);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@

class GreatCircleTest extends PHPUnit_Framework_TestCase {

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedCalculator() {
$GreatCircle = new C\GreatCircle;
$GreatCircle->calculate(new stdClass, new stdClass);
}

public function testCalculate() {
$GreatCircle = new C\GreatCircle;
$point1 = new N\LatLong(new N\Coordinate(80.9), new N\Coordinate(20.1));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Navigator: a geographic calculation library for PHP
* @link http://navigator.simonholywell.com
* @license http://www.opensource.org/licenses/bsd-license.php BSD 2-Clause License
* @copyright 2012, Simon Holywell
* @author Simon Holywell <treffynnon@php.net>
*/
use Treffynnon\Navigator as N;
use Treffynnon\Navigator\Distance\Calculator as C;

class GreatCircleTestUnder7 extends PHPUnit_Framework_TestCase {

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedCalculator() {
$GreatCircle = new C\GreatCircle;
$GreatCircle->calculate(new stdClass, new stdClass);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@

class HaversineTest extends PHPUnit_Framework_TestCase {

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedCalculator() {
$Haversine = new C\Haversine;
$Haversine->calculate(new stdClass, new stdClass);
}

public function testCalculate() {
$Haversine = new C\Haversine;
$point1 = new N\LatLong(new N\Coordinate(80.9), new N\Coordinate(20.1));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Navigator: a geographic calculation library for PHP
* @link http://navigator.simonholywell.com
* @license http://www.opensource.org/licenses/bsd-license.php BSD 2-Clause License
* @copyright 2012, Simon Holywell
* @author Simon Holywell <treffynnon@php.net>
*/
use Treffynnon\Navigator as N;
use Treffynnon\Navigator\Distance\Calculator as C;

class HaversineTestUnder7 extends PHPUnit_Framework_TestCase {

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedCalculator() {
$Haversine = new C\Haversine;
$Haversine->calculate(new stdClass, new stdClass);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@

class VincentyTest extends PHPUnit_Framework_TestCase {

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedCalculator() {
$Vincenty = new C\Vincenty;
$Vincenty->calculate(new stdClass, new stdClass);
}

public function testCalculate() {
$Vincenty = new C\Vincenty;
$point1 = new N\LatLong(new N\Coordinate(80.9), new N\Coordinate(20.1));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Navigator: a geographic calculation library for PHP
* @link http://navigator.simonholywell.com
* @license http://www.opensource.org/licenses/bsd-license.php BSD 2-Clause License
* @copyright 2012, Simon Holywell
* @author Simon Holywell <treffynnon@php.net>
*/
use Treffynnon\Navigator as N;
use Treffynnon\Navigator\Distance\Calculator as C;

class VincentyTestUnder7 extends PHPUnit_Framework_TestCase {

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedCalculator() {
$Vincenty = new C\Vincenty;
$Vincenty->calculate(new stdClass, new stdClass);
}

}
17 changes: 0 additions & 17 deletions tests/Treffynnon/Navigator/DistanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@

class DistanceTest extends PHPUnit_Framework_TestCase {

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedGet() {
$point1 = new N\LatLong(new N\Coordinate(80.9), new N\Coordinate(20.1));
$point2 = new N\LatLong(new N\Coordinate(20.1), new N\Coordinate(80.9));
$Distance = new N\Distance($point1, $point2);
$metres = $Distance->get(new stdClass, new stdClass);
}

public function testGet() {
$point1 = new N\LatLong(new N\Coordinate(80.9), new N\Coordinate(20.1));
$point2 = new N\LatLong(new N\Coordinate(20.1), new N\Coordinate(80.9));
Expand Down Expand Up @@ -48,13 +38,6 @@ public function testConstructorWithProvider($coord) {
$this->assertGreaterThan(20, $metres);
}

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedConstructor() {
$Distance = new N\Distance(new stdClass, new stdClass);
}

public function coordValidProvider() {
return NavigatorTestData::coordData_decimal_valid();
}
Expand Down
31 changes: 31 additions & 0 deletions tests/Treffynnon/Navigator/DistanceTestUnder7.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* Navigator: a geographic calculation library for PHP
* @link http://navigator.simonholywell.com
* @license http://www.opensource.org/licenses/bsd-license.php BSD 2-Clause License
* @copyright 2012, Simon Holywell
* @author Simon Holywell <treffynnon@php.net>
*/
use Treffynnon\Navigator as N;

class DistanceTestUnder7 extends PHPUnit_Framework_TestCase {

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedGet() {
$point1 = new N\LatLong(new N\Coordinate(80.9), new N\Coordinate(20.1));
$point2 = new N\LatLong(new N\Coordinate(20.1), new N\Coordinate(80.9));
$Distance = new N\Distance($point1, $point2);
$metres = $Distance->get(new stdClass, new stdClass);
}

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testFailedConstructor() {
$Distance = new N\Distance(new stdClass, new stdClass);
}

}
7 changes: 0 additions & 7 deletions tests/Treffynnon/Navigator/LatLongTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ public function testConstructor() {
$LatLong = new N\LatLong($latitude, $longitude);
}

/**
* @expectedException PHPUnit_Framework_Error
*/
public function testInvalidConstructor() {
$LatLong = new N\LatLong('test', 'test');
}

public function testPrimeCoordinateParsers() {
$latitude = new N\Coordinate(10.03);
$longitude = new N\Coordinate('10 10 1.2S', new C\DmsParser);
Expand Down
51 changes: 51 additions & 0 deletions tests/Treffynnon/Navigator/LatLongTestUnder7.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* Navigator: a geographic calculation library for PHP
* @link http://navigator.simonholywell.com
* @license http://www.opensource.org/licenses/bsd-license.php BSD 2-Clause License
* @copyright 2012, Simon Holywell
* @author Simon Holywell <treffynnon@php.net>
*/
use Treffynnon as T;
use Treffynnon\Navigator as N;
use Treffynnon\Navigator\Coordinate as C;

class LatLongTestUnder7 extends PHPUnit_Framework_TestCase {

public function testConstructor() {
$latitude = new N\Coordinate(10.03);
$longitude = new N\Coordinate('10 10 1.2S', new C\DmsParser);
$LatLong = new N\LatLong($latitude, $longitude);
}

public function testPrimeCoordinateParsers() {
$latitude = new N\Coordinate(10.03);
$longitude = new N\Coordinate('10 10 1.2S', new C\DmsParser);
$LatLong = new N\LatLong($latitude, $longitude);

$this->assertEquals(
$LatLong->getLongitude()->getParser()->getDirection(), T\Navigator::LONG
);
$this->assertEquals(
$LatLong->getLatitude()->getParser()->getDirection(), T\Navigator::LAT
);
}

public function testToString() {
$latitude = new N\Coordinate(42.77);
$longitude = new N\Coordinate(-2.86844);
$LatLong = new N\LatLong($latitude, $longitude);
$this->assertEquals($latitude . ',' . $longitude, (string) $LatLong);
}

public function testFromString() {
$latitude = '42.77';
$longitude = '-2.86844';
$LatLong = N\LatLong::createFromString($latitude . ',' . $longitude);
$this->assertInstanceOf('Treffynnon\Navigator\LatLong', $LatLong);
$this->assertEquals($latitude, (string) $LatLong->getLatitude());
$this->assertEquals($longitude, (string) $LatLong->getLongitude());
}

}

0 comments on commit 3a44b20

Please sign in to comment.