Comments

ThiOz’s picture

Status: Active » Needs review
StatusFileSize
new1.16 KB

Hi,

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

dsel’s picture

Status: Needs review » Reviewed & tested by the community

All tests pass.

webchick’s picture

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!

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.

+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.

+  function getInfo() {

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

+      '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.

+      '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?

+  function testMenuSetItem() {

PHPDoc please. :)

+    $orig_item = menu_get_item('node');

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

+    $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.

+    $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?

+    $test_item = menu_set_item('node',$orig_item);

Need a space after the comma.

+    $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!!

ThiOz’s picture

Status: Needs work » Needs review
StatusFileSize
new1.87 KB

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 ;)

dries’s picture

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! :)

ThiOz’s picture

Status: Needs work » Needs review
StatusFileSize
new1.82 KB

Finally I got some time to fix these minor issues ,

here's the new patch

C Ya

ThiOz’s picture

StatusFileSize
new0 bytes

Hi

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

cheers

grndlvl’s picture

Status: Needs review » Needs work

Patch is empty :(

Wisif’s picture

StatusFileSize
new2.08 KB

The new patch for menu_set_item()

catch’s picture

Category: bug » 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.

Status: Needs review » Needs work

The last submitted patch failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.67 KB

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

catch’s picture

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."

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new2.04 KB

thx for review,

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

catch’s picture

StatusFileSize
new1.11 KB

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

catch’s picture

Component: tests » menu system
Issue tags: +Needs tests
cwgordon7’s picture

StatusFileSize
new1.23 KB

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

chx’s picture

Status: Needs review » Reviewed & tested by the community

Yay more tests!

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -Needs tests

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