/**
  * Add button
  *
  * @param string $key
  * @param array $data
  * @param UiComponentInterface $view
  * @return void
  */
 public function add($key, array $data, UiComponentInterface $view)
 {
     $data['id'] = isset($data['id']) ? $data['id'] : $key;
     if ($this->toolbarBlock !== false) {
         $this->items[$key] = $this->itemFactory->create();
         $this->items[$key]->setData($data);
         $container = $this->createContainer($key, $view);
         $this->toolbarBlock->setChild($key, $container);
     }
 }
 /**
  * @magentoAppIsolation enabled
  */
 public function testGetChildBlock()
 {
     $childAlias = 'child_alias';
     $childName = 'child';
     $parentName = 'parent';
     // Without layout
     $this->assertFalse($this->_block->getChildBlock($childAlias));
     // With layout
     /** @var $layout \Magento\Framework\View\Layout */
     $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface');
     $child = $layout->createBlock('Magento\\Framework\\View\\Element\\Text', $childName);
     $layout->addBlock($this->_block, $parentName);
     $this->_block->setChild($childAlias, $child);
     $result = $this->_block->getChildBlock($childAlias);
     $this->assertInstanceOf('Magento\\Framework\\View\\Element\\Text', $result);
     $this->assertEquals($childName, $result->getNameInLayout());
     $this->assertEquals($child, $result);
 }