Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

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? (31 h 16 min)

You also get:

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

Already a member? Login here

Comments & Discussion

No comments yet…