Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#37308 closed defect (bug) (fixed)

`wp_insert_user()` test failing due to database autoincrement

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

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
10 years ago

  • Owner set to boonebgorges
  • Status new → assigned

#2 @boonebgorges
10 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
10 years ago

  • Resolution → fixed
  • Status assigned → 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.