EntityShareClientFunctionalTestBase::createRemote() prevents exceptions from failing tests

Created on 13 May 2025, 2 days ago

Problem/Motivation

I'm trying to fix 🐛 CI broken Active , and one test is failing here:

    try {
      $access_token = $plugin->initializeToken($remote, $credentials);
    }
    catch (\Exception $e) {
      $this->fail('The access token had not been generated.');
    }

Catching an exception just to fail a test looks like a code smell to me -- phpunit fails on an exception anyway, and you get the exception message and backtrace too, rather than it being obscured as it is here.

Except when I remove the try/catch from this call, the test passes!???

I've experimented with putting a line ' throw new \Exception('FAIL');' in various places in the test, and narrowed it down to here in EntityShareClientFunctionalTestBase::setUp():

    $this->createRemote($this->channelUser);
    throw new \Exception('FAIL');

This exception does not cause the test to fail!

The problem is that EntityShareClientFunctionalTestBase::setUp() calls createAuthenticationPlugin(), which the test class overrides, and has a try/catch block there.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024