Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
$bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
// Check to see if the custom block was created by checking that it's in the database.
$this->assertNotNull($bid, t('Custom block found in database'));
fetchField will return false if there is nothing to fetch or the value of the field if the query gets a result. In both cases assertNotNull is going to be TRUE, so that test is testing nothing at all. The correct assertion would be to assert it is not false, assertTrue.
Comment | File | Size | Author |
---|---|---|---|
#3 | 1018618-block-3.patch | 1.08 KB | joshi.rohit100 |
#1 | 1018618-block-1.patch | 1.24 KB | manfer |
Comments
Comment #1
manfer CreditAttribution: manfer commentedHere is a patch correcting the two places were that incorrect assertion appears.
Comment #2
dcam CreditAttribution: dcam commentedI was looking through some old issues and found this one. It looks like a valid bug to me. I checked D8 for these assertions and they seem to have been removed completely due to the major changes in the Block module. #1 just needs to be rerolled for 7.x.
Comment #3
joshi.rohit100Rerolled the patch.
Comment #4
dcam CreditAttribution: dcam commentedThis looks good to me. Thank you, @joshi.rohit100!
Comment #5
David_Rothstein CreditAttribution: David_Rothstein commentedCommitted to 7.x - thanks!