protected function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->contextMock = $this->getMockBuilder(ContextInterface::class)->getMockForAbstractClass();
     $this->processorMock = $this->getMockBuilder(Processor::class)->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($this->processorMock);
 }
 /**
  * Set up
  */
 public function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->contextMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface', [], '', false, true, true, []);
     $processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor);
 }
Esempio n. 3
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();
 }
 /**
  * @return void
  */
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $processorMock = $this->getMock('Magento\\Framework\\View\\Element\\UiComponent\\Processor', [], [], '', false, false);
     $processorMock->expects($this->once())->method('register');
     $this->contextMock = $this->getMock('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface');
     $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processorMock);
 }
Esempio n. 5
0
 public function setup()
 {
     $this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
     $processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getProcessor')->willReturn($processor);
     $this->uiComponentFactory = $this->getMock('Magento\\Framework\\View\\Element\\UiComponentFactory', [], [], '', false);
     $this->component = new AccountLock($this->context, $this->uiComponentFactory);
 }
 /**
  * @param ContextInterface $context
  * @param FormFactory $formFactory
  * @param ConfigInterface $wysiwygConfig
  * @param array $components
  * @param array $data
  * @param array $config
  */
 public function __construct(ContextInterface $context, FormFactory $formFactory, ConfigInterface $wysiwygConfig, array $components = [], array $data = [], array $config = [])
 {
     $wysiwygConfigData = isset($config['wysiwygConfigData']) ? $config['wysiwygConfigData'] : [];
     $this->form = $formFactory->create();
     $this->editor = $this->form->addField($context->getNamespace() . '_' . $data['name'], 'Magento\\Framework\\Data\\Form\\Element\\Editor', ['force_load' => true, 'rows' => 20, 'name' => $data['name'], 'config' => $wysiwygConfig->getConfig($wysiwygConfigData), 'wysiwyg' => isset($config['wysiwyg']) ? $config['wysiwyg'] : null]);
     $data['config']['content'] = $this->editor->getElementHtml();
     parent::__construct($context, $components, $data);
 }
 /**
  * Constructor
  *
  * @param ContextInterface $context
  * @param UiComponentInterface[] $components
  * @param array $data
  */
 public function __construct(ContextInterface $context, array $components = [], array $data = [])
 {
     $this->context = $context;
     $this->components = $components;
     $this->initObservers($data);
     $this->context->getProcessor()->register($this);
     $this->_data = array_replace_recursive($this->_data, $data);
 }
Esempio n. 8
0
 /**
  * Set up
  *
  * @return void
  */
 protected function setUp()
 {
     $this->uiComponentFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponentFactory')->disableOriginalConstructor()->getMock();
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
     $processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getProcessor')->willReturn($processor);
     $this->multiline = new Multiline($this->contextMock, $this->uiComponentFactoryMock);
 }
Esempio n. 9
0
 public function setup()
 {
     $this->processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
     $this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
     $this->context->expects($this->once())->method('getProcessor')->willReturn($this->processor);
     $this->uiComponentFactory = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponentFactory')->disableOriginalConstructor()->getMock();
     $this->scopeConfig = $this->getMockBuilder('Magento\\Framework\\App\\Config\\ScopeConfigInterface')->getMockForAbstractClass();
     $this->confirmation = new Confirmation($this->context, $this->uiComponentFactory, $this->scopeConfig, [], []);
 }
Esempio n. 10
0
 protected function setUp()
 {
     $this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)->getMockForAbstractClass();
     $this->contextMock = $this->getMockBuilder(ContextInterface::class)->getMockForAbstractClass();
     $this->uiElementProcessorMock = $this->getMockBuilder(UiElementProcessor::class)->disableOriginalConstructor()->getMock();
     $this->contextMock->expects(static::any())->method('getProcessor')->willReturn($this->uiElementProcessorMock);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->nameColumn = $this->objectManagerHelper->getObject(NameColumn::class, ['urlBuilder' => $this->urlBuilderMock, 'context' => $this->contextMock]);
 }
 public function setup()
 {
     $this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
     $processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getProcessor')->willReturn($processor);
     $this->uiComponentFactory = $this->getMock('Magento\\Framework\\View\\Element\\UiComponentFactory', [], [], '', false);
     $this->urlBuilder = $this->getMockForAbstractClass('Magento\\Framework\\UrlInterface', [], '', false);
     $this->component = new EditAction($this->context, $this->uiComponentFactory, $this->urlBuilder, [], ['name' => 'name', 'config' => ['editUrlPath' => 'theme/design_config/edit']]);
 }
