Compare commits
No commits in common. 'master' and 'v0.0.4' have entirely different histories.
File diff suppressed because it is too large
Load Diff
@ -1,16 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
<phpunit backupGlobals="false"
|
||||||
<coverage processUncoveredFiles="true">
|
backupStaticAttributes="false"
|
||||||
<include>
|
bootstrap="vendor/autoload.php"
|
||||||
<directory suffix=".php">src</directory>
|
colors="true"
|
||||||
</include>
|
convertErrorsToExceptions="true"
|
||||||
</coverage>
|
convertNoticesToExceptions="true"
|
||||||
<testsuites>
|
convertWarningsToExceptions="true"
|
||||||
<testsuite name="Unit">
|
processIsolation="false"
|
||||||
<directory suffix="Test.php">./tests/Unit</directory>
|
stopOnFailure="false">
|
||||||
</testsuite>
|
<testsuites>
|
||||||
</testsuites>
|
<testsuite name="Unit">
|
||||||
<php>
|
<directory suffix="Test.php">./tests/Unit</directory>
|
||||||
<server name="APP_ENV" value="testing"/>
|
</testsuite>
|
||||||
</php>
|
</testsuites>
|
||||||
|
<filter>
|
||||||
|
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||||
|
<directory suffix=".php">src</directory>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
<php>
|
||||||
|
<server name="APP_ENV" value="testing"/>
|
||||||
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<phpunit backupGlobals="false"
|
|
||||||
backupStaticAttributes="false"
|
|
||||||
bootstrap="vendor/autoload.php"
|
|
||||||
colors="true"
|
|
||||||
convertErrorsToExceptions="true"
|
|
||||||
convertNoticesToExceptions="true"
|
|
||||||
convertWarningsToExceptions="true"
|
|
||||||
processIsolation="false"
|
|
||||||
stopOnFailure="false">
|
|
||||||
<testsuites>
|
|
||||||
<testsuite name="Unit">
|
|
||||||
<directory suffix="Test.php">./tests/Unit</directory>
|
|
||||||
</testsuite>
|
|
||||||
</testsuites>
|
|
||||||
<filter>
|
|
||||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
|
||||||
<directory suffix=".php">src</directory>
|
|
||||||
</whitelist>
|
|
||||||
</filter>
|
|
||||||
<php>
|
|
||||||
<server name="APP_ENV" value="testing"/>
|
|
||||||
</php>
|
|
||||||
</phpunit>
|
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Ae3\LaravelGeoLayer\app\DataTransferObjects;
|
|
||||||
|
|
||||||
use Spatie\LaravelData\Data;
|
|
||||||
|
|
||||||
class GeocodingResponseData extends Data
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param float $lat
|
|
||||||
* @param float $lng
|
|
||||||
* @param string $accuracy
|
|
||||||
* @param string $formatted_address
|
|
||||||
* @param array $viewport
|
|
||||||
* @param array $address_components
|
|
||||||
* @param bool $partial_match
|
|
||||||
* @param string $place_id
|
|
||||||
* @param array $types
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
public float $lat,
|
|
||||||
public float $lng,
|
|
||||||
public string $accuracy,
|
|
||||||
public string $formatted_address,
|
|
||||||
public array $viewport,
|
|
||||||
public array $address_components,
|
|
||||||
public bool $partial_match,
|
|
||||||
public string $place_id,
|
|
||||||
public array $types
|
|
||||||
) {}
|
|
||||||
}
|
|
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Unit;
|
||||||
|
|
||||||
|
use Ae3\LaravelGeoLayer\app\Services\GeocodingService;
|
||||||
|
use Ae3\LaravelGeoLayer\Tests\TestCase;
|
||||||
|
use Mockery;
|
||||||
|
|
||||||
|
class GeocodingServiceTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var GeocodingService
|
||||||
|
*/
|
||||||
|
private GeocodingService $geocodingService;
|
||||||
|
|
||||||
|
private $mockedGeocoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the test
|
||||||
|
*/
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->mockedGeocoder = Mockery::mock('overload:Spatie\Geocoder\Geocoder');
|
||||||
|
|
||||||
|
// Configurando o mock para esperar a chamada de setApiKey
|
||||||
|
$this->mockedGeocoder->shouldReceive('setApiKey')->once()->withAnyArgs();
|
||||||
|
$this->mockedGeocoder->shouldReceive('setRegion')->once()->withAnyArgs();
|
||||||
|
$this->mockedGeocoder->shouldReceive('setCountry')->once()->withAnyArgs();
|
||||||
|
$this->mockedGeocoder->shouldReceive('setBounds')->once()->withAnyArgs();
|
||||||
|
|
||||||
|
// Configurando o mock para esperar a chamada de getCoordinatesForAddress
|
||||||
|
$this->mockedGeocoder->shouldReceive('getCoordinatesForAddress')
|
||||||
|
->once()
|
||||||
|
->with('Brussels, Belgium')
|
||||||
|
->andReturn(['lat' => '50.85045', 'lng' => '4.34878']);
|
||||||
|
|
||||||
|
$this->geocodingService = new GeocodingService();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test getCoordinatesForAddress function
|
||||||
|
*/
|
||||||
|
public function testGetCoordinatesForAddress(): void
|
||||||
|
{
|
||||||
|
// Mocking Geocoder response
|
||||||
|
$this->mockedGeocoder->shouldReceive('getCoordinatesForAddress')
|
||||||
|
->once()
|
||||||
|
->with('Brussels, Belgium')
|
||||||
|
->andReturn(['lat' => '50.85045', 'lng' => '4.34878']);
|
||||||
|
|
||||||
|
// Testing the function
|
||||||
|
$result = $this->geocodingService->getCoordinatesForAddress('Brussels, Belgium');
|
||||||
|
$this->assertEquals(['lat' => '50.85045', 'lng' => '4.34878'], $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tear down the test
|
||||||
|
*/
|
||||||
|
public function tearDown(): void
|
||||||
|
{
|
||||||
|
Mockery::close();
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue