From a1f51253c5ca6b81f4a3f023b0f781c63c4484ab Mon Sep 17 00:00:00 2001 From: Nadhiir Date: Mon, 6 Nov 2017 17:23:36 +0100 Subject: [PATCH 1/3] Update to latest google finance endpoint --- src/Provider/GoogleFinanceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Provider/GoogleFinanceProvider.php b/src/Provider/GoogleFinanceProvider.php index cd4a778..820d682 100644 --- a/src/Provider/GoogleFinanceProvider.php +++ b/src/Provider/GoogleFinanceProvider.php @@ -22,7 +22,7 @@ */ class GoogleFinanceProvider extends AbstractProvider { - const URL = 'http://www.google.com/finance/converter?a=1&from=%s&to=%s'; + const URL = 'https://finance.google.com/finance/converter?a=1&from=%s&to=%s'; /** * {@inheritdoc} From f422238fd7d92f931d1a57a24a341439ceb93343 Mon Sep 17 00:00:00 2001 From: Rosun Nadhiir Date: Thu, 9 Nov 2017 12:33:18 +0000 Subject: [PATCH 2/3] Apply fixes from StyleCI --- src/Provider/CentralBankOfRepublicTurkeyProvider.php | 2 +- src/Util/StringUtil.php | 1 + tests/Tests/Provider/CurrencyLayerProviderTest.php | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Provider/CentralBankOfRepublicTurkeyProvider.php b/src/Provider/CentralBankOfRepublicTurkeyProvider.php index 92e3fa7..e1fc018 100644 --- a/src/Provider/CentralBankOfRepublicTurkeyProvider.php +++ b/src/Provider/CentralBankOfRepublicTurkeyProvider.php @@ -20,7 +20,7 @@ /** * Central Bank of Republic of Turkey (CBRT) provider. * - * @link http://tcmb.gov.tr + * @see http://tcmb.gov.tr * * @author Uğur Erkan */ diff --git a/src/Util/StringUtil.php b/src/Util/StringUtil.php index 06420a4..e50f9b3 100644 --- a/src/Util/StringUtil.php +++ b/src/Util/StringUtil.php @@ -71,6 +71,7 @@ public static function jsonToArray($string) if (JSON_ERROR_NONE !== json_last_error()) { $last = json_last_error(); + throw new \RuntimeException( 'Unable to parse JSON data: ' .(isset($jsonErrors[$last]) ? $jsonErrors[$last] : 'Unknown error') diff --git a/tests/Tests/Provider/CurrencyLayerProviderTest.php b/tests/Tests/Provider/CurrencyLayerProviderTest.php index a3240a1..03c309f 100644 --- a/tests/Tests/Provider/CurrencyLayerProviderTest.php +++ b/tests/Tests/Provider/CurrencyLayerProviderTest.php @@ -7,6 +7,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Swap\Tests\Provider; use Swap\Model\CurrencyPair; From 9504bb93b2750147bf4fba961e89ddaf705ed33f Mon Sep 17 00:00:00 2001 From: Nadhiir Date: Thu, 9 Nov 2017 14:27:45 +0100 Subject: [PATCH 3/3] Update Tests to use latest google finance endpoint --- tests/Tests/Provider/GoogleFinanceProviderTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Tests/Provider/GoogleFinanceProviderTest.php b/tests/Tests/Provider/GoogleFinanceProviderTest.php index 6b50244..1658cb5 100644 --- a/tests/Tests/Provider/GoogleFinanceProviderTest.php +++ b/tests/Tests/Provider/GoogleFinanceProviderTest.php @@ -22,7 +22,7 @@ class GoogleFinanceProviderTest extends AbstractProviderTestCase */ public function it_throws_an_exception_when_rate_not_supported() { - $uri = 'http://www.google.com/finance/converter?a=1&from=EUR&to=XXL'; + $uri = 'https://finance.google.com/finance/converter?a=1&from=EUR&to=XXL'; $content = file_get_contents(__DIR__.'/../../Fixtures/Provider/GoogleFinance/unsupported.html'); $provider = new GoogleFinanceProvider($this->getHttpAdapterMock($uri, $content)); @@ -34,7 +34,7 @@ public function it_throws_an_exception_when_rate_not_supported() */ public function it_fetches_a_rate() { - $url = 'http://www.google.com/finance/converter?a=1&from=EUR&to=USD'; + $url = 'https://finance.google.com/finance/converter?a=1&from=EUR&to=USD'; $content = file_get_contents(__DIR__.'/../../Fixtures/Provider/GoogleFinance/success.html'); $provider = new GoogleFinanceProvider($this->getHttpAdapterMock($url, $content)); @@ -49,7 +49,7 @@ public function it_fetches_a_rate() */ public function it_has_no_php_errors() { - $url = 'http://www.google.com/finance/converter?a=1&from=EUR&to=USD'; + $url = 'https://finance.google.com/finance/converter?a=1&from=EUR&to=USD'; $content = file_get_contents(__DIR__.'/../../Fixtures/Provider/GoogleFinance/success.html'); $provider = new GoogleFinanceProvider($this->getHttpAdapterMock($url, $content));