Esempio n. 12
0
 public function testPrepareDataSource()
 {
     $dataSource = ['data' => ['items' => [['entity_id' => 1]]]];
     $expectedDataSource = ['data' => ['items' => [['entity_id' => 1, 'name' => ['edit' => ['href' => 'http://magento.com/customer/index/edit', 'label' => new \Magento\Framework\Phrase('Edit'), 'hidden' => false]]]]]];
     $this->context->expects($this->once())->method('getFilterParam')->with('store_id')->willReturn(null);
     $this->urlBuilder->expects($this->once())->method('getUrl')->with('customer/*/edit', ['id' => 1, 'store' => null])->willReturn('http://magento.com/customer/index/edit');
     $dataSource = $this->component->prepareDataSource($dataSource);
     $this->assertEquals($expectedDataSource, $dataSource);
 }
Esempio n. 13
0
 /**
  * Run test for prepare method
  *
  * @param array $data
  * @param array $expectedData
  * @return void
  *
  * @dataProvider prepareSuccessDataProvider
  */
 public function testPrepareSuccess(array $data, array $expectedData)
 {
     $this->uiComponentFactoryMock->expects($this->once())->method('create')->with(self::NAME, $data['config']['formElement'], $this->arrayHasKey('context'))->willReturn($this->getWrappedComponentMock());
     $this->contextMock->expects($this->any())->method('getNamespace')->willReturn(self::COMPONENT_NAMESPACE);
     $this->field->setData($data);
     $this->field->prepare();
     $result = $this->field->getData();
     $this->assertEquals($expectedData, $result);
 }
Esempio n. 14
0
 /**
  * Run test prepare method
  *
  * @return void
  */
 public function testPrepare()
 {
     $buttons = ['button1' => 'button1', 'button2' => 'button2'];
     /** @var Listing $listing */
     $listing = $this->objectManager->getObject('Magento\\Ui\\Component\\Listing', ['context' => $this->contextMock, 'data' => ['js_config' => ['extends' => 'test_config_extends', 'testData' => 'testValue'], 'buttons' => $buttons]]);
     $this->contextMock->expects($this->at(0))->method('getNamespace')->willReturn(Listing::NAME);
     $this->contextMock->expects($this->once())->method('addComponentDefinition')->with($listing->getComponentName(), ['extends' => 'test_config_extends', 'testData' => 'testValue']);
     $this->contextMock->expects($this->once())->method('addButtons')->with($buttons, $listing);
     $listing->prepare();
 }
 public function setup()
 {
     $this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
     $processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getProcessor')->willReturn($processor);
     $this->uiComponentFactory = $this->getMock('Magento\\Framework\\View\\Element\\UiComponentFactory', [], [], '', false);
     $this->attributeRepository = $this->getMock('Magento\\Customer\\Ui\\Component\\Listing\\AttributeRepository', [], [], '', false);
     $this->attributeMetadata = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\Data\\AttributeMetadataInterface', [], '', false);
     $this->component = new AttributeColumn($this->context, $this->uiComponentFactory, $this->attributeRepository);
     $this->component->setData('name', 'gender');
 }
Esempio n. 16
0
 protected function setUp()
 {
     $this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->getMockForAbstractClass();
     $processor = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getProcessor')->willReturn($processor);
     $this->columnFactory = $this->getMock('Magento\\Customer\\Ui\\Component\\ColumnFactory', ['create'], [], '', false);
     $this->attributeRepository = $this->getMock('Magento\\Customer\\Ui\\Component\\Listing\\AttributeRepository', [], [], '', false);
     $this->attribute = $this->getMock('Magento\\Customer\\Model\\Attribute', [], [], '', false);
     $this->column = $this->getMockForAbstractClass('Magento\\Ui\\Component\\Listing\\Columns\\ColumnInterface', [], '', false);
     $this->inlineEditUpdater = $this->getMockBuilder('Magento\\Customer\\Ui\\Component\\Listing\\Column\\InlineEditUpdater')->disableOriginalConstructor()->getMock();
     $this->component = new Columns($this->context, $this->columnFactory, $this->attributeRepository, $this->inlineEditUpdater);
 }
