Coming from #2822837: Replace @expectedException @expectedExceptionMessage with $this->setExpectedException.

Using that annotations is bad practice, so we should add a sniff to DrupalPractice that creates a warning.

Comments

klausi created an issue. See original summary.

Anonymous’s picture

In addition there are:

  • @expectedExceptionMessageRegExp - drupal core has 3 cases
  • @expectedExceptionCode - drupal core hasn't cases, but contrib modules have it (eg. acquia_lift)
claudiu.cristea’s picture

Issue tags: +needs documentation updates

Documentation needs update too, when this lands: https://www.drupal.org/docs/8/phpunit

  • klausi committed 984c54a on 8.x-2.x
    feat(ExpectedExceptionSniff): Add sniff to forbid usage of PHPUnit @...
klausi’s picture

Status: Active » Fixed

Pushed a new sniff.

klausi’s picture

Assigning credits.

Anonymous’s picture

Super news!! You saved our issue again!

Only one absolutely nit typo:
$warning = '%s tags should not be used, use $§this->setExpectedException() or $this->expectException() instead';
$

  • klausi committed 79e8249 on 8.x-2.x
    style(ExpectedExceptionSniff): Fix typo in sniff message (#2859286)
    
klausi’s picture

Thanks, fixed that typo.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.