CRM-20927 - civicrm_menu - Add test for reading/writing `module_data`
authorTim Otten <totten@civicrm.org>
Thu, 20 Jul 2017 06:07:25 +0000 (23:07 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 4 Aug 2017 00:13:04 +0000 (17:13 -0700)
tests/phpunit/CRM/Core/MenuTest.php

index b48a5f5cd42abdc5de1c4cc0b97db37c9eb859ca..360198e22a03817d175b6b72f110d6871e265a59 100644 (file)
@@ -6,6 +6,27 @@
  */
 class CRM_Core_MenuTest extends CiviUnitTestCase {
 
+  /**
+   * Check that novel data elements in the menu are correctly
+   * stored and loaded.
+   */
+  public function testModuleData() {
+    CRM_Core_Menu::store(TRUE);
+    $item = CRM_Core_Menu::get('civicrm/case');
+    $this->assertFalse(isset($item['ids_arguments']['exception']));
+    $this->assertFalse(isset($item['whimsy']));
+
+    CRM_Utils_Hook::singleton()->setHook('civicrm_alterMenu', function(&$items){
+      $items['civicrm/case']['ids_arguments']['exception'][] = 'foobar';
+      $items['civicrm/case']['whimsy'] = 'godliness';
+    });
+
+    CRM_Core_Menu::store(TRUE);
+    $item = CRM_Core_Menu::get('civicrm/case');
+    $this->assertTrue(in_array('foobar', $item['ids_arguments']['exception']));
+    $this->assertEquals('godliness', $item['whimsy']);
+  }
+
   /**
    * @return array
    */