Esempio n. 17
0
 protected function setUp()
 {
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->processorMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\Processor')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->uiComponentFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponentFactory')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->systemStoreMock = $this->getMockBuilder('Magento\\Store\\Model\\System\\Store')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->escaperMock = $this->getMockBuilder('Magento\\Framework\\Escaper')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->contextMock->expects($this->atLeastOnce())->method('getProcessor')->willReturn($this->processorMock);
     $this->processorMock->expects($this->atLeastOnce())->method('register');
     $this->model = $objectManager->getObject('Magento\\Store\\Ui\\Component\\Listing\\Column\\Store', ['context' => $this->contextMock, 'uiComponent' => $this->uiComponentFactoryMock, 'systemStore' => $this->systemStoreMock, 'escaper' => $this->escaperMock, 'components' => [], 'data' => ['name' => $this->name]]);
 }
Esempio n. 18
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)
 {
     $this->contextMock->expects($this->any())->method('getNamespace')->willReturn(Range::NAME);
     $this->contextMock->expects($this->any())->method('addComponentDefinition')->with(Range::NAME, ['extends' => Range::NAME]);
     $this->contextMock->expects($this->any())->method('getRequestParam')->with(UiContext::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);
     }
     $range = new Range($this->contextMock, $this->uiComponentFactory, [], ['name' => $name]);
     $range->prepare();
 }
Esempio n. 19
0
 /**
  * Run test prepare method
  *
  * @return void
  */
 public function testPrepare()
 {
     $resultData = ['js_config' => ['extends' => 'test_config_extends', 'testData' => 'testValue'], 'config' => ['options' => [['value' => 20, 'label' => 20], ['value' => 30, 'label' => 30], ['value' => 50, 'label' => 50], ['value' => 100, 'label' => 100], ['value' => 200, 'label' => 200], ['value' => 20, 'label' => 'options1'], ['value' => 40, 'label' => 'options2']], 'pageSize' => 20, 'current' => 2]];
     /** @var Paging $paging */
     $paging = $this->objectManager->getObject('Magento\\Ui\\Component\\Paging', ['context' => $this->contextMock, 'data' => ['js_config' => ['extends' => 'test_config_extends', 'testData' => 'testValue'], 'config' => ['options' => ['options1' => ['label' => 'options1', 'value' => '20'], 'options2' => ['label' => 'options2', 'value' => '40']], 'current' => 2, 'pageSize' => 20]]]);
     /** @var DataProviderInterface|\PHPUnit_Framework_MockObject_MockObject $dataProviderMock */
     $dataProviderMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface', [], '', false);
     $this->contextMock->expects($this->once())->method('getRequestParam')->with('paging')->willReturn(['pageSize' => 5, 'current' => 3]);
     $this->contextMock->expects($this->once())->method('getDataProvider')->willReturn($dataProviderMock);
     $dataProviderMock->expects($this->once())->method('setLimit')->with(3, 5);
     $this->contextMock->expects($this->once())->method('addComponentDefinition')->with($paging->getComponentName(), ['extends' => 'test_config_extends', 'testData' => 'testValue']);
     $paging->prepare();
     $this->assertEquals($paging->getData(), $resultData);
 }
