Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 301100

drupalLogin() crashes where it should fail.

$
0
0

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


Viewing all articles
Browse latest Browse all 301100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>