示例#1
0
 /**
  * Returns component by namespace
  *
  * @return UiComponentInterface
  * @throws LocalizedException
  */
 public function getComponent()
 {
     $namespace = $this->request->getParam('namespace');
     if (!isset($this->components[$namespace])) {
         $this->components[$namespace] = $this->factory->create($namespace);
     }
     return $this->components[$namespace];
 }
示例#2
0
 public function testCreate()
 {
     $filterName = 'created_at';
     $config = ['data' => ['config' => ['dataScope' => $filterName, 'label' => __('Label'), 'options' => [['value' => 'Value', 'label' => 'Label']], 'caption' => __('Select...')]], 'context' => $this->context];
     $attributeData = ['attribute_code' => $filterName, 'frontend_input' => 'frontend-input', 'frontend_label' => 'Label', 'backend_type' => 'backend-type', 'options' => [['label' => 'Label', 'value' => 'Value']], 'is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true];
     $this->componentFactory->expects($this->once())->method('create')->with($filterName, 'filterInput', $config)->willReturn($this->filter);
     $this->assertSame($this->filter, $this->filterFactory->create($attributeData, $this->context));
 }
示例#3
0
 /**
  * Run test for prepare method
  *
  * @param array $data
  * @return void
  *
  * @dataProvider prepareDataProvider
  */
 public function testPrepare(array $data)
 {
     $this->uiComponentFactoryMock->expects($this->exactly($data['config']['size']))->method('create')->with($this->stringContains(self::NAME . '_'), Field::NAME, $this->logicalNot($this->isEmpty()))->willReturn($this->getComponentMock($data['config']['size']));
     $this->multiline->setData($data);
     $this->multiline->prepare();
     $result = $this->multiline->getData();
     $this->assertEquals($data, $result);
 }
 public function testCreate()
 {
     $columnName = 'created_at';
     $config = ['data' => ['js_config' => ['component' => 'Magento_Ui/js/grid/columns/column'], 'config' => ['label' => __('Label'), 'dataType' => 'text', 'align' => 'left', 'visible' => true, 'options' => [['label' => 'Label', 'value' => 'Value']], 'component' => 'Magento_Ui/js/grid/columns/column']], 'context' => $this->context];
     $attributeData = ['attribute_code' => 'billing_attribute_code', 'frontend_input' => 'text', 'frontend_label' => 'Label', 'backend_type' => 'backend-type', 'options' => [['label' => 'Label', 'value' => 'Value']], 'is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true, 'entity_type_code' => 'customer', 'validation_rules' => [], 'required' => false];
     $this->inlineEditUpdater->expects($this->once())->method('applyEditing')->with($this->column, 'text', []);
     $this->componentFactory->expects($this->once())->method('create')->with($columnName, 'column', $config)->willReturn($this->column);
     $this->assertSame($this->column, $this->columnFactory->create($attributeData, $columnName, $this->context));
 }
示例#5
0
 /**
  * @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
  * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
  * @param array $config
  * @return \Magento\Ui\Component\Listing\Columns\ColumnInterface
  */
 public function create($attribute, $context, array $config = [])
 {
     $columnName = $attribute->getAttributeCode();
     $config = array_merge(['label' => __($attribute->getDefaultFrontendLabel()), 'dataType' => $this->getDataType($attribute), 'sorting' => 'asc', 'align' => 'left', 'add_field' => true, 'visible' => $attribute->getIsVisibleInGrid()], $config);
     if ($attribute->usesSource()) {
         $config['options'] = $attribute->getSource()->getAllOptions();
     }
     $arguments = ['data' => ['js_config' => ['component' => $this->getJsComponent($config['dataType'])], 'config' => $config], 'context' => $context];
     return $this->componentFactory->create($columnName, 'column', $arguments);
 }
示例#6
0
 /**
  * @param array $attributeData
  * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
  * @return \Magento\Ui\Component\Listing\Columns\ColumnInterface
  */
 public function create(array $attributeData, $context)
 {
     $config = ['dataScope' => $attributeData[AttributeMetadata::ATTRIBUTE_CODE], 'label' => __($attributeData[AttributeMetadata::FRONTEND_LABEL])];
     if ($attributeData[AttributeMetadata::OPTIONS]) {
         $config['options'] = $attributeData[AttributeMetadata::OPTIONS];
         $config['caption'] = __('Select...');
     }
     $arguments = ['data' => ['config' => $config], 'context' => $context];
     return $this->componentFactory->create($attributeData[AttributeMetadata::ATTRIBUTE_CODE], $this->getFilterType($attributeData[AttributeMetadata::FRONTEND_INPUT]), $arguments);
 }
 /**
  * @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
  * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
  * @param array $config
  * @return \Magento\Ui\Component\Listing\Columns\ColumnInterface
  */
 public function create($attribute, $context, $config = [])
 {
     $columnName = $attribute->getAttributeCode();
     $config = array_merge(['dataScope' => $columnName, 'label' => __($attribute->getDefaultFrontendLabel())], $config);
     if ($attribute->usesSource() && $attribute->getSourceModel()) {
         $config['options'] = $attribute->getSource()->getAllOptions();
         $config['caption'] = __('Select...');
     }
     $arguments = ['data' => ['config' => $config], 'context' => $context];
     return $this->componentFactory->create($columnName, $this->getFilterType($attribute), $arguments);
 }
 /**
  * @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
  * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
  * @param array $config
  * @return \Magento\Ui\Component\Listing\Columns\ColumnInterface
  */
 public function create($attribute, $context, array $config = [])
 {
     $columnName = $attribute->getAttributeCode();
     $config = array_merge(['label' => __($attribute->getDefaultFrontendLabel()), 'dataType' => $this->getDataType($attribute), 'add_field' => true, 'visible' => $attribute->getIsVisibleInGrid(), 'filter' => $attribute->getIsFilterableInGrid() ? $this->getFilterType($attribute->getFrontendInput()) : null], $config);
     if ($attribute->usesSource()) {
         $config['options'] = $attribute->getSource()->getAllOptions();
     }
     $config['component'] = $this->getJsComponent($config['dataType']);
     $arguments = ['data' => ['config' => $config], 'context' => $context];
     return $this->componentFactory->create($columnName, 'column', $arguments);
 }
 /**
  * @param array $attributeData
  * @param string $columnName
  * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
  * @param array $config
  * @return \Magento\Ui\Component\Listing\Columns\ColumnInterface
  */
 public function create(array $attributeData, $columnName, $context, array $config = [])
 {
     $config = array_merge(['label' => __($attributeData[AttributeMetadata::FRONTEND_LABEL]), 'dataType' => $this->getDataType($attributeData[AttributeMetadata::FRONTEND_INPUT]), 'align' => 'left', 'visible' => (bool) $attributeData[AttributeMetadata::IS_VISIBLE_IN_GRID]], $config);
     if (count($attributeData[AttributeMetadata::OPTIONS]) && !isset($config[AttributeMetadata::OPTIONS])) {
         $config[AttributeMetadata::OPTIONS] = $attributeData[AttributeMetadata::OPTIONS];
     }
     if ($attributeData[AttributeMetadata::OPTIONS]) {
         $config['options'] = $attributeData[AttributeMetadata::OPTIONS];
     }
     $arguments = ['data' => ['js_config' => ['component' => $this->getJsComponent($config['dataType'])], 'config' => $config], 'context' => $context];
     $column = $this->componentFactory->create($columnName, 'column', $arguments);
     $this->inlineEditUpdater->applyEditing($column, $attributeData[AttributeMetadata::FRONTEND_INPUT], $attributeData[AttributeMetadata::VALIDATION_RULES], $attributeData[AttributeMetadata::REQUIRED]);
     return $column;
 }
示例#10
0
 /**
  * Prepare component configuration
  *
  * @return void
  */
 public function prepare()
 {
     parent::prepare();
     $dataType = $this->getData('config/dataType');
     $wrappedComponentConfig = [];
     if ($dataType) {
         $this->wrappedComponent = $this->uiComponentFactory->create($this->getName(), $dataType, array_merge(['context' => $this->getContext()], (array) $this->getData()));
         $this->wrappedComponent->prepare();
         $wrappedComponentConfig = $this->getConfiguration($this->wrappedComponent);
     }
     $this->applySorting();
     $jsConfig = array_replace_recursive($wrappedComponentConfig, $this->getConfiguration($this));
     $this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
 }
示例#11
0
 /**
  * Prepare component configuration
  *
  * @return void
  */
 public function prepare()
 {
     $dataType = $this->getData('config/dataType');
     if ($dataType) {
         $this->wrappedComponent = $this->uiComponentFactory->create($this->getName(), $dataType, array_merge(['context' => $this->getContext()], (array) $this->getData()));
         $this->wrappedComponent->prepare();
         $wrappedComponentConfig = $this->getJsConfig($this->wrappedComponent);
         // Merge JS configuration with wrapped component configuration
         $jsConfig = array_replace_recursive($wrappedComponentConfig, $this->getJsConfig($this));
         $this->setData('js_config', $jsConfig);
         $this->setData('config', array_replace_recursive((array) $this->wrappedComponent->getData('config'), (array) $this->getData('config')));
     }
     $this->applySorting();
     parent::prepare();
 }
示例#12
0
文件: Field.php 项目: opexsw/magento2
 /**
  * Prepare component configuration
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function prepare()
 {
     parent::prepare();
     $formElement = $this->getData('config/formElement');
     if (null === $formElement) {
         throw new LocalizedException(__('The configuration parameter "formElement" is a required for "' . $this->getName() . '" field.'));
     }
     // Create of wrapped component
     $this->wrappedComponent = $this->uiComponentFactory->create($this->getName(), $formElement, array_merge(['context' => $this->getContext()], (array) $this->getData()));
     $this->wrappedComponent->prepare();
     // To prepare the component configuration
     $wrappedComponentConfig = $this->getConfiguration($this->wrappedComponent);
     $jsConfig = array_replace_recursive($wrappedComponentConfig, $this->getConfiguration($this, $this->wrappedComponent->getComponentName()));
     $this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
 }
示例#13
0
 /**
  * Create child of form
  *
  * @param UiComponentInterface $childComponent
  * @param string $name
  * @return UiComponentInterface
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function createChildFormComponent(UiComponentInterface $childComponent, $name)
 {
     $panelComponent = $this->uiComponentFactory->create($name, $this->getConfig(self::CONFIG_PANEL_COMPONENT), ['context' => $this->component->getContext(), 'components' => [$childComponent->getName() => $childComponent]]);
     $panelComponent->prepare();
     $this->component->addComponent($name, $panelComponent);
     return $panelComponent;
 }
示例#14
0
 /**
  * Run test prepare method
  *
  * @param array $data
  * @param array $filterData
  * @param array|null $expectedCondition
  * @dataProvider getPrepareDataProvider
  * @return void
  */
 public function testPrepare($data, $filterData, $expectedCondition)
 {
     $name = $data['name'];
     /** @var UiComponentInterface $uiComponent */
     $uiComponent = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponentInterface', [], '', false);
     $uiComponent->expects($this->any())->method('getContext')->willReturn($this->contextMock);
     $this->contextMock->expects($this->any())->method('getNamespace')->willReturn(Select::NAME);
     $this->contextMock->expects($this->any())->method('addComponentDefinition')->with(Select::NAME, ['extends' => Select::NAME]);
     $this->contextMock->expects($this->any())->method('getFiltersParams')->willReturn($filterData);
     /** @var DataProviderInterface $dataProvider */
     $dataProvider = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface', ['addFilter'], '', false);
     $this->contextMock->expects($this->any())->method('getDataProvider')->willReturn($dataProvider);
     if ($expectedCondition !== null) {
         $filterMock = $this->getMock('Magento\\Framework\\Api\\Filter');
         $this->filterBuilderMock->expects($this->any())->method('setConditionType')->with($expectedCondition)->willReturnSelf();
         $this->filterBuilderMock->expects($this->any())->method('setField')->with($name)->willReturnSelf();
         $this->filterBuilderMock->expects($this->any())->method('setValue')->willReturnSelf();
         $this->filterBuilderMock->expects($this->any())->method('create')->willReturn($filterMock);
         $dataProvider->expects($this->any())->method('addFilter')->with($filterMock);
     }
     /** @var \Magento\Framework\Data\OptionSourceInterface $selectOptions */
     $selectOptions = $this->getMockForAbstractClass('Magento\\Framework\\Data\\OptionSourceInterface', [], '', false);
     $this->uiComponentFactory->expects($this->any())->method('create')->with($name, Select::COMPONENT, ['context' => $this->contextMock, 'options' => $selectOptions])->willReturn($uiComponent);
     $date = new Select($this->contextMock, $this->uiComponentFactory, $this->filterBuilderMock, $this->filterModifierMock, $selectOptions, [], $data);
     $date->prepare();
 }
示例#15
0
 /**
  * Prepare component configuration
  *
  * @return void
  */
 public function prepare()
 {
     $size = abs((int) $this->getData('config/size'));
     $validation = [$this->getData('config/validation')];
     while ($size--) {
         $identifier = $this->getName() . '_' . $size;
         $arguments = ['data' => ['name' => $identifier, 'config' => ['dataScope' => $size, 'dataType' => static::DATA_TYPE, 'formElement' => static::FORM_ELEMENT, 'sortOrder' => $size]]];
         if (!empty($validation[$size])) {
             $arguments['data']['config']['validation'] = $validation[$size];
         }
         $component = $this->uiComponentFactory->create($identifier, Field::NAME, $arguments);
         $component->prepare();
         $this->components[$identifier] = $component;
     }
     parent::prepare();
 }
示例#16
0
 /**
  * Create tab component
  *
  * @param UiComponentInterface $childComponent
  * @param string $name
  * @return UiComponentInterface
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function createTabComponent(UiComponentInterface $childComponent, $name)
 {
     $tabComponent = $this->uiComponentFactory->create($name, 'tab', ['context' => $this->component->getContext(), 'components' => [$childComponent->getName() => $childComponent]]);
     $tabComponent->prepare();
     $this->component->addComponent($name, $tabComponent);
     return $tabComponent;
 }
示例#17
0
 /**
  * Run test prepare method
  *
  * @param string $name
  * @param array $filterData
  * @param array|null $expectedCondition
  * @dataProvider getPrepareDataProvider
  * @return void
  */
 public function testPrepare($name, $filterData, $expectedCondition)
 {
     /** @var UiComponentInterface $uiComponent */
     $uiComponent = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponentInterface', [], '', false);
     $uiComponent->expects($this->any())->method('getContext')->willReturn($this->contextMock);
     $this->contextMock->expects($this->any())->method('getNamespace')->willReturn(Input::NAME);
     $this->contextMock->expects($this->any())->method('addComponentDefinition')->with(Input::NAME, ['extends' => Input::NAME]);
     $this->contextMock->expects($this->any())->method('getRequestParam')->with(UiContext::FILTER_VAR)->willReturn($filterData);
     $dataProvider = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface', [], '', false);
     $this->contextMock->expects($this->any())->method('getDataProvider')->willReturn($dataProvider);
     if ($expectedCondition !== null) {
         $dataProvider->expects($this->any())->method('addFilter')->with($expectedCondition, $name);
     }
     $this->uiComponentFactory->expects($this->any())->method('create')->with($name, Input::COMPONENT, ['context' => $this->contextMock])->willReturn($uiComponent);
     $date = new Input($this->contextMock, $this->uiComponentFactory, $this->filterBuilderMock, $this->filterModifierMock, [], ['name' => $name]);
     $date->prepare();
 }
示例#18
0
文件: Field.php 项目: kid17/magento2
 /**
  * Prepare component configuration
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function prepare()
 {
     $formElement = $this->getData('config/formElement');
     if (null === $formElement) {
         throw new LocalizedException(__('The configuration parameter "formElement" is a required for "' . $this->getName() . '" field.'));
     }
     // Create of wrapped component
     $this->wrappedComponent = $this->uiComponentFactory->create($this->getName(), $formElement, array_merge(['context' => $this->getContext()], (array) $this->getData()));
     $this->wrappedComponent->prepare();
     // Merge JS configuration with wrapped component configuration
     $wrappedComponentConfig = $this->getJsConfig($this->wrappedComponent);
     $jsConfig = array_replace_recursive($wrappedComponentConfig, $this->getJsConfig($this));
     $jsConfig['extends'] = $this->wrappedComponent->getComponentName();
     $this->setData('js_config', $jsConfig);
     $this->setData('config', array_replace_recursive((array) $this->wrappedComponent->getData('config'), (array) $this->getData('config')));
     parent::prepare();
 }
示例#19
0
 /**
  * @inheritDoc
  */
 public function update(UiComponentInterface $component)
 {
     if ($component instanceof ColumnInterface) {
         $filterType = $component->getData('config/filter');
         if (is_array($filterType)) {
             $filterType = $filterType['filterType'];
         }
         if (!$filterType) {
             return;
         }
         if (isset($this->filterMap[$filterType])) {
             $filterComponent = $this->uiComponentFactory->create($component->getName(), $this->filterMap[$filterType], ['context' => $this->getContext()]);
             $filterComponent->setData('config', $component->getConfiguration());
             $filterComponent->prepare();
             $this->addComponent($component->getName(), $filterComponent);
         }
     }
 }
 public function testProcess()
 {
     $this->prepareScheduledStructure();
     $this->readerContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Reader\\Context')->disableOriginalConstructor()->getMock();
     $this->readerContextMock->expects($this->any())->method('getScheduledStructure')->willReturn($this->scheduledStructureMock);
     $generatorContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Generator\\Context')->disableOriginalConstructor()->getMock();
     $structureMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Data\\Structure')->disableOriginalConstructor()->getMock();
     $structureMock->expects($this->once())->method('addToParentGroup')->with(UiComponent::TYPE, 'new_group')->willReturnSelf();
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->getMockForAbstractClass();
     $generatorContextMock->expects($this->any())->method('getStructure')->willReturn($structureMock);
     $generatorContextMock->expects($this->any())->method('getLayout')->willReturn($layoutMock);
     $this->uiComponentFactoryMock->expects($this->any())->method('setLayout')->with($layoutMock)->willReturnSelf();
     $blockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMock();
     $this->uiComponentFactoryMock->expects($this->any())->method('createUiComponent')->with('component_name', UiComponent::TYPE, ['attribute_1' => 'value_1', 'attribute_2' => 'value_2'])->willReturn($blockMock);
     $this->argumentInterpreterMock->expects($this->any())->method('evaluate')->will($this->returnValueMap([[['key_1' => 'value_1'], 'value_1'], [['key_2' => 'value_2'], 'value_2']]));
     $layoutMock->expects($this->any())->method('setBlock')->with(UiComponent::TYPE, $blockMock)->willReturnSelf();
     $this->uiComponent->process($this->readerContextMock, $generatorContextMock);
 }
示例#21
0
 /**
  * Run test prepare method
  *
  * @param string $name
  * @param array $filterData
  * @param array|null $expectedCondition
  * @dataProvider getPrepareDataProvider
  * @return void
  */
 public function testPrepare($name, $filterData, $expectedCondition)
 {
     /** @var UiComponentInterface $uiComponent */
     $uiComponent = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponentInterface', [], '', false);
     $uiComponent->expects($this->any())->method('getContext')->willReturn($this->contextMock);
     $this->contextMock->expects($this->any())->method('getNamespace')->willReturn(Select::NAME);
     $this->contextMock->expects($this->any())->method('addComponentDefinition')->with(Select::NAME, ['extends' => Select::NAME]);
     $this->contextMock->expects($this->any())->method('getRequestParam')->with(AbstractFilter::FILTER_VAR)->willReturn($filterData);
     if ($expectedCondition !== null) {
         /** @var DataProviderInterface $dataProvider */
         $dataProvider = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface', [], '', false);
         $dataProvider->expects($this->any())->method('addFilter')->with($expectedCondition, $name);
         $this->contextMock->expects($this->any())->method('getDataProvider')->willReturn($dataProvider);
     }
     /** @var \Magento\Framework\Data\OptionSourceInterface $selectOptions */
     $selectOptions = $this->getMockForAbstractClass('Magento\\Framework\\Data\\OptionSourceInterface', [], '', false);
     $this->uiComponentFactory->expects($this->any())->method('create')->with($name, Select::COMPONENT, ['context' => $this->contextMock, 'options' => $selectOptions])->willReturn($uiComponent);
     $date = new Select($this->contextMock, $this->uiComponentFactory, $selectOptions, [], ['name' => $name]);
     $date->prepare();
 }
示例#22
0
 /**
  * Create component object
  *
  * @param \Magento\Framework\View\Layout\Data\Structure $structure
  * @param string $elementName
  * @param string $data
  * @return \Magento\Framework\View\Element\UiComponentInterface
  */
 protected function generateComponent(Layout\Data\Structure $structure, $elementName, $data)
 {
     $attributes = $data['attributes'];
     if (!empty($attributes['group'])) {
         $structure->addToParentGroup($elementName, $attributes['group']);
     }
     $arguments = empty($data['arguments']) ? [] : $this->evaluateArguments($data['arguments']);
     $componentName = isset($attributes['component']) ? $attributes['component'] : '';
     $uiComponent = $this->uiComponentFactory->createUiComponent($componentName, $elementName, $arguments);
     return $uiComponent;
 }
示例#23
0
 /**
  * Run test prepare method
  *
  * @param string $name
  * @param array $filterData
  * @param array|null $expectedCondition
  * @dataProvider getPrepareDataProvider
  * @return void
  */
 public function testPrepare($name, $filterData, $expectedCondition)
 {
     /** @var FormDate $uiComponent */
     $uiComponent = $this->getMock('Magento\\Ui\\Component\\Form\\Element\\DataType\\Date', [], [], '', false);
     $uiComponent->expects($this->any())->method('getContext')->willReturn($this->contextMock);
     $this->contextMock->expects($this->any())->method('getNamespace')->willReturn(DateRange::NAME);
     $this->contextMock->expects($this->any())->method('addComponentDefinition')->with(DateRange::NAME, ['extends' => DateRange::NAME]);
     $this->contextMock->expects($this->any())->method('getRequestParam')->with(AbstractFilter::FILTER_VAR)->willReturn($filterData);
     if ($expectedCondition !== null) {
         /** @var DataProviderInterface $dataProvider */
         $dataProvider = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface', [], '', false);
         $dataProvider->expects($this->any())->method('addFilter')->with($name, $expectedCondition);
         $this->contextMock->expects($this->any())->method('getDataProvider')->willReturn($dataProvider);
         $uiComponent->expects($this->any())->method('getLocale')->willReturn($expectedCondition['locale']);
         $uiComponent->expects($this->any())->method('convertDate')->willReturnArgument(0);
     }
     $this->uiComponentFactory->expects($this->any())->method('create')->with($name, DateRange::COMPONENT, ['context' => $this->contextMock])->willReturn($uiComponent);
     $dateRange = new DateRange($this->contextMock, $this->uiComponentFactory, [], ['name' => $name]);
     $dateRange->prepare();
 }
示例#24
0
 /**
  * Create component object
  *
  * @param Structure $structure
  * @param string $elementName
  * @param string $data
  * @param LayoutInterface $layout
  * @return ContainerInterface
  */
 protected function generateComponent(Structure $structure, $elementName, $data, LayoutInterface $layout)
 {
     $attributes = $data['attributes'];
     if (!empty($attributes['group'])) {
         $structure->addToParentGroup($elementName, $attributes['group']);
     }
     $context = $this->contextFactory->create(['namespace' => $elementName, 'pageLayout' => $layout]);
     $component = $this->uiComponentFactory->create($elementName, null, ['context' => $context]);
     $this->prepareComponent($component);
     /** @var ContainerInterface $blockContainer */
     $blockContainer = $this->blockFactory->createBlock(static::CONTAINER, ['component' => $component]);
     return $blockContainer;
 }
示例#25
0
 /**
  * Run test prepare method (Exception)
  *
  * @return void
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage The configuration parameter "formElement" is a required for "test-name" field.
  */
 public function testPrepareException()
 {
     $this->uiComponentFactoryMock->expects($this->never())->method('create');
     $this->field->setData(['name' => self::NAME]);
     $this->field->prepare();
 }