Esempio n. 20
0
 protected function setUp()
 {
     $this->contextMock = $this->getMockBuilder(ContextInterface::class)->getMockForAbstractClass();
     $this->attributeRepositoryMock = $this->getMockBuilder(ProductAttributeRepositoryInterface::class)->getMockForAbstractClass();
     $this->searchCriteriaBuilderMock = $this->getMockBuilder(SearchCriteriaBuilder::class)->disableOriginalConstructor()->getMock();
     $this->uiElementProcessorMock = $this->getMockBuilder(UiElementProcessor::class)->disableOriginalConstructor()->getMock();
     $this->searchCriteriaMock = $this->getMockBuilder(SearchCriteria::class)->disableOriginalConstructor()->getMock();
     $this->searchResultsMock = $this->getMockBuilder(ProductAttributeSearchResultsInterface::class)->getMockForAbstractClass();
     $this->contextMock->expects(static::any())->method('getProcessor')->willReturn($this->uiElementProcessorMock);
     $this->searchCriteriaBuilderMock->expects(static::any())->method('addFilter')->willReturnSelf();
     $this->searchCriteriaBuilderMock->expects(static::any())->method('create')->willReturn($this->searchCriteriaMock);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->attributesColumn = $this->objectManagerHelper->getObject(AttributesColumn::class, ['context' => $this->contextMock, 'attributeRepository' => $this->attributeRepositoryMock, 'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock]);
 }
Esempio n. 21
0
 /**
  * Run test getDataSourceData method
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testGetDataSourceData()
 {
     $result = [['type' => 'test_component_name', 'name' => 'test_name', 'dataScope' => 'test_namespace', 'config' => ['data' => ['items' => ['data']], 'totalCount' => 20, 'testConfig' => 'testConfigValue', 'params' => ['namespace' => 'test_namespace']]]];
     /** @var DataSourceInterface|\PHPUnit_Framework_MockObject_MockObject $dataSourceMock */
     $dataSourceMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataSourceInterface', [], '', false);
     /** @var DataProviderInterface|\PHPUnit_Framework_MockObject_MockObject $dataProviderMock */
     $dataProviderMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface', [], '', false);
     /** @var Columns|\PHPUnit_Framework_MockObject_MockObject $columnsMock */
     $columnsMock = $this->getMock('Magento\\Ui\\Component\\Listing\\Columns', [], [], '', false);
     /** @var Column|\PHPUnit_Framework_MockObject_MockObject $columnMock */
     $columnMock = $this->getMock('Magento\\Ui\\Component\\Listing\\Columns\\Column', [], [], '', false);
     /** @var Listing $listing */
     $listing = $this->objectManager->getObject('Magento\\Ui\\Component\\Listing', ['context' => $this->contextMock, 'components' => [$dataSourceMock, $columnsMock], 'data' => ['js_config' => ['extends' => 'test_config_extends', 'testData' => 'testValue']]]);
     $columnsMock->expects($this->once())->method('getChildComponents')->willReturn([$columnMock]);
     $dataSourceMock->expects($this->any())->method('getDataProvider')->willReturn($dataProviderMock);
     $dataProviderMock->expects($this->once())->method('getData')->willReturn(['items' => ['data']]);
     $columnMock->expects($this->once())->method('prepareItems')->with(['data']);
     $dataSourceMock->expects($this->once())->method('getComponentName')->willReturn('test_component_name');
     $dataSourceMock->expects($this->once())->method('getName')->willReturn('test_name');
     $dataSourceMock->expects($this->once())->method('getContext')->willReturn($this->contextMock);
     $this->contextMock->expects($this->any())->method('getNamespace')->willReturn('test_namespace');
     $dataProviderMock->expects($this->once())->method('count')->willReturn(20);
     $dataSourceMock->expects($this->once())->method('getData')->with('config')->willReturn(['testConfig' => 'testConfigValue']);
     $this->assertEquals($listing->getDataSourceData(), $result);
 }
Esempio n. 22
0
 public function testPrepareDataSource()
 {
     $fieldName = 'special_field';
     $baseCurrencyCode = 'USD';
     $currencySymbol = '$';
     $dataSource = ['data' => ['items' => [['id' => '1', $fieldName => 3], ['id' => '2'], ['id' => '3', $fieldName => 4.55]]]];
     $result = ['data' => ['items' => [['id' => '1', $fieldName => '3.00$', 'price_number' => '3.00', 'price_currency' => $currencySymbol], ['id' => '2'], ['id' => '3', $fieldName => '4.55$', 'price_number' => '4.55', 'price_currency' => $currencySymbol]]]];
     $this->contextMock->expects($this->any())->method('getFilterParam')->with('store_id', Store::DEFAULT_STORE_ID)->willReturn(Store::DEFAULT_STORE_ID);
     $this->storeManagerMock->expects($this->any())->method('getStore')->with(Store::DEFAULT_STORE_ID)->willReturn($this->storeMock);
     $this->storeMock->expects($this->any())->method('getBaseCurrencyCode')->willReturn($baseCurrencyCode);
     $this->localeCurrencyMock->expects($this->any())->method('getCurrency')->with($baseCurrencyCode)->willReturn($this->currencyMock);
     $this->currencyMock->expects($this->any())->method('toCurrency')->willReturnMap([['3.000000', ['display' => false], '3.00'], ['4.550000', ['display' => false], '4.55'], ['3.000000', [], '3.00$'], ['4.550000', [], '4.55$']]);
     $this->storeMock->expects($this->any())->method('getBaseCurrency')->willReturn($this->currencyModelMock);
     $this->currencyModelMock->expects($this->any())->method('getCurrencySymbol')->willReturn($currencySymbol);
     $this->priceColumn->setData('name', $fieldName);
     $this->assertSame($result, $this->priceColumn->prepareDataSource($dataSource));
 }
Esempio n. 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 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();
 }
