Skip to content

Commit

Permalink
Merge pull request #127 from ash-jc-allen/analysis-mayA1K
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
ash-jc-allen authored Mar 23, 2023
2 parents 4ce5d4f + a29fe46 commit 20e4132
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 117 deletions.
74 changes: 37 additions & 37 deletions tests/Unit/Drivers/ExchangeRateHost/ConvertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,43 +188,43 @@ private function mockResponseForCurrentDateAndOneSymbol(): Response
private function mockResponseForPastDateAndOneSymbol(): Response
{
return new Response([
'rates' => [
'CAD' => 1.4969,
'HKD' => 8.8843,
'ISK' => 138.5,
'PHP' => 60.256,
'DKK' => 7.4594,
'HUF' => 321.31,
'CZK' => 25.936,
'AUD' => 1.5663,
'RON' => 4.657,
'SEK' => 10.2648,
'IDR' => 16661.6,
'INR' => 82.264,
'BRL' => 4.254,
'RUB' => 76.4283,
'HRK' => 7.43,
'JPY' => 129.26,
'THB' => 37.453,
'CHF' => 1.1414,
'SGD' => 1.5627,
'PLN' => 4.288,
'BGN' => 1.9558,
'TRY' => 6.2261,
'CNY' => 7.8852,
'NOK' => 9.5418,
'NZD' => 1.6815,
'ZAR' => 16.1884,
'USD' => 1.1346,
'MXN' => 23.0001,
'ILS' => 4.171,
'GBP' => 0.87053,
'KRW' => 1278.77,
'MYR' => 4.7399,
],
'base' => 'EUR',
'date' => '2018-11-09',
]);
'rates' => [
'CAD' => 1.4969,
'HKD' => 8.8843,
'ISK' => 138.5,
'PHP' => 60.256,
'DKK' => 7.4594,
'HUF' => 321.31,
'CZK' => 25.936,
'AUD' => 1.5663,
'RON' => 4.657,
'SEK' => 10.2648,
'IDR' => 16661.6,
'INR' => 82.264,
'BRL' => 4.254,
'RUB' => 76.4283,
'HRK' => 7.43,
'JPY' => 129.26,
'THB' => 37.453,
'CHF' => 1.1414,
'SGD' => 1.5627,
'PLN' => 4.288,
'BGN' => 1.9558,
'TRY' => 6.2261,
'CNY' => 7.8852,
'NOK' => 9.5418,
'NZD' => 1.6815,
'ZAR' => 16.1884,
'USD' => 1.1346,
'MXN' => 23.0001,
'ILS' => 4.171,
'GBP' => 0.87053,
'KRW' => 1278.77,
'MYR' => 4.7399,
],
'base' => 'EUR',
'date' => '2018-11-09',
]);
}

private function mockResponseForCurrentDateAndMultipleSymbols(): Response
Expand Down
30 changes: 15 additions & 15 deletions tests/Unit/Drivers/ExchangeRateHost/ExchangeRateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function exchange_rate_for_today_is_returned_if_no_date_parameter_passed_
$exchangeRate = new ExchangeRateHostDriver($requestBuilderMock);
$rate = $exchangeRate->exchangeRate('EUR', 'GBP');
$this->assertEquals('0.86158', $rate);
$this->assertEquals('0.86158', Cache::get('laravel_xr_EUR_GBP_' . now()->format('Y-m-d')));
$this->assertEquals('0.86158', Cache::get('laravel_xr_EUR_GBP_'.now()->format('Y-m-d')));
}

/** @test */
Expand All @@ -37,30 +37,30 @@ public function exchange_rate_in_the_past_is_returned_if_date_parameter_passed_a

$requestBuilderMock = Mockery::mock(RequestBuilder::class);
$requestBuilderMock->expects('makeRequest')
->withArgs(['/' . $mockDate->format('Y-m-d'), ['base' => 'EUR', 'symbols' => 'GBP']])
->withArgs(['/'.$mockDate->format('Y-m-d'), ['base' => 'EUR', 'symbols' => 'GBP']])
->once()
->andReturn($this->mockResponseForPastDateAndOneSymbol());

