Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#37308 closed defect (bug) (fixed)

`wp_insert_user()` test failing due to database autoincrement

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 4.6 Priority: normal
Severity: normal Version:
Component: Users Keywords:
Focuses: Cc:

Description

For about a week (since [37905] for me, though it's largely inconsequential), Tests_User::test_wp_insert_user_with_invalid_user_id() has been failing for me. The reason is that the ID 123 is hardcoded there, but there is an existing user in the installation with the ID 123. There are two problems:

  • If the point of test_wp_insert_user_with_invalid_user_id() is to test a truly invalid ID, it should check for the ID's invalidity first. This is an easy fix.
  • By the time the suite gets to test_wp_insert_user_with_invalid_user_id() (after about 5900 tests), there are 6 users in the wp_users table. This means that some tests are not cleaning up their mess.

I'll see if I can track it down.

Change History (3)

#1 @boonebgorges
9 years ago

  • Owner set to boonebgorges
  • Status changed from new to assigned

#2 @boonebgorges
9 years ago

By the time the suite gets to test_wp_insert_user_with_invalid_user_id() (after about 5900 tests), there are 6 users in the wp_users table. This means that some tests are not cleaning up their mess.

I was wrong about the leakage - the users are created in setUpBeforeClass(). It just so happens that one of them has the ID 123, because of the database autoincrement. Fixing the first bullet point should be enough.

#3 @boonebgorges
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 38005:

Tests: Ensure that test for invalid user ID actually uses an invalid user ID.

This prevents false positives when the ID column's incrementor has exceeded the
hardcoded invalid ID.

Fixes #37308.

Note: See TracTickets for help on using tickets.