<commit_before><?php

require_once dirname(__FILE__).'/../../../bootstrap/functional.php';
require_once $_SERVER['SYMFONY'].'/vendor/lime/lime.php';

$t = new lime_test(0);<commit_msg>Writing test for ioDoctrineMenuItemTable. No other changes needed - it passed on the first try.<commit_after><?php

require_once dirname(__FILE__).'/../../../bootstrap/functional.php';
require_once $_SERVER['SYMFONY'].'/vendor/lime/lime.php';
require_once sfConfig::get('sf_lib_dir').'/test/unitHelper.php';

$t = new lime_test(54);
$tbl = Doctrine_Core::getTable('ioDoctrineMenuItem');

$t->info('1 - Add a tree to an existing node. This should have the same effect as using ioDoctrineMenuItem::persistFromMenuArray()');
  $rt = create_root('rt');
  $arr = create_test_tree($t);
  $menu = $arr['menu'];
  $menu['Parent 1']->setAttributes(array('class' => 'parent1'));
  $menu['Parent 1']['Child 2']->setCredentials(array('c2', 'c3'));
  print_test_tree($t);

  $tbl->persist($menu, $rt);
  complex_root_menu_check($rt, $t, 2);
  test_total_nodes($t, array(0 => 1, 1 => 2, 2 => 4, 3 => 1));
  root_sanity_check($t, $rt);

$t->info('1 - Persist an entire menu to a new root. This should have the same effect as above, but creates the root for us.');
  $tbl->createQuery()->delete()->execute();
  $tbl->persist($menu);
  $rt = $tbl->findOneByLevel(0);
  complex_root_menu_check($rt, $t, 2);
  test_total_nodes($t, array(0 => 1, 1 => 2, 2 => 4, 3 => 1));
  root_sanity_check($t, $rt);
  $t->is($rt->getName(), 'Root li', 'The created root has the correct name.');
  $t->is($rt->getAttributes(), 'class="root"', 'The created root has the correct attributes.');
{'fraction_non_alphanumeric': 0.2048780487804878, 'fraction_numerical': 0.018292682926829267, 'mean_word_length': 5.192452830188679, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4152871', 'n_tokens_mistral': 599, 'n_tokens_neox': 573, 'n_words': 139}