$user->uid is always 1 when running automated tests
It happens exactly what described in the documentation page for DrupalWebTestCase::drupalLogin().


  Please note that neither the global $user nor the passed-in user object is populated with data of the logged in user. If you need full access to the user object after logging in, it must be updated manually. If you also need access to the plain-text password of the user (set by drupalCreateUser()), e.g. to log in the same user again, then it must be re-assigned manually. For example:

  // Create a user.
  $account = $this-&gt;drupalCreateUser(array());
  $this-&gt;drupalLogin($account);
  // Load real user object.
  $pass_raw = $account-&gt;pass_raw;
  $account = user_load($account-&gt;uid);
  $account-&gt;pass_raw = $pass_raw;