$exchangeRate = new ExchangeRateHostDriver($requestBuilderMock);
$rate = $exchangeRate->exchangeRate('EUR', 'GBP', $mockDate);
$this->assertEquals('0.87053', $rate);
$this->assertEquals('0.87053', Cache::get('laravel_xr_EUR_GBP_' . $mockDate->format('Y-m-d')));
$this->assertEquals('0.87053', Cache::get('laravel_xr_EUR_GBP_'.$mockDate->format('Y-m-d')));
}

/** @test */
public function cached_exchange_rate_is_returned_if_it_exists(): void
{
$mockDate = now();

Cache::forever('laravel_xr_EUR_GBP_' . $mockDate->format('Y-m-d'), 0.123456);
Cache::forever('laravel_xr_EUR_GBP_'.$mockDate->format('Y-m-d'), 0.123456);

$requestBuilderMock = Mockery::mock(RequestBuilder::class);
$requestBuilderMock->expects('makeRequest')->never();

$exchangeRate = new ExchangeRateHostDriver($requestBuilderMock);
$rate = $exchangeRate->exchangeRate('EUR', 'GBP', $mockDate);
$this->assertEquals('0.123456', $rate);
$this->assertEquals('0.123456', Cache::get('laravel_xr_EUR_GBP_' . $mockDate->format('Y-m-d')));
$this->assertEquals('0.123456', Cache::get('laravel_xr_EUR_GBP_'.$mockDate->format('Y-m-d')));
}

/** @test */
Expand All @@ -77,7 +77,7 @@ public function multiple_exchange_rates_can_be_returned_if_no_date_parameter_pas
$this->assertEquals(['CAD' => 1.4561, 'USD' => 1.1034, 'GBP' => 0.86158], $response);
$this->assertEquals(
['CAD' => 1.4561, 'USD' => 1.1034, 'GBP' => 0.86158],
Cache::get('laravel_xr_EUR_CAD_GBP_USD_' . now()->format('Y-m-d'))
Cache::get('laravel_xr_EUR_CAD_GBP_USD_'.now()->format('Y-m-d'))
);
}

Expand All @@ -88,7 +88,7 @@ public function multiple_exchange_rates_can_be_returned_if_date_parameter_passed

$requestBuilderMock = Mockery::mock(RequestBuilder::class);
$requestBuilderMock->expects('makeRequest')
->withArgs(['/' . $mockDate->format('Y-m-d'), ['base' => 'EUR', 'symbols' => 'GBP,CAD,USD']])
->withArgs(['/'.$mockDate->format('Y-m-d'), ['base' => 'EUR', 'symbols' => 'GBP,CAD,USD']])
->once()
->andReturn($this->mockResponseForPastDateAndMultipleSymbols());

Expand All @@ -97,7 +97,7 @@ public function multiple_exchange_rates_can_be_returned_if_date_parameter_passed
$this->assertEquals(['CAD' => 1.4969, 'USD' => 1.1346, 'GBP' => 0.87053], $response);
$this->assertEquals(
['CAD' => 1.4969, 'USD' => 1.1346, 'GBP' => 0.87053],
Cache::get('laravel_xr_EUR_CAD_GBP_USD_' . $mockDate->format('Y-m-d'))
Cache::get('laravel_xr_EUR_CAD_GBP_USD_'.$mockDate->format('Y-m-d'))
);
}

