Skip to content

Commit

Permalink
Update readme. Added back live integration testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielme85 committed Oct 21, 2019
1 parent 34e005c commit baee367
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,16 @@ There are static class "shortcuts" to convert or get one-time Currency series.
$valueNOK = Currency::conv($from = 'USD', $to = 'NOK', $value = 10, $decimals = 2);

//To convert a value based on historical data
$valueNOK = Currency::conv($from = 'USD', $to = 'NOK', $value = 10, $decimals = 2, $date = '2014-12-24');
$valueNOK = Currency::conv($from = 'USD', $to = 'NOK', $value = 10, $decimals = 2, $date = '2018-12-24');

//to get an array of all the rates associated to a base currency.
$rates = Currency::rates(); //defaults to USD

$rates = Currency::rates('NOK');

//Get historical rates
$rates = Currency::rates('NOK', '2014-12-24');
$rates = Currency::rates('NOK', '2018-12-24');

//Get historical rate series
$rates = Currency::rateSeries('USD', 'NOK', '2016-12-24', ''2016-12-31);
```

#### Working with multiple values
Expand Down Expand Up @@ -107,7 +105,7 @@ $result = Currency:conv(
$to = 'NOK',
$value = 10,
$decimals = 2,
$date = '2014-12-24',
$date = '2018-12-24',
$api = 'yahoo',
$https = false,
$useCache = false,
Expand Down
41 changes: 40 additions & 1 deletion tests/CurrencyConvertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* User: danielme85
* Date: 8/21/17
* Time: 9:21 PM
*/
*/

use danielme85\CConverter\Currency;

Expand Down Expand Up @@ -107,6 +107,20 @@ public function testFixer()
$this->assertEquals(1, $currency->convert('USD', 'USD', 1));
$this->assertEquals(1, $currency->convert('EUR', 'EUR', 1));
$this->assertEquals(1, $currency->convert('NOK', 'NOK', 1));

//Live test
$currency = new Currency('fixer', false);
$this->assertNotEmpty($currency->getRateResults());
$this->assertNotEmpty($currency->getRateResults('USD', '2019-01-01'));
$this->assertEquals(1, $currency->convert('USD', 'USD', 1));
$this->assertEquals(1, $currency->convert('EUR', 'EUR', 1));
$this->assertEquals(1, $currency->convert('NOK', 'NOK', 1));


$this->assertNotEmpty(Currency::rates('USD', '2019-01-01', 'fixer', false, true));
$this->assertEquals(1, Currency::conv('USD', 'USD', 1, null, '2019-01-01', 'fixer', false, true));
$this->assertEquals(1, Currency::conv('EUR', 'EUR', 1, null, '2019-01-01', 'fixer', false, true));

}

/**
Expand All @@ -122,6 +136,20 @@ public function testCurrencyLayer()
$this->assertEquals(1, $currency->convert('USD', 'USD', 1));
$this->assertEquals(1, $currency->convert('EUR', 'EUR', 1));
$this->assertEquals(1, $currency->convert('NOK', 'NOK', 1));

//Live test
$currency = new Currency('currencylayer', false);
$this->assertNotEmpty($currency->getRateResults());
$this->assertNotEmpty($currency->getRateResults('USD', '2019-01-01'));
$this->assertEquals(1, $currency->convert('USD', 'USD', 1));
$this->assertEquals(1, $currency->convert('EUR', 'EUR', 1));
$this->assertEquals(1, $currency->convert('NOK', 'NOK', 1));

$this->assertNotEmpty(Currency::rates('USD', '2019-01-01', 'currencylayer'));
$this->assertEquals(1, Currency::conv('USD', 'USD', 1, null, '2019-01-01', 'currencylayer', false, true));
$this->assertEquals(1, Currency::conv('EUR', 'EUR', 1, null, '2019-01-01', 'currencylayer', false, true));


}

/**
Expand All @@ -136,6 +164,17 @@ public function testOpenExchange()
$this->assertNotEmpty($currency->getRateResults());
$this->assertEquals(1, $currency->convert('USD', 'USD', 1));
$this->assertEquals(1, $currency->convert('EUR', 'EUR', 1));

//Live test
$currency = new Currency('openexchange', false);
$this->assertNotEmpty($currency->getRateResults());
$this->assertEquals(1, $currency->convert('USD', 'USD', 1));
$this->assertEquals(1, $currency->convert('EUR', 'EUR', 1));
$this->assertEquals(1, $currency->convert('NOK', 'NOK', 1));

$this->assertEquals(1, Currency::conv('USD', 'USD', 1, null, null, 'openexchange', false, true));
$this->assertEquals(1, Currency::conv('EUR', 'EUR', 1, null, null, 'openexchange', false, true));

}

/**
Expand Down

0 comments on commit baee367

Please sign in to comment.