Esempio n. 1
0
 public function testCollectConfig()
 {
     $this->builder->add('id', 'text');
     $this->builder->add('name', 'text', array('format' => '#%s!', 'title' => 'name'));
     $table = $this->builder->getTable();
     $valueExporter = new ValueExporter();
     $dataCollector = new TableDataCollector($valueExporter);
     $this->resolvedOptions['_passed_options'] = array('a' => 1, 'b' => 'x');
     $dataCollector->collectConfig($table, null, $this->resolvedOptions);
     $columns = $this->builder->getColumns();
     $expected = array('test' => array('id' => 'foo', 'name' => 'foo', 'type' => 'foo', 'type_class' => 'EMC\\TableBundle\\Tests\\Table\\Type\\FooType', 'passed_options' => array('a' => 1, 'b' => 'x'), 'resolved_options' => array('allow_select' => 'false', 'attrs' => '[]', 'caption' => '', 'data' => 'null', 'data_provider' => $valueExporter->exportValue($this->dataProvider), 'default_sorts' => '[]', 'limit' => '10', 'name' => 'foo', 'params' => '[]', 'route' => '_table', 'rows_pad' => 'true', 'rows_params' => '[]', 'subtable' => 'null', 'subtable_options' => '[]', 'subtable_params' => '[]', 'subtable_params' => '[]', 'export' => '[]', 'export_route' => '_table_export', 'select_route' => '_table_select'), 'columns' => array('id' => array('id' => 'id', 'name' => 'id', 'type' => NULL, 'type_class' => get_class($columns['id']->getType()), 'passed_options' => array('name' => 'id', 'params' => '[0 => id]', 'allow_sort' => 'false'), 'resolved_options' => array('name' => 'id', 'title' => '', 'params' => '[0 => id]', 'attrs' => '[]', 'data' => 'null', 'default' => 'null', 'format' => 'null', 'allow_sort' => 'false', 'allow_filter' => 'false', 'width' => 'null', 'anchor_route' => 'null', 'anchor_params' => '[]', 'anchor_args' => '[]', 'anchor_text' => '', 'anchor_title' => '')), 'name' => array('id' => 'name', 'name' => 'name', 'type' => NULL, 'type_class' => get_class($columns['name']->getType()), 'passed_options' => array('format' => '#%s!', 'title' => 'name', 'name' => 'name', 'params' => '[0 => name]', 'allow_sort' => '[0 => name, 1 => id]', 'allow_filter' => 'true'), 'resolved_options' => array('name' => 'name', 'title' => 'name', 'params' => '[0 => name]', 'attrs' => '[]', 'data' => 'null', 'default' => 'null', 'format' => '#%s!', 'allow_sort' => '[0 => name, 1 => id]', 'allow_filter' => 'true', 'width' => 'null', 'anchor_route' => 'null', 'anchor_params' => '[]', 'anchor_args' => '[]', 'anchor_text' => '', 'anchor_title' => '')))));
     $this->assertEquals($expected, $dataCollector->getTables());
 }
 public function onPreSetData(TablePreSetDataEvent $event)
 {
     $this->dataCollector->collectConfig($event->getTable(), $event->getData(), $event->getOptions());
 }