Download & Extend

TestingParty08: menu_set_item().

Project:Drupal core
Version:7.x-dev
Component:menu system
Category:task
Priority:critical
Assigned:Unassigned
Status:closed (fixed)
Issue tags:Needs tests

Issue Summary

Needs a test: http://api.drupal.org/api/function/menu_set_item/7

Comments

#1

Status:active» needs review

Hi,

Yusuf and I created a simple test for this function as part of our companies OpenAfternoon project. This code needs reviewing.

AttachmentSizeStatusTest resultOperations
menu_set_item.patch1.16 KBIdleFailed: 9732 passes, 1 fail, 0 exceptionsView details

#2

Status:needs review» reviewed & tested by the community

All tests pass.

#3

Status:reviewed & tested by the community» needs work

Ok, since this is a testingparty patch, I'm going to be merciless, because that helps you learn. Also, it's fun. :) Pay it forward!

<?php
Index
: modules/simpletest/tests/menu_set_item.test
?>

I would go ahead and add this to the existing menu.inc tests, which are in modules/simpletest/tests/menu.test.

<?php
+class menuSetItemTest extends DrupalWebTestCase {
?>

a) This line needs a sentence of PHPDoc above it explaining what's going on.
b) The class should be capitalized.
c) Also needs to be MenuSetItemTestCase.

<?php
+  function getInfo() {
?>

Please preface this function with PHPDoc that says "Implementation of getInfo()."

<?php
+      'name' => t('set menu item testcase'),
?>

a) Capitalize Set.
b) I would just call this 'Tests for menu_set_item()' since that's a little more clear.

<?php
+      'description' => t('Test menu_set_item functionality.'),
?>

Hm. Not sure that description's very useful. :) Could you be more specific? What does menu_set_item() do that's being tested?

<?php
+  function testMenuSetItem() {
?>

PHPDoc please. :)

<?php
+    $orig_item = menu_get_item('node');
?>

We don't abbreviate variable names. Should be $original_item. Needs to be changed throughout.

<?php
+    $this->assertEqual($orig_item['path'], 'node', t('Path from menu_get_item(\'node\') is equal to \'node\''), 'menu');
?>

Let's simply put that string in double quotes so you don't need all the escaping.

<?php
+    $orig_item['path'] = 'foobar';
+   
$orig_item['href'] = 'foobar';
+   
$orig_item['title'] = 'view foobar';
?>

Could we come up with values here that are a little more meaningful? Like can you think of a legitimate reason one might be changing these properties, or are you literally just throwing random stuff at it to see how it reacts?

<?php
+    $test_item = menu_set_item('node',$orig_item);
?>

Need a space after the comma.

<?php
+    $this->assertEqual($orig_item, $compare_item, t('Modified item is equal to newly gotten item'), 'menu');
?>

Gotten isn't really a word. Let's try retrieved.

That's all I could find. :) Thanks a lot!!

#4

Status:needs work» needs review

Ouch ! ... you sure are harsh, but ... okay, you were right in most cases.

The things about the random stuff is true but there are not that many cases in which I could find a use for this function, I could not even find a place where it was used in the whole Drupal code, but eventually we came up with some form use for it.

Here's the new patch, hope you like it ;)

AttachmentSizeStatusTest resultOperations
menu_set_item.patch1.87 KBIdleFailed: 9678 passes, 4 fails, 0 exceptionsView details

#5

Status:needs review» needs work

The inline code comments in this patch are not according to the Drupal conventions. Prefix with // and terminate your comments with a point. Almost there, ThiOz! :)

#6

Status:needs work» needs review

Finally I got some time to fix these minor issues ,

here's the new patch

C Ya

AttachmentSizeStatusTest resultOperations
menu_test.patch1.82 KBIdleFailed: 8163 passes, 1 fail, 0 exceptionsView details

#7

Hi

the patch made by eclipse wasn't made correctly so this one I made through the commandline

cheers

AttachmentSizeStatusTest resultOperations
menu_set_item_test.patch0 bytesIdlePassed: 11276 passes, 0 fails, 0 exceptionsView details

#8

Status:needs review» needs work

Patch is empty :(

#9

The new patch for menu_set_item()

AttachmentSizeStatusTest resultOperations
menu_set_item.patch2.08 KBIdleFailed: Failed to apply patch.View details

#10

Category:bug report» task
Status:needs work» needs review

Hi Wisif, you're missing a space in "modified for testing purposes,we "

Also, since core testing creates a completely clean drupal install and removes it once finished there's no need for 'Test:' prefixes. Otherwise this looks great. Marking to needs review to run it past the test bot.

#11

Status:needs review» needs work

The last submitted patch failed testing.

#12

Status:needs work» needs review

i rerolled the patch and changed the stuff from here http://drupal.org/node/293511#comment-1150200

AttachmentSizeStatusTest resultOperations
menu_set_item_4.patch1.67 KBIdleFailed: 9327 passes, 1 fail, 0 exceptionsView details

#13

Status:needs review» needs work

The prefix mention should be removed from the inline comment as well.
"// To make clear this is a testnode, we prefix the title."

#14

Status:needs work» needs review

thx for review,

i removed the previous comment and added a better description for the assert

AttachmentSizeStatusTest resultOperations
menu_set_item_5.patch2.04 KBIdlePassed: 11278 passes, 0 fails, 0 exceptionsView details

#15

Spotted a couple more nitpicks, sorry this is so piecemeal, rather than marking CNW I've re-rolled with the changes.

AttachmentSizeStatusTest resultOperations
menu_set_item.patch1.11 KBIdlePassed: 11278 passes, 0 fails, 0 exceptionsView details

#16

Component:tests» menu system

#17

Even smaller nitpick: we should be using single quotes in the second assertion, no need to use double quotes. Patch rerolled accordingly.

AttachmentSizeStatusTest resultOperations
menu_set_item_7.patch1.23 KBIdlePassed: 11257 passes, 0 fails, 0 exceptionsView details

#18

Status:needs review» reviewed & tested by the community

Yay more tests!

#19

Status:reviewed & tested by the community» fixed

Committed to CVS HEAD. Thanks.

#20

Status:fixed» closed (fixed)

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

nobody click here