diff --git a/modules/simpletest/tests/menu.test b/modules/simpletest/tests/menu.test index f5d7d290fc..5d30cf790a 100644 --- a/modules/simpletest/tests/menu.test +++ b/modules/simpletest/tests/menu.test @@ -1738,3 +1738,47 @@ class MenuTrailTestCase extends MenuWebTestCase { } } } +/** + * Tests value integrity. + */ +class MenuDataIntegrityTestCase extends MenuWebTestCase { + public static function getInfo() { + // This is just one test for weight but more can be added in future. + return array( + 'name' => 'Menu item array integrity', + 'description' => 'Tests the values passed on to menu items array.', + 'group' => 'Menu', + ); + } + + function setUp() { + $modules = func_get_args(); + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + $modules[] = 'menu_test'; + parent::setUp($modules); + } + /** + * Tests for null/casting weight parameter. + */ + function testNullMenuWeight() { + $base_options = array( + 'link_title' => 'Menu link test', + 'module' => 'menu_test', + 'menu_name' => 'menu_test', + 'weight' => NULL, + 'link_path' => 'menu-test/parent' + ); + + // Catch and check for the PDO. + try { + menu_link_save($base_options); + } catch (PDOException $exception) { + $this->assert(FALSE, "Menu weight is not being casted properly."); + return ; + } + // if no PDO pass the test. + $this->assert(TRUE, "Menu weight is being casted properly."); + } +}