public function setUp() { $column = new Money(); $column->setName('money'); $column->initOptions(); $extension = new DefaultColumnOptionsExtension(); $extension->initOptions($column); $this->column = $column; }
public function setUp() { $column = new Number(); $column->setName('number'); $column->initOptions(); $extension = new DefaultColumnOptionsExtension(); $extension->initOptions($column); $this->column = $column; }
public function setUp() { $column = new DateTime(); $column->setName('datetime'); $column->initOptions(); $extension = new DefaultColumnOptionsExtension(); $extension->initOptions($column); $this->column = $column; }
public function testFilterValueWithRedirectUriFalse() { $this->router->expects($this->once())->method('generate')->with('foo', array(), false)->will($this->returnValue('/test/bar')); $this->column->setName('action'); $this->column->initOptions(); $extension = new DefaultColumnOptionsExtension(); $extension->initOptions($this->column); $this->column->setOption('actions', array('edit' => array('route_name' => 'foo', 'absolute' => false, 'redirect_uri' => false))); $this->assertSame(array('edit' => array('content' => 'edit', 'field_mapping_values' => array('foo' => 'bar'), 'url_attr' => array('href' => '/test/bar'))), $this->column->filterValue(array('foo' => 'bar'))); }
public function testBuildHeaderView() { $extension = new DefaultColumnOptionsExtension(); $column = $this->getMock('FSi\\Component\\DataGrid\\Column\\ColumnTypeInterface'); $view = $this->getMock('FSi\\Component\\DataGrid\\Column\\HeaderViewInterface'); $column->expects($this->at(0))->method('getOption')->with('label')->will($this->returnValue('foo')); $column->expects($this->at(1))->method('getOption')->with('display_order')->will($this->returnValue(100)); $view->expects($this->at(0))->method('setLabel')->with('foo'); $view->expects($this->at(1))->method('setAttribute')->with('display_order', 100); $extension->buildHeaderView($column, $view); }
public function testGetValue() { $column = new Entity(); $column->setName('foo'); $column->initOptions(); $extension = new DefaultColumnOptionsExtension(); $extension->initOptions($column); // Call resolve at OptionsResolver. $column->setOptions(array()); $object = new Fixture('object'); $dataGrid = $this->getMock('FSi\\Component\\DataGrid\\DataGridInterface'); $dataMapper = $dataMapper = $this->getMock('FSi\\Component\\DataGrid\\DataMapper\\DataMapperInterface'); $dataMapper->expects($this->once())->method('getData')->will($this->returnValue(array('foo' => 'bar'))); $dataGrid->expects($this->any())->method('getDataMapper')->will($this->returnValue($dataMapper)); $column->setDataGrid($dataGrid); $column->getValue($object); }
public function testGetValue() { if (!interface_exists('Doctrine\\Common\\Persistence\\ManagerRegistry') || !class_exists('Gedmo\\Tree\\TreeListener')) { $this->markTestSkipped('Doctrine\\Common\\Persistence\\ManagerRegistry is required for testGetValue in gedmo.tree column type'); } $dataGrid = $this->getMock('FSi\\Component\\DataGrid\\DataGridInterface'); $registry = $this->getManagerRegistry(); $dataMapper = $this->getMock('FSi\\Component\\DataGrid\\DataMapper\\DataMapperInterface'); $dataMapper->expects($this->any())->method('getData')->will($this->returnValue(new EntityTree("foo"))); $column = new Tree($registry); $column->setName('tree'); $column->initOptions(); $extension = new DefaultColumnOptionsExtension(); $extension->initOptions($column); $column->setDataMapper($dataMapper); $column->setOption('field_mapping', array('foo')); $column->setDataGrid($dataGrid); $object = new EntityTree("foo"); $column->getValue($object); $this->assertSame(array("id" => "foo", "root" => "root", "left" => "left", "right" => "right", "level" => "level", "children" => 2, "parent" => "bar"), $column->getViewAttributes()); }
public function testFilterValueWithRedirectUriFalse() { $self = $this; $this->container->expects($this->any())->method('get')->will($this->returnCallback(function ($serviceId) use($self) { switch ($serviceId) { case 'router': $router = $self->getMock('Symfony\\Component\\Routing\\RouterInterface'); $router->expects($self->once())->method('generate')->with('foo', array(), false)->will($self->returnValue('/test/bar')); return $router; break; case 'request': return new MyRequest(); break; } })); $column = new Action($this->container); $column->setName('action'); $column->initOptions(); $extension = new DefaultColumnOptionsExtension(); $extension->initOptions($column); $column->setOption('actions', array('edit' => array('route_name' => 'foo', 'absolute' => false, 'redirect_uri' => false))); $this->assertSame(array('edit' => array('url' => '/test/bar', 'content' => 'edit', 'field_mapping_values' => array('foo' => 'bar'), 'url_attr' => array('href' => '/test/bar'))), $column->filterValue(array('foo' => 'bar'))); }