Пример #1
0
 public function testZipcode()
 {
     $zipcode = new Zipcode();
     $this->assertEquals(null, $zipcode->zipcode("RTRR", "rt"));
     $this->assertEquals(null, $zipcode->zipcode("RTRR", "ca"));
     $address = $zipcode->zipcode("X0A0A0", "CA");
     $this->assertEquals($address->zipcode, "X0A0A0");
     $this->assertEquals($address->lat, "73.005278");
     $this->assertEquals($address->lng, "-85.033056");
     $this->assertEquals($address->province, "Nunavut");
     $this->assertEquals($address->city, "Arctic Bay");
     //$this->assertEquals(-1, -1);
 }
Пример #2
0
<?php

namespace Maalls\Zipcode\Tests;

include __DIR__ . "/../Zipcode.php";
use Maalls\Zipcode\Zipcode;
$zipcode = new Zipcode();
$fh = fopen(__DIR__ . "/data/sample.csv", "r");
$row = fgetcsv($fh);
while ($row = fgetcsv($fh)) {
    list($from, $to) = @$row;
    $address = $zipcode->zipcode($from, "CA");
    if ($address) {
        echo "SUCCESS " . $from . " -> " . $address->lat . "," . $address->lng . PHP_EOL;
    } else {
        echo "ERROR " . $from . PHP_EOL;
    }
    if (isset($to)) {
        $address = $zipcode->zipcode($to, "CA");
        if ($address) {
            echo "SUCCESS " . $to . " -> " . $address->lat . "," . $address->lng . PHP_EOL;
        } else {
            echo "ERROR " . $to . PHP_EOL;
        }
    }
}