Problem/Motivation

As title.

Proposed resolution

For example:

-    $this->assertFalse(!empty($view->build_info['pre_render_called']), 'Make sure hook_views_pre_render is not called for the cached view.');
+    $this->assertEmpty($view->build_info['pre_render_called']);

Not sure about whether to keep or drop the $message arguments here, though.

Comments

gena.io created an issue. See original summary.

gena.io’s picture

gena.io’s picture

Status: Needs work » Needs review
jonathan1055’s picture

Thanks gena.io for the patch.
I can see that in your example the new version is definitely clearer and easier to read/understand. Is there a specific Drupal best practise statement about this? or did you just decide that it would be an improvement

jonathan1055’s picture

Issue summary: View changes
StatusFileSize
new1.91 KB

Just tried this

grep -nir . -e 'assert.*(.*empty' --exclude=\*.patch --exclude-dir=.git

which shows that the two you have identified are the only assertions which have 'empty' within the arguments.

Not sure about whether to keep or drop the $message arguments here, though.

Unlike some of the replcement assertions, these do accept a message parameter. I've changed the text to say what should be the case, as the message is only shown when there is a failure. This makes it clearer to understand what has happened when viewing the output.

Re-rolled the patch due to #3084931-9: Remove calls to deprecated method assertEqual() and replace with assertEquals(). I have also used assertEquals for the length, instead of assertTrue(strLen() ...)

  • jonathan1055 committed 2c69645 on 8.x-1.x authored by gena.io
    Issue #3150473 by gena.io, jonathan1055: Replace assertions involving...
jonathan1055’s picture

Status: Needs review » Fixed

Thanks @gena.io for starting this off.
Committed and fixed.

jonathan1055’s picture

Assigned: gena.io » Unassigned

Unassigning.

Status: Fixed » Closed (fixed)

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