Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
|
f8429d2a9d | 2 years ago |
|
cafebfedf9 | 2 years ago |
|
ac90c4d2d2 | 2 years ago |
|
c4d04b7964 | 2 years ago |
|
fa6bb2a910 | 2 years ago |
|
ed115ecd2e | 2 years ago |
|
33f665934b | 2 years ago |
|
0c604f7182 | 2 years ago |
|
94d23275f2 | 2 years ago |
|
b09f1c42b5 | 2 years ago |
File diff suppressed because it is too large
Load Diff
@ -1,24 +1,16 @@
|
||||
<?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 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">
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<server name="APP_ENV" value="testing"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
|
@ -0,0 +1,24 @@
|
||||
<?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>
|
@ -0,0 +1,31 @@
|
||||
<?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
|
||||
) {}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<?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