public function testDatagridRenderBlockFromParent()
 {
     $datagrid = $this->createDatagrid('grid');
     $datagrid->setData([['title' => 'This is value 1']]);
     $view = $datagrid->createView();
     $parent = $this->prophesize('\\Twig_Template');
     $parent->getParent([])->willReturn(false)->shouldBeCalled();
     $parent->hasBlock('datagrid_grid')->willReturn(false)->shouldBeCalled();
     $parent->hasBlock('datagrid')->willReturn(true)->shouldBeCalled();
     $template = $this->prophesize('\\Twig_Template');
     $template->getParent([])->willReturn($parent);
     $template->hasBlock('datagrid_grid')->willReturn(false)->shouldBeCalled();
     $template->hasBlock('datagrid')->willReturn(false)->shouldBeCalled();
     // call the display block on this template (not the parent),
     // Twig will call the parent block itself.
     $template->displayBlock('datagrid', ['datagrid' => $view, 'vars' => [], 'global_var' => 'global_value'])->willReturn(true);
     $this->extension->setBaseTheme($template->reveal());
     $this->extension->datagrid($view);
 }
 /**
  * This test case is realistic in collection rows where each
  * row contains the same data.
  *
  * This is most common use-case, showing more rows
  * on the page is likely to hit memory limits (for the data set itself).
  * And more rows will give display problems.
  *
  * @group benchmark
  */
 public function testGenerateViewWith100RowsAnd10Columns()
 {
     $this->setMaxRunningTime(1);
     $datagrid = $this->factory->createDatagridBuilder('test');
     $datagrid->add('id', NumberType::class, ['data_provider' => function ($data) {
         return $data['id'];
     }]);
     $datagrid->add('name', TextType::class, ['data_provider' => function ($data) {
         return $data['name'];
     }]);
     $datagrid->add('email', TextType::class, ['data_provider' => function ($data) {
         return $data['email'];
     }]);
     $datagrid->add('regdate', DateTimeType::class, ['data_provider' => function ($data) {
         return $data['regdate'];
     }]);
     $datagrid->add('lastModified', DateTimeType::class, ['data_provider' => function ($data) {
         return $data['lastModified'];
     }]);
     $datagrid->add('status', TextType::class, ['label' => 'last_modified', 'data_provider' => function ($data) {
         return $data['lastModified'];
     }, 'value_format' => function ($value) {
         return $value === 1 ? 'active' : 'deactivated';
     }]);
     $datagrid->add('group', TextType::class);
     $datagrid->add('actions', CompoundColumnType::class, ['label' => 'Actions', 'columns' => ['modify' => $this->factory->createColumn('modify', ActionType::class, ['label' => 'Modify', 'data_provider' => function ($data) {
         return ['id' => $data['id']];
     }, 'uri_scheme' => 'entity/{id}/modify']), 'delete' => $this->factory->createColumn('delete', ActionType::class, ['label' => 'Delete', 'data_provider' => function ($data) {
         return ['id' => $data['id']];
     }, 'uri_scheme' => 'entity/{id}/delete'])]]);
     $data = [];
     for ($i = 0; $i < 100; ++$i) {
         $data[] = ['id' => $i, 'name' => 'Who', 'email' => '*****@*****.**', 'regdate' => new \DateTime(), 'lastModified' => new \DateTime(), 'status' => mt_rand(0, 1), 'group' => 'Default'];
     }
     $datagrid = $datagrid->getDatagrid();
     $datagrid->setData($data);
     $this->extension->datagrid($datagrid->createView());
     $this->assertTrue(true);
 }