Expand All @@ -106,9 +106,9 @@ public function multiple_cached_exchange_rates_are_returned_if_they_exist(): voi
{
$mockDate = now();

Cache::forget('laravel_xr_EUR_CAD_GBP_USD_' . $mockDate->format('Y-m-d'));
Cache::forget('laravel_xr_EUR_CAD_GBP_USD_'.$mockDate->format('Y-m-d'));

Cache::forever('laravel_xr_EUR_CAD_GBP_USD_' . $mockDate->format('Y-m-d'),
Cache::forever('laravel_xr_EUR_CAD_GBP_USD_'.$mockDate->format('Y-m-d'),
['CAD' => 1.4561, 'USD' => 1.1034, 'GBP' => 0.86158]
);

Expand All @@ -120,7 +120,7 @@ public function multiple_cached_exchange_rates_are_returned_if_they_exist(): voi
$this->assertEquals(['CAD' => 1.4561, 'USD' => 1.1034, 'GBP' => 0.86158], $rate);
$this->assertEquals(
['CAD' => 1.4561, 'USD' => 1.1034, 'GBP' => 0.86158],
Cache::get('laravel_xr_EUR_CAD_GBP_USD_' . $mockDate->format('Y-m-d'))
Cache::get('laravel_xr_EUR_CAD_GBP_USD_'.$mockDate->format('Y-m-d'))
);
}

Expand All @@ -129,18 +129,18 @@ public function cached_exchange_rate_is_not_used_if_should_bust_cache_method_is_
{
$mockDate = now();

Cache::forever('laravel_xr_EUR_GBP_' . $mockDate->format('Y-m-d'), '0.123456');
Cache::forever('laravel_xr_EUR_GBP_'.$mockDate->format('Y-m-d'), '0.123456');

$requestBuilderMock = Mockery::mock(RequestBuilder::class);
$requestBuilderMock->expects('makeRequest')
->withArgs(['/' . $mockDate->format('Y-m-d'), ['base' => 'EUR', 'symbols' => 'GBP']])
->withArgs(['/'.$mockDate->format('Y-m-d'), ['base' => 'EUR', 'symbols' => 'GBP']])
->once()
->andReturn($this->mockResponseForPastDateAndOneSymbol());

$exchangeRate = new ExchangeRateHostDriver($requestBuilderMock);
$rate = $exchangeRate->shouldBustCache()->exchangeRate('EUR', 'GBP', $mockDate);
$this->assertEquals('0.87053', $rate);
$this->assertEquals('0.87053', Cache::get('laravel_xr_EUR_GBP_' . $mockDate->format('Y-m-d')));
$this->assertEquals('0.87053', Cache::get('laravel_xr_EUR_GBP_'.$mockDate->format('Y-m-d')));
}

/** @test */
Expand All @@ -155,7 +155,7 @@ public function exchange_rate_is_not_cached_if_the_shouldCache_option_is_false()
$exchangeRate = new ExchangeRateHostDriver($requestBuilderMock);
$rate = $exchangeRate->shouldCache(false)->exchangeRate('EUR', 'GBP');
$this->assertEquals('0.86158', $rate);
$this->assertNull(Cache::get('laravel_xr_EUR_GBP_' . now()->format('Y-m-d')));
$this->assertNull(Cache::get('laravel_xr_EUR_GBP_'.now()->format('Y-m-d')));
}

/** @test */
Expand Down
74 changes: 37 additions & 37 deletions tests/Unit/Drivers/ExchangeRatesApiIo/ConvertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,43 +188,43 @@ private function mockResponseForCurrentDateAndOneSymbol(): Response
private function mockResponseForPastDateAndOneSymbol(): Response
{
return new Response([
'rates' => [
'CAD' => 1.4969,
'HKD' => 8.8843,
'ISK' => 138.5,
'PHP' => 60.256,
'DKK' => 7.4594,
'HUF' => 321.31,
'CZK' => 25.936,
'AUD' => 1.5663,
'RON' => 4.657,
'SEK' => 10.2648,
'IDR' => 16661.6,
'INR' => 82.264,
'BRL' => 4.254,
'RUB' => 76.4283,
'HRK' => 7.43,
'JPY' => 129.26,
'THB' => 37.453,
'CHF' => 1.1414,
'SGD' => 1.5627,
'PLN' => 4.288,
'BGN' => 1.9558,
'TRY' => 6.2261,
'CNY' => 7.8852,
'NOK' => 9.5418,
'NZD' => 1.6815,
'ZAR' => 16.1884,
'USD' => 1.1346,
'MXN' => 23.0001,
'ILS' => 4.171,
'GBP' => 0.87053,
'KRW' => 1278.77,
'MYR' => 4.7399,
],
'base' => 'EUR',
'date' => '2018-11-09',
]);
'rates' => [
'CAD' => 1.4969,
'HKD' => 8.8843,
'ISK' => 138.5,
'PHP' => 60.256,
'DKK' => 7.4594,
'HUF' => 321.31,
'CZK' => 25.936,
'AUD' => 1.5663,
'RON' => 4.657,
'SEK' => 10.2648,
'IDR' => 16661.6,
'INR' => 82.264,
'BRL' => 4.254,
'RUB' => 76.4283,
'HRK' => 7.43,
'JPY' => 129.26,
'THB' => 37.453,
'CHF' => 1.1414,
'SGD' => 1.5627,
'PLN' => 4.288,
'BGN' => 1.9558,
'TRY' => 6.2261,
'CNY' => 7.8852,
'NOK' => 9.5418,
'NZD' => 1.6815,
'ZAR' => 16.1884,
'USD' => 1.1346,
'MXN' => 23.0001,
'ILS' => 4.171,
'GBP' => 0.87053,
'KRW' => 1278.77,
'MYR' => 4.7399,
],
'base' => 'EUR',
'date' => '2018-11-09',
]);
}

