Problem/Motivation

This issue came out in #2787873: Add a base class for entity reference selection handlers and fix the structure of their configuration.

As we are deprecating functions/methods we are starting to emit deprecation errors @trigger_error('...', E_USER_DEPRECATED). Right now there's now way to test such errors and, in general, all kind of errors that are not exceptions.

Proposed resolution

Provide a trait with two methods to be used with unit, kernel and browser/javascript tests:

trait ErrorTestTrait {
 
  protected function assertError($message, $severity) {...}

  protected function assertNoError($message, $severity) {...}

}

Remaining tasks

Discuss. Agree. Implement.

User interface changes

None.

API changes

New trait ^^^.

Data model changes

None.

Comments

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Issue summary: View changes
dawehner’s picture

dawehner’s picture

Oh wait, maybe I'm confused. Can't you test assertions already as phpunit will convert it to an exception?

alexpott’s picture

Yes I'm pretty sure #2488860: Bring phpunit bridge into drupal and use it for unit tests and simpletest to handle Deprecation is the way we want to test @trigger_error('...', E_USER_DEPRECATED). In fact I'll really like to get that done rather than adding odd tests.

claudiu.cristea’s picture

@dawehner, does PHPUnit convert errors into exceptions? Hm, I didn't know this.

claudiu.cristea’s picture

I see. I missed the other issue.

claudiu.cristea’s picture