/**
  * Test that the collection trees are properly built
  */
 public function testCollectionTreeBuilder()
 {
     $treeBuilder = new FormTreeBuilder();
     $keyBuilder = new FormKeyBuilder();
     $form = $this->factory->createNamed('foo', 'form');
     $form->add('bar', 'collection', array('type' => 'text', 'allow_add' => true, 'allow_delete' => true));
     $view = $form->createView();
     $barTree = $treeBuilder->getTree($view['bar']);
     $prototypeTree = $treeBuilder->getTree($view['bar']->vars['prototype']);
     $barLabel = $keyBuilder->buildKeyFromTree($barTree, 'label');
     $prototypeLabel = $keyBuilder->buildKeyFromTree($prototypeTree, 'label');
     $this->assertEquals('form.foo.children.bar.label', $barLabel);
     $this->assertEquals('form.foo.children.bar.prototype.label', $prototypeLabel);
 }
 /**
  * Test that the collection trees are properly built
  */
 public function testCollectionTreeBuilder()
 {
     $treeBuilder = new FormTreeBuilder();
     $form = $this->factory->createNamed('foo', 'form');
     $form->add('bar', 'collection', array('type' => 'text', 'allow_add' => true, 'allow_delete' => true));
     $formView = $form->createView();
     $tree = $treeBuilder->getTree($formView['bar']->vars['prototype']);
     $this->assertEquals(true, $tree[1]->hasChildren());
     $this->assertEquals(true, $tree[1]->isCollection());
     $this->assertEquals(false, $tree[1]->isPrototype());
     $this->assertEquals(3, count($tree));
     $this->assertEquals(false, $tree[2]->hasChildren());
     $this->assertEquals(false, $tree[2]->isCollection());
     $this->assertEquals(true, $tree[2]->isPrototype());
 }