Skip to main content

Assertion Error Messages

Premium
2 min read

This lesson is a "quick tip" to emphasize that you need to pick the proper assertion to get the correct assertion error.


For example, we have a simple Service for converting currencies.

app/Services/CurrencyService.php:

class CurrencyService
{
const RATES = [
'usd' => [
'eur' => 0.98
],
];
 
public function convert(float $amount, string $currencyFrom, string $currencyTo): float
{
$rate = self::RATES[$currencyFrom][$currencyTo] ?? 0;
 
return round($amount * $rate, 2);
}
}

Then, in the unit test, we expect the...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (36 h 00 min)

You also get:

61 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

No comments yet…