コード例 #1
0
ファイル: GridBuilderTest.php プロジェクト: blazarecki/lug
 public function testBuildWithFullOptions()
 {
     $this->columnBuilder->expects($this->once())->method('build')->with($this->identicalTo(array_merge(['name' => $columnName = 'column_name'], $columnDefinition = ['column' => 'definition'])))->will($this->returnValue($column = $this->createColumnMock()));
     $column->expects($this->once())->method('getName')->will($this->returnValue($columnName));
     $this->filterBuilder->expects($this->once())->method('build')->with($this->identicalTo(array_merge(['name' => $filterName = 'filter_name'], $filterDefinition = ['filter' => 'definition'])))->will($this->returnValue($filter = $this->createFilterMock()));
     $filter->expects($this->once())->method('getName')->will($this->returnValue($filterName));
     $this->sortBuilder->expects($this->once())->method('build')->with($this->identicalTo(array_merge(['name' => $sortName = 'sort_name'], $sortDefinition = ['sort' => 'definition'])))->will($this->returnValue($sort = $this->createSortMock()));
     $sort->expects($this->once())->method('getName')->will($this->returnValue($sortName));
     $this->actionBuilder->expects($this->at(0))->method('build')->with($this->identicalTo(array_merge(['name' => $globalActionName = 'global_action_name'], $globalActionDefinition = ['global_action' => 'definition'])))->will($this->returnValue($globalAction = $this->createActionMock()));
     $globalAction->expects($this->once())->method('getName')->will($this->returnValue($globalActionName));
     $this->actionBuilder->expects($this->at(1))->method('build')->with($this->identicalTo(array_merge(['name' => $columnActionName = 'column_action_name'], $columnActionDefinition = ['column_action' => 'definition'])))->will($this->returnValue($columnAction = $this->createActionMock()));
     $columnAction->expects($this->once())->method('getName')->will($this->returnValue($columnActionName));
     $this->batchBuilder->expects($this->once())->method('build')->with($this->identicalTo(array_merge(['name' => $batchName = 'batch_name'], $batchDefinition = ['batch' => 'definition'])))->will($this->returnValue($batch = $this->createBatchMock()));
     $batch->expects($this->once())->method('getName')->will($this->returnValue($batchName));
     $grid = $this->builder->build(['resource' => $resource = $this->createResourceMock(), 'columns' => [$columnName => $columnDefinition], 'filters' => [$filterName => $filterDefinition], 'sorts' => [$sortName => $sortDefinition], 'global_actions' => [$globalActionName => $globalActionDefinition], 'column_actions' => [$columnActionName => $columnActionDefinition], 'batches' => [$batchName => $batchDefinition], 'data' => $data = ['data'], 'options' => $options = ['foo' => 'bar']]);
     $this->assertSame($resource, $grid->getResource());
     $this->assertSame([$columnName => $column], $grid->getColumns());
     $this->assertSame([$filterName => $filter], $grid->getFilters());
     $this->assertSame([$sortName => $sort], $grid->getSorts());
     $this->assertSame([$globalActionName => $globalAction], $grid->getGlobalActions());
     $this->assertSame([$columnActionName => $columnAction], $grid->getColumnActions());
     $this->assertSame([$batchName => $batch], $grid->getBatches());
     $this->assertSame($data, $grid->getData());
     $this->assertSame($options, $grid->getOptions());
 }
コード例 #2
0
ファイル: GridBuilder.php プロジェクト: php-lug/lug
 /**
  * @param mixed[] $config
  * @param mixed[] $parentConfig
  *
  * @return BatchInterface
  */
 protected function buildBatch(array $config, array $parentConfig)
 {
     return $this->batchBuilder->build($this->prepareConfig($config, $parentConfig));
 }