Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ksdev-pl committed Jul 5, 2015
1 parent 85e6e72 commit 6c04da0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/BCMathHelperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Ksdev\NBPCurrencyConverter\Test;

use Ksdev\NBPCurrencyConverter\BCMathHelper;

class BCMathHelperTest extends \PHPUnit_Framework_TestCase
{
public function testBcround()
{
$this->assertEquals('0.5679', BCMathHelper::bcround('0.567891', 4));
$this->assertEquals('0.5676', BCMathHelper::bcround('0.567591', 4));
$this->assertEquals('0.5676', BCMathHelper::bcround('0.567559', 4));
$this->assertEquals('0.5675', BCMathHelper::bcround('0.567544', 4));
}
}
6 changes: 6 additions & 0 deletions tests/NBPCurrencyConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public function testConvert()
{
$converter = new NBPCurrencyConverter($this->guzzleMock(), null, 0);

$this->assertEquals('0.2651', $converter->convert('1.0000', 'PLN', 'USD')['amount']);
$this->assertEquals('3.7726', $converter->convert('1.0000', 'USD', 'PLN')['amount']);
$this->assertEquals('123.4567', $converter->convert('123.4567', 'PLN', 'PLN')['amount']);
$this->assertEquals('32.7246', $converter->convert('123.4567', 'PLN', 'USD')['amount']);
$this->assertEquals('465.7527', $converter->convert('123.4567', 'USD', 'PLN')['amount']);
Expand All @@ -38,6 +40,10 @@ public function testConvert()
$this->assertEquals('284.0662', $converter->convert('123.4567', 'JPY', 'HUF')['amount']);
$this->assertEquals('53.6549', $converter->convert('123.4567', 'HUF', 'JPY')['amount']);
$this->assertEquals('123.4567', $converter->convert('123.4567', 'JPY', 'JPY')['amount']);
$this->assertEquals('53654981.1634', $converter->convert('123456789.6789', 'HUF', 'JPY')['amount']);
$this->assertEquals('284066429.3850', $converter->convert('123456789.6789', 'JPY', 'HUF')['amount']);
$this->assertEquals('32724590.3830', $converter->convert('123456789.6789', 'PLN', 'USD')['amount']);
$this->assertEquals('465753084.7426', $converter->convert('123456789.6789', 'USD', 'PLN')['amount']);
}

public function testInvalidFormatOfAmount()
Expand Down

0 comments on commit 6c04da0

Please sign in to comment.