Created
July 2, 2022 12:58
-
-
Save osteel/46d7b66c160a5af9c988ba9cd1281cbe to your computer and use it in GitHub Desktop.
PHP compatibility demo – library tests v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Osteel\PhpCompatibilityDemo\Tests; | |
use Money\Money; | |
use Osteel\PhpCompatibilityDemo\CurrencyHelper; | |
use PHPUnit\Framework\TestCase; | |
class CurrencyHelperTest extends TestCase | |
{ | |
public function testItReturnsWhetherCurrenciesAreTheSame() | |
{ | |
$helper = new CurrencyHelper(); | |
$amount1 = Money::EUR(10); | |
$amount2 = Money::EUR(20); | |
$amount3 = Money::EUR(15); | |
$amount4 = Money::USD(10); | |
$this->assertTrue($helper->isSame($amount1, $amount2)); | |
$this->assertTrue($helper->isSame($amount1, $amount2, $amount3)); | |
$this->assertFalse($helper->isSame($amount1, $amount4)); | |
$this->assertFalse($helper->isSame($amount1, $amount2, $amount4)); | |
} | |
public function testItReturnsNumericCode() | |
{ | |
$helper = new CurrencyHelper(); | |
$this->assertEquals(978, $helper->numericCode(Money::EUR(10))); | |
$this->assertEquals(840, $helper->numericCode(Money::USD(10))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment