public function testUpdate() { $this->testAdd(); $data = ['id' => 'id']; $this->items[$this->key]->expects($this->any())->method('setData')->with($data)->willReturnSelf(); $this->actionPool->update($this->key, $data); }
/** * Prepare component data * * @return void */ public function prepare() { $this->registerComponents(); $buttons = $this->getData('buttons'); if ($buttons) { foreach ($buttons as $buttonId => $buttonClass) { /** @var ButtonProviderInterface $button */ $button = $this->buttonProviderFactory->create($buttonClass); $buttonData = $button->getButtonData(); if (!$buttonData) { unset($buttons[$buttonId]); continue; } $buttons[$buttonId] = $buttonData; } uasort($buttons, [$this, 'sortButtons']); foreach ($buttons as $buttonId => $buttonData) { $this->actionPool->add($buttonId, $buttonData, $this); } } $layoutSettings = (array) $this->getData('layout'); $data = ['name' => $this->getData('name'), 'label' => $this->getData('label'), 'data_sources' => $this->getData('data_sources'), 'child_blocks' => $this->getLayout()->getChildBlocks($this->getNameInLayout()), 'configuration' => isset($layoutSettings['configuration']) ? $layoutSettings['configuration'] : []]; $layoutType = isset($layoutSettings['type']) ? $layoutSettings['type'] : \Magento\Ui\Component\Layout\Tabs::NAME; $layout = $this->factory->create($layoutType, $data); $layout->prepare(); $this->elements[] = $layout; }
public function testPrepare() { $this->prepareMeta(); $config = ['page_actions' => ['add' => ['name' => 'add', 'label' => __('Add New'), 'class' => 'primary', 'url' => 'http://some.url']]]; $this->urlBuilder->expects($this->at(0))->method('getUrl')->with('*/*/new')->willReturn('http://mage.local/category/new'); $dataCollection = $this->getMock('Magento\\Framework\\Data\\CollectionDataSourceInterface', [], [], '', false); $this->listingView->setData('configuration', $config); $this->listingView->setData('name', 'someName'); $this->listingView->setData('dataSource', $dataCollection); $this->actionPool->expects($this->once())->method('add')->with('add', $config['page_actions']['add'], $this->listingView); $this->configurationFactory->expects($this->once())->method('create')->willReturn($this->configuration); $this->assertNull($this->listingView->prepare()); }
/** * Prepare custom data * * @return void */ public function prepare() { $meta = $this->getMeta(); $defaultConfigData = $this->getDefaultConfiguration(); if ($this->hasData('configuration')) { $configData = $this->getData('configuration'); if (!empty($configData['page_actions'])) { foreach ($configData['page_actions'] as $key => $action) { $defaultConfigData['page_actions'][$key] = isset($configData['page_actions']) ? array_replace($defaultConfigData['page_actions'][$key], $configData['page_actions'][$key]) : $defaultConfigData['page_actions'][$key]; } } unset($configData['page_actions']); $defaultConfigData = array_merge($defaultConfigData, $configData); } foreach ($defaultConfigData['page_actions'] as $key => $action) { $this->actionPool->add($key, $action, $this); } unset($defaultConfigData['page_actions']); $this->prepareConfiguration($defaultConfigData, $this->getData('name')); $this->renderContext->getStorage()->addMeta($this->getData('name'), $meta); $this->renderContext->getStorage()->addDataCollection($this->getData('name'), $this->getData('dataSource')); }