Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $privateView = new GridView();
     $privateView->setName('gridView')->setGridName('testing-grid')->setOwner($this->getReference('simple_user'));
     $manager->persist($privateView);
     $publicView = new GridView();
     $publicView->setName('gridView')->setType(GridView::TYPE_PUBLIC)->setGridName('testing-grid')->setOwner($this->getReference('simple_user'));
     $manager->persist($publicView);
     $manager->flush();
 }
Exemplo n.º 2
0
 public function testCreateView()
 {
     $gridView = new GridView();
     $gridView->setName('name');
     $gridView->setFiltersData(['f' => 'fv']);
     $gridView->setSortersData(['s' => 'sv']);
     $expectedView = new View(null, ['f' => 'fv'], ['s' => 'sv'], GridView::TYPE_PRIVATE);
     $expectedView->setLabel('name');
     $this->assertEquals($expectedView, $gridView->createView());
 }
Exemplo n.º 3
0
 public function testCreateView()
 {
     $gridView = new GridView();
     $gridView->setName('name');
     $gridView->setFiltersData(['f' => 'fv']);
     $gridView->setSortersData(['s' => 'sv']);
     $gridView->setColumnsData(['name' => ['order' => 4]]);
     $expectedView = new View(null, ['f' => 'fv'], ['s' => 'sv'], GridView::TYPE_PRIVATE, ['name' => ['order' => 4]]);
     $expectedView->setLabel('name');
     static::assertEquals($expectedView, $gridView->createView());
 }
 public function testListenerShouldAddViewsIntoEvent()
 {
     $originalViews = ['choices' => [['label' => 'first', 'value' => 'first']], 'views' => [['name' => 'first', 'filters' => [], 'sorters' => [], 'type' => 'system']]];
     $event = new GridViewsLoadEvent('grid', $originalViews);
     $currentUser = new User();
     $this->securityFacade->expects($this->once())->method('getLoggedUser')->will($this->returnValue($currentUser));
     $view1 = new GridView();
     $view1->setId(1);
     $view1->setOwner($currentUser);
     $view1->setName('view1');
     $view2 = new GridView();
     $view2->setId(2);
     $view2->setName('view2');
     $view2->setOwner($currentUser);
     $gridViews = [$view1, $view2];
     $this->gridViewRepository->expects($this->once())->method('findGridViews')->will($this->returnValue($gridViews));
     $expectedViews = ['choices' => [['label' => 'first', 'value' => 'first'], ['label' => 'view1', 'value' => 1], ['label' => 'view2', 'value' => 2]], 'views' => [['name' => 'first', 'filters' => [], 'sorters' => [], 'type' => 'system'], ['label' => 'view1', 'name' => 1, 'filters' => [], 'sorters' => [], 'type' => GridView::TYPE_PRIVATE, 'deletable' => true, 'editable' => true, 'columns' => [], 'is_default' => false], ['label' => 'view2', 'name' => 2, 'filters' => [], 'sorters' => [], 'type' => GridView::TYPE_PRIVATE, 'deletable' => true, 'editable' => true, 'columns' => [], 'is_default' => false]]];
     $this->gridViewsLoadListener->onViewsLoad($event);
     $this->assertEquals($expectedViews, $event->getGridViews());
 }