$t->info(' 2.1 - First try it without any children - should just update root values.'); $t->info(' 2.1.1 - Persist a menu with mostly blank fields.'); $rt = create_root('rt'); $menu->setAttributes(array()); // clear the default "root" class attribute $rt->persistFromMenuArray($menu->toArray(false)); $t->is($rt->getName(), 'Root li', '->getName() returns "Root li".'); $t->is($rt->getLabel(), null, '->getLabel() returns null.'); $t->is($rt->getRoute(), null, '->getRoute() returns null.'); $t->is($rt->getAttributes(), '', '->getAttributes() returns an empty string.'); $t->is($rt->getRequiresAuth(), false, '->getRequiresAuth() returns false.'); $t->is($rt->getRequiresNoAuth(), false, '->getRequiresNoAuth() returns false.'); $t->is(count($rt->Permissions), 0, '->Permissions matches 0 items'); // setup some interesting values to persist $menu->setLabel('sympal'); $menu->setRoute('http://www.sympalphp.org'); $menu->setAttributes(array('class' => 'root', 'id' => 'sympal_menu')); $menu->requiresAuth(true); $menu->requiresNoAuth(false); $menu->setCredentials(array(array('c1', 'c2'))); $t->info(' 2.1.2 - Persisting a menu with multi-level credentials is not supported - an exception is thrown.'); $rt = create_root('rt'); try { $rt->persistFromMenuArray($menu->toArray(false)); $t->fail('Exception not thrown'); } catch (sfException $e) { $t->pass('Exception thrown: ' . $e->getMessage()); } $t->info(' 2.1.3 - Persist a valid menu item with several different fields filled in (no refresh).'); $rt = create_root('rt'); $menu->setCredentials(array('c1', 'c2'));