private function mockResponseForCurrentDateAndMultipleSymbols(): Response
Expand Down
28 changes: 14 additions & 14 deletions tests/Unit/Drivers/ExchangeRatesApiIo/ExchangeRateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,24 +236,24 @@ private function mockResponseForCurrentDateAndMultipleSymbols(): Response
private function mockResponseForPastDateAndOneSymbol(): Response
{
return new Response([
'rates' => [
'GBP' => 0.87053,
],
'base' => 'EUR',
'date' => '2018-11-09',
]);
'rates' => [
'GBP' => 0.87053,
],
'base' => 'EUR',
'date' => '2018-11-09',
]);
}

private function mockResponseForPastDateAndMultipleSymbols(): Response
{
return new Response([
'rates' => [
'CAD' => 1.4969,
'USD' => 1.1346,
'GBP' => 0.87053,
],
'base' => 'EUR',
'date' => '2018-11-09',
]);
'rates' => [
'CAD' => 1.4969,
'USD' => 1.1346,
'GBP' => 0.87053,
],
'base' => 'EUR',
'date' => '2018-11-09',
]);
}
}
3 changes: 1 addition & 2 deletions tests/Unit/Drivers/ExchangeRatesDataApi/ConvertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\ExchangeRatesDataApiDriver;
use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\RequestBuilder;
use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\Response;
use AshAllenDesign\LaravelExchangeRates\Exceptions\InvalidCurrencyException;
use AshAllenDesign\LaravelExchangeRates\Exceptions\InvalidDateException;
use AshAllenDesign\LaravelExchangeRates\Tests\Unit\TestCase;
use Illuminate\Support\Facades\Cache;
use Mockery;
use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\Response;


final class ConvertTest extends TestCase
{
Expand Down
3 changes: 1 addition & 2 deletions tests/Unit/Drivers/ExchangeRatesDataApi/CurrenciesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\ExchangeRatesDataApiDriver;
use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\RequestBuilder;
use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\Response;
use AshAllenDesign\LaravelExchangeRates\Tests\Unit\TestCase;
use Illuminate\Support\Facades\Cache;
use Mockery;
use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\Response;


final class CurrenciesTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\ExchangeRatesDataApiDriver;
use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\RequestBuilder;
use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\Response;
use AshAllenDesign\LaravelExchangeRates\Exceptions\InvalidCurrencyException;
use AshAllenDesign\LaravelExchangeRates\Exceptions\InvalidDateException;
use AshAllenDesign\LaravelExchangeRates\Tests\Unit\TestCase;
use Carbon\Carbon;
use Illuminate\Support\Facades\Cache;
use Mockery;
use AshAllenDesign\LaravelExchangeRates\Drivers\ExchangeRatesDataApi\Response;


final class ExchangeRateBetweenDateRangeTest extends TestCase
{
Expand Down
16 changes: 8 additions & 8 deletions tests/Unit/Drivers/ExchangeRatesDataApi/ExchangeRateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ private function mockResponseForPastDateAndOneSymbol(): Response
private function mockResponseForPastDateAndMultipleSymbols(): Response
{
return new Response([
'rates' => [
'CAD' => 1.4969,
'USD' => 1.1346,
'GBP' => 0.87053,
],
'base' => 'EUR',
'date' => '2018-11-09',
]);
'rates' => [
'CAD' => 1.4969,
'USD' => 1.1346,
'GBP' => 0.87053,
],
'base' => 'EUR',
'date' => '2018-11-09',
]);
}
}

0 comments on commit 20e4132

Please sign in to comment.