drupalLogin() crashes where it should fail.

Created on 5 April 2014, almost 11 years ago
Updated 6 May 2023, almost 2 years ago

Problem/Motivation

I should be able to write a test that fails without crashing.

There are a number of SimpleTest assertions that crash rather than fail.

One of them is drupalLogin().

Typically, you do something like this:

$account = $this->drupalCreateUser(array('my special permission'));
$this->drupalLogin($account);

I should be able to write that test, run it, and have it fail without a code error, even before I implement hook_permission().

drupalCreateUser() does the right thing by returning FALSE if my permission doesn't exist.

drupalLogin() does the WRONG thing by using type hinting instead of checking its input. drupalLogin() should give me a fail if I don't have a valid user, rather than a code error.

Proposed resolution

Remove type hinting from drupalLogin(), and have it show a fail if the account object is invalid. Also, short-circuit the remaining login process.

Remaining tasks

User interface changes

API changes

🐛 Bug report
Status

Postponed: needs info

Version

9.5

Component
PHPUnit 

Last updated 4 days ago

Created by

🇺🇸United States mile23 Seattle, WA

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024