phpunit测试-无法断言两个字符串相等

时间:2019-12-07 16:10:48

标签: laravel phpunit currency

这怎么可能? phpunit结果:

--- Expected
+++ Actual
@@ @@
-'€ 10,00'
+'€ 10,00'

代码:

$product = factory(Product::class)->create([
    'price' => 1000
]);

$this->assertEquals($product->formattedPrice, '€ 10,00');

我正在使用此类来设置我的货币和语言环境: (省略其他功能)

class Money
{
    protected $money;
    public function __construct($value)
    {
        $this->money = new BaseMoney($value, new Currency('EUR'));
    }

    public function formatted()
    {
        $formatter = new IntlMoneyFormatter(
            new \NumberFormatter('nl_BE', NumberFormatter::CURRENCY),
            new ISOCurrencies()
        );
        return $formatter->format($this->money);
    }
}

0 个答案:

没有答案