parent
fa6bb2a910
commit
c4d04b7964
@ -1,24 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit backupGlobals="false"
|
<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">
|
||||||
backupStaticAttributes="false"
|
<coverage processUncoveredFiles="true">
|
||||||
bootstrap="vendor/autoload.php"
|
<include>
|
||||||
colors="true"
|
<directory suffix=".php">src</directory>
|
||||||
convertErrorsToExceptions="true"
|
</include>
|
||||||
convertNoticesToExceptions="true"
|
</coverage>
|
||||||
convertWarningsToExceptions="true"
|
<testsuites>
|
||||||
processIsolation="false"
|
<testsuite name="Unit">
|
||||||
stopOnFailure="false">
|
<directory suffix="Test.php">./tests/Unit</directory>
|
||||||
<testsuites>
|
</testsuite>
|
||||||
<testsuite name="Unit">
|
</testsuites>
|
||||||
<directory suffix="Test.php">./tests/Unit</directory>
|
<php>
|
||||||
</testsuite>
|
<server name="APP_ENV" value="testing"/>
|
||||||
</testsuites>
|
</php>
|
||||||
<filter>
|
|
||||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
|
||||||
<directory suffix=".php">src</directory>
|
|
||||||
</whitelist>
|
|
||||||
</filter>
|
|
||||||
<php>
|
|
||||||
<server name="APP_ENV" value="testing"/>
|
|
||||||
</php>
|
|
||||||
</phpunit>
|
</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>
|
@ -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