Esempio n. 24
0
 /**
  * Run test prepare method
  *
  * @return void
  */
 public function testPrepare()
 {
     /** @var Column|\PHPUnit_Framework_MockObject_MockObject $componentMock */
     $columnMock = $this->getMock('Magento\\Ui\\Component\\Listing\\Columns\\Column', [], [], '', false);
     /** @var DataProviderInterface|\PHPUnit_Framework_MockObject_MockObject $dataProviderMock */
     $dataProviderMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface', [], '', false);
     $data = ['name' => 'test_name', 'js_config' => ['extends' => 'test_config_extends'], 'config' => ['dataType' => 'test_type', 'sortable' => true]];
     $this->contextMock->expects($this->once())->method('getDataProvider')->willReturn($dataProviderMock);
     $this->contextMock->expects($this->once())->method('addComponentDefinition')->with('columns', ['extends' => 'test_config_extends']);
     $dataProviderMock->expects($this->once())->method('getFieldMetaInfo')->with('test_name', 'test_column_name')->willReturn(['test_meta' => 'test_meta_value']);
     $columnMock->expects($this->once())->method('getName')->willReturn('test_column_name');
     $columnMock->expects($this->once())->method('getData')->with('config')->willReturn(['test_config_data' => 'test_config_value']);
     $columnMock->expects($this->once())->method('setData')->with('config', ['test_config_data' => 'test_config_value', 'test_meta' => 'test_meta_value']);
     /** @var Columns $columns */
     $columns = $this->objectManager->getObject('Magento\\Ui\\Component\\Listing\\Columns', ['components' => [$columnMock], 'context' => $this->contextMock, 'data' => $data]);
     $columns->prepare();
 }
 /**
  * @param array $jsConfig
  * @param array $expectedResult
  * @return void
  * @dataProvider getJsConfigDataProvider
  */
 public function testGetJsConfig(array $jsConfig, array $expectedResult)
 {
     $namespace = 'my_namespace';
     /** @var \Magento\Framework\View\Element\UiComponentInterface|MockObject $uiComponentMock */
     $uiComponentMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponentInterface')->setMethods(['getData'])->getMockForAbstractClass();
     $uiComponentMock->expects($this->once())->method('getData')->with('js_config')->willReturnOnConsecutiveCalls($jsConfig);
     $uiComponentMock->expects($this->any())->method('getContext')->willReturn($this->contextMock);
     $this->contextMock->expects($this->any())->method('getNamespace')->willReturn($namespace);
     $this->assertEquals($expectedResult, $this->abstractComponent->getJsConfig($uiComponentMock));
 }
Esempio n. 26
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();
 }
Esempio n. 27
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();
 }
