Skip to content

Instantly share code, notes, and snippets.

@osteel
Created July 2, 2022 12:58
Show Gist options
  • Save osteel/46d7b66c160a5af9c988ba9cd1281cbe to your computer and use it in GitHub Desktop.
Save osteel/46d7b66c160a5af9c988ba9cd1281cbe to your computer and use it in GitHub Desktop.
PHP compatibility demo – library tests v1
<?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