Problem/Motivation

Drupal 8 has dropped hook_menu() in favor of hook_menu_links_default(), which in turn has been superseded by the use of YAML files.

Change records here:

https://drupal.org/node/2228089
Many of the D8 examples still have hook_menu(), and these should be converted.

Also, in accordance with the Examples module checklist, each of these menu paths should have a functional test, to make sure they work properly. As it is, the tests for these modules should be failing, due to the API change, but they aren't.

Proposed resolution

Convert the PHPUnit Example module to using *.menu_links.yml files.
Write a test which verifies that
1) The menu links appear on the front page, and also that
2) A request to each link yields a result of 200.
Remaining tasks
User interface changes
API changes

Follow-up from #2223291: Change all hook_menu() implementations to *.menu_links.yml files, add tests: Change all hook_menu() implementations to *.menu_links.yml files, add tests.

Comments

piestep’s picture

StatusFileSize
new2.62 KB

This patch updates PHPUnit example to *.menu_links.yml and adds a Menu test. It passes all the tests in lib/Drupal/phpunit_example/Tests, however; their seem to be some additional tests in tests/Drupal/phpunit_example/Tests. When these tests are run on my Windows based system using the instructions given, modified for Windows, they all pass. I need to look into if these tests need to be run to ensure the patch works.

mile23’s picture

Status: Active » Needs review

Thanks, piestep.

If you set the issue to 'needs review,' the testbot can test the patch automatically.

mile23’s picture

StatusFileSize
new3.29 KB
new4.74 KB
+++ b/phpunit_example/lib/Drupal/phpunit_example/Tests/PHPUnitExampleMenuTest.php
@@ -0,0 +1,60 @@
+  /**
+   * Tests phpunit_example menus.
+   */
+  public function testPHPUnitExampleMenu() {
+    $this->drupalGet('examples/phpunit_example');
+    $this->assertResponse(200, 'Description page exists.');
+  }

This duplicates another test that already exists. But that's OK, because we can just remove the other one and refactor this one a bit.

New patch has fancy dataprovider type thing for checking the menu links. This will be the new template for the rest of the examples project.

If this comes back green, it's commit time. :-)

  • Commit 4b68add on 8.x-1.x authored by piestep, committed by Mile23:
    Issue #2276929 by Mile23, piestep: Update PHPUnit Example to use *....
mile23’s picture

Status: Needs review » Fixed

Aaaaand done.

Thanks, piestep!

piestep’s picture

StatusFileSize
new2.47 KB

Had a few other changes -- 1) Added the implementation of hook_help() so help will now appear on the Admin Help Page. 2) Added commands on PHPUnit Example page for executing phpunit on Window-based systems.

I assume I can add these minor changes but I don't see how to get it to retest after a fix. Will it be done automatically.

mile23’s picture

Status: Fixed » Needs work
+++ b/phpunit_example/phpunit_example.module
@@ -18,9 +18,9 @@
-    case 'examples/phpunit_example':
-      // Help text for the simple page registered for this path.
-      return t('This is the help text for PHPUnit example.');
+    case 'help.page.phpunit_example':
+      // Help text for the admin section, using the module name in the path.
+      return t("This is help text created in phpunit example's implementation of hook_help().");

Hehe.. I guess we should have something more substantive here, either way. :-)

piestep’s picture

I was thinking that if we used the markup text in the controller and placed it in the PHPUnit Example help page and then link the Tool menu item to the PHPUnit Example help page it would provide the information for both.

mile23’s picture

Having the text in one place and then reusing it is a generally good idea, but if it's on the examples/phpunit_example path, it will just appear twice on the page.

hook_help() is useful to us if we need other content in a help box, or if we have special instructions for the module.

In this case, we could just remove it.

mile23’s picture

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

Removed hook_help(), added Windows instructions.

mile23’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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