Esempio n. 28
0
 /**
  * Run test prepare method
  *
  * @return void
  */
 public function testPrepare()
 {
     $data = ['name' => 'test_name', 'js_config' => ['extends' => 'test_config_extends'], 'config' => ['dataType' => 'test_type', 'sortable' => true]];
     /** @var UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject $uiComponentFactoryMock */
     $uiComponentFactoryMock = $this->getMock('Magento\\Framework\\View\\Element\\UiComponentFactory', [], [], '', false);
     /** @var UiComponentInterface|\PHPUnit_Framework_MockObject_MockObject $wrappedComponentMock */
     $wrappedComponentMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponentInterface', [], '', false);
     /** @var DataProviderInterface|\PHPUnit_Framework_MockObject_MockObject $dataProviderMock */
     $dataProviderMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface', [], '', false);
     $this->contextMock->expects($this->atLeastOnce())->method('getNamespace')->willReturn('test_namespace');
     $this->contextMock->expects($this->atLeastOnce())->method('getDataProvider')->willReturn($dataProviderMock);
     $this->contextMock->expects($this->atLeastOnce())->method('getRequestParam')->with('sorting')->willReturn(['field' => 'test_name', 'direction' => 'asc']);
     $this->contextMock->expects($this->atLeastOnce())->method('addComponentDefinition')->with(Column::NAME . '.test_type', ['extends' => 'test_config_extends']);
     $dataProviderMock->expects($this->once())->method('addOrder')->with('test_name', 'ASC');
     $uiComponentFactoryMock->expects($this->once())->method('create')->with('test_name', 'test_type', array_merge(['context' => $this->contextMock], $data))->willReturn($wrappedComponentMock);
     $wrappedComponentMock->expects($this->once())->method('getContext')->willReturn($this->contextMock);
     $wrappedComponentMock->expects($this->once())->method('prepare');
     /** @var Column $column */
     $column = $this->objectManager->getObject('Magento\\Ui\\Component\\Listing\\Columns\\Column', ['context' => $this->contextMock, 'uiComponentFactory' => $uiComponentFactoryMock, 'data' => $data]);
     $column->prepare();
 }
Esempio n. 29
0
 public function testGetDataSourceDataWithoutId()
 {
     $requestFieldName = 'request_id';
     $dataSource = [];
     /** @var DataProviderInterface|\PHPUnit_Framework_MockObject_MockObject $dataProviderMock */
     $dataProviderMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface')->getMock();
     $dataProviderMock->expects($this->once())->method('getRequestFieldName')->willReturn($requestFieldName);
     $dataProviderMock->expects($this->never())->method('getPrimaryFieldName');
     $this->contextMock->expects($this->any())->method('getDataProvider')->willReturn($dataProviderMock);
     $this->contextMock->expects($this->once())->method('getRequestParam')->with($requestFieldName)->willReturn(null);
     $this->filterBuilderMock->expects($this->never())->method('setField');
     $this->filterBuilderMock->expects($this->never())->method('setValue');
     $this->filterBuilderMock->expects($this->never())->method('create');
     $dataProviderMock->expects($this->never())->method('addFilter');
     $dataProviderMock->expects($this->never())->method('getData');
     $this->assertEquals($dataSource, $this->model->getDataSourceData());
 }
Esempio n. 30
0
 public function testGetDataSourceDataWithoutId()
 {
     $requestFieldName = 'request_id';
     $primaryFieldName = 'primary_id';
     $fieldId = null;
     $row = ['key' => 'value'];
     $data = [$fieldId => $row];
     $dataSource = ['data' => $row];
     /** @var DataProviderInterface|\PHPUnit_Framework_MockObject_MockObject $dataProviderMock */
     $dataProviderMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface')->getMock();
     $dataProviderMock->expects($this->once())->method('getRequestFieldName')->willReturn($requestFieldName);
     $dataProviderMock->expects($this->once())->method('getPrimaryFieldName')->willReturn($primaryFieldName);
     $this->contextMock->expects($this->any())->method('getDataProvider')->willReturn($dataProviderMock);
     $this->contextMock->expects($this->once())->method('getRequestParam')->with($requestFieldName)->willReturn($fieldId);
     /** @var Filter|\PHPUnit_Framework_MockObject_MockObject $filterMock */
     $filterMock = $this->getMockBuilder('Magento\\Framework\\Api\\Filter')->disableOriginalConstructor()->getMock();
     $this->filterBuilderMock->expects($this->once())->method('setField')->with($primaryFieldName)->willReturnSelf();
     $this->filterBuilderMock->expects($this->once())->method('setValue')->with($fieldId)->willReturnSelf();
     $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock);
     $dataProviderMock->expects($this->once())->method('addFilter')->with($filterMock);
     $dataProviderMock->expects($this->once())->method('getData')->willReturn($data);
     $this->assertEquals($dataSource, $this->model->getDataSourceData());
 }