expectException replaced the annotation, with a deadline

The @expectedException annotation asserts the exception happened somewhere in the method, which passes when it is thrown by the arrangement rather than by the thing under test.

// deprecated in 8, gone in 9
/** @expectedException AppPaymentDeclined */
public function testDeclined() { /* ... */ }

// the assertion sits next to the call it is about
public function testDeclined(): void
{
    $gateway = new Gateway($this->declinedClient());

    $this->expectException(PaymentDeclined::class);
    $this->expectExceptionMessage('insufficient funds');

    $gateway->charge($this->card, Money::gbp(4900));
}

Placing the expectation immediately before the call is the whole improvement — everything above it is arrangement and is asserted normally. expectExceptionMessage does a substring match rather than an equality one, which is usually what you want and occasionally matches something you did not intend. Anything after the throwing call never executes, so an assertion placed there is silently skipped rather than failing.