Download & Extend

Wrong count assertion in taxonomy.test

Project:Drupal core
Version:7.x-dev
Component:base system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:needs backport to D7, Novice

Issue Summary

Problem/Motivation

There is a wrong assertion in taxonomy.test that always evaluates to TRUE.

$this->assertTrue(count($terms4 == 4), 'Correct number of terms were loaded.');

This is always TRUE. It should at least be count($terms4) == 4. However, it would be better to replace the assertion with assertEqual(): $this->assertEqual(count($terms4), 4, ...).

Proposed resolution

  • Change the mentioned line of code to assertEqual() and fix the count().
  • Look for other places in the file that could be done using assertEqual() instead of assertTrue() to simplify the code.

Remaining tasks

This should only be done once both #1160566: entity_load() is actually entity_load_multiple() and #1195254: Taxonomy test cleanup have been commited (the the second already has been commited to 8.x, only needs to be commited to 7.x, the first will not be backported) because both patches currently touch that line or come too close so that it will need a re-roll.

Comments

#1

Issue tags:+needs backport to D7

Updated the summary.

#2

Status:active» needs review

Here is a D7 patch for this.

AttachmentSizeStatusTest resultOperations
1542674-d7.patch684 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1542674-d7.patch. Unable to apply patch. See the log in the details link for more information.View details

#3

Status:needs review» needs work

The last submitted patch, 1542674-d7.patch, failed testing.

#4

Status:needs work» active

Ignore the last patch, too premature.

#5

Looks like it was just rolled against D7. :) It needs to be fixed in D8 first.

#6

Yep, I got it all wrong on this one I'm afraid :)

#7

Here is a D8 patch with assertEqual instead of assertTrue where appropriate.

AttachmentSizeStatusTest resultOperations
1542674-7.patch3.59 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1542674-7.patch. Unable to apply patch. See the log in the details link for more information.View details

#8

Status:active» needs review

#9

Isn't this issue still waiting on other issues above?

#10

#7: 1542674-7.patch queued for re-testing.

#11

Status:needs review» needs work

The last submitted patch, 1542674-7.patch, failed testing.

#12

Status:needs work» needs review

Re-rolled to apply after #1160566: entity_load() is actually entity_load_multiple() has been commited

AttachmentSizeStatusTest resultOperations
1542674-12.patch3.59 KBIdlePASSED: [[SimpleTest]]: [MySQL] 35,372 pass(es).View details

#13

Status:needs review» reviewed & tested by the community

Looks good to me.

#14

Version:8.x-dev» 7.x-dev

Nice catch, and good clean-up. Committed to 8.x. Moving to 7.x.

#15

Version:7.x-dev» 8.x-dev

It doesn't look like this was pushed to D8 yet.

#16

#17

Status:reviewed & tested by the community» needs review

Rerolled.

AttachmentSizeStatusTest resultOperations
drupal-1542674-17.patch3.58 KBIdleFAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in modules/taxonomy/taxonomy.test.View details

#18

Status:needs review» needs work

The last submitted patch, drupal-1542674-17.patch, failed testing.

#19

Status:needs work» needs review

I mismatched the parenthesis on that weird count() line.

AttachmentSizeStatusTest resultOperations
drupal-1542674-19.patch3.58 KBIdlePASSED: [[SimpleTest]]: [MySQL] 38,858 pass(es).View details

#20

Status:needs review» reviewed & tested by the community

Looks correct.

#21

Status:reviewed & tested by the community» fixed

wow, nice catch. committed and pushed to 7.x. thanks!

#22

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.