Much of MenuTest has been written a long time ago, and this is apparent in the documentation, and in the poor choice of some variable names (e.g. '$big_user' to store an administrator). Let's clean it up a bit.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pfrenssen’s picture

Status: Active » Needs review
FileSize
16.22 KB

Here's a patch.

  • Ordered the module list alphabetically.
  • Renamed $big_user to $admin_user
  • Renamed $std_user to $authenticated_user
  • Removed unused parameter $menu in deleteCustomMenu().
  • Fixed whitespace and punctuation issues.
  • Improved documentation.
  • Rewrote some assert messages that were mistakenly referring to admin pages as 'nodes'.

Status: Needs review » Needs work
Issue tags: -Novice

The last submitted patch, 2093849-1-menutest-cleanup.patch, failed testing.

pfrenssen’s picture

Status: Needs work » Needs review
Issue tags: +Novice

#1: 2093849-1-menutest-cleanup.patch queued for re-testing.

angel.h’s picture

Assigned: Unassigned » angel.h
angel.h’s picture

Status: Needs review » Needs work
angel.h’s picture

+++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
@@ -168,11 +195,12 @@ function addCustomMenu() {
-  function deleteCustomMenu($menu) {
+  function deleteCustomMenu() {

You removed the argument but the menu object is still passed as a parameter:

// Delete custom menu.
$this->deleteCustomMenu($this->menu);

in testMenu().

Also for 3 methods the menu id is passed as parameter:

$this->doMenuTests($this->menu->id());
$this->addInvalidMenuLink($this->menu->id());
$this->verifyAccess(403, $this->menu->id());

although this is quite unnecessary - OOP :) - we can use it directly in the methods like it was done here:

function deleteCustomMenu($menu) {
  $menu_name = $this->menu->id();

ignoring the unnesessary argument.

I created a new patch with all this in mind. You can also see an interdiff.

angel.h’s picture

Assigned: angel.h » Unassigned
Status: Needs work » Needs review
pfrenssen’s picture

Nice catch! The test looks much better now.

pfrenssen’s picture

Status: Needs review » Needs work

The last submitted patch, 6: 2093849-6-menutest-cleanup.patch, failed testing.

pfrenssen’s picture

Patch still applies cleanly, and locally this test is green. Retesting.

pfrenssen’s picture

Status: Needs work » Needs review
parthipanramesh’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Good job!

webchick’s picture

xjm’s picture

xjm’s picture

Priority: Normal » Minor

Nice work! Recategorizing as minor since it is pure cleanup for test code.

xjm’s picture

Issue tags: +RTBC 4+ weeks

Also, this patch was RTBCed Nov. 28 and has just been retested since.

catch’s picture

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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

xjm’s picture

Issue tags: -RTBC over 4 weeks