36 private $elementVisibilityMock;
45 'label' =>
'Element Label',
46 'someAttribute' =>
'Some attribute value',
47 'children' => [
'someGroup' => []],
52 $this->elementVisibilityMock = $this->getMockBuilder(ElementVisibilityInterface::class)
53 ->getMockForAbstractClass();
54 $this->_iteratorMock = $this->createMock(\
Magento\Config\Model\Config\
Structure\Element\Iterator::class);
55 $this->_storeManagerMock = $this->createMock(\
Magento\Store\Model\StoreManager::class);
56 $this->moduleManagerMock = $this->createMock(\
Magento\Framework\Module\Manager::class);
57 $this->_model = $this->getMockForAbstractClass(
59 [$this->_storeManagerMock, $this->moduleManagerMock, $this->_iteratorMock]
61 $objectManagerHelper =
new ObjectManagerHelper($this);
62 $objectManagerHelper->setBackwardCompatibleProperty(
65 $this->elementVisibilityMock,
72 unset($this->_iteratorMock);
73 unset($this->_storeManagerMock);
79 $this->_iteratorMock->expects(
87 $this->_model->setData($this->_testData,
'scope');
92 $this->_iteratorMock->expects($this->once())->method(
'setElements')->with([],
'scope');
93 $this->_model->setData([],
'scope');
98 $this->assertFalse($this->_model->hasChildren());
103 $this->_iteratorMock->expects($this->once())->method(
'current')->will($this->returnValue(
true));
104 $this->_iteratorMock->expects($this->once())->method(
'valid')->will($this->returnValue(
true));
105 $this->assertTrue($this->_model->hasChildren());
110 $this->_storeManagerMock->expects($this->once())->method(
'isSingleStoreMode')->will($this->returnValue(
true));
111 $this->_iteratorMock->expects($this->once())->method(
'current')->will($this->returnValue(
true));
112 $this->_iteratorMock->expects($this->once())->method(
'valid')->will($this->returnValue(
true));
113 $this->_model->setData([
'showInDefault' =>
'true'],
'default');
114 $this->assertTrue($this->_model->isVisible());
119 $this->_storeManagerMock->expects($this->once())->method(
'isSingleStoreMode')->will($this->returnValue(
true));
120 $this->_model->setData([
'showInDefault' =>
'true',
'frontend_model' =>
'Model_Name'],
'default');
121 $this->assertTrue($this->_model->isVisible());
126 $this->_storeManagerMock->expects($this->once())->method(
'isSingleStoreMode')->will($this->returnValue(
true));
127 $this->_model->setData([
'showInDefault' =>
'true'],
'default');
128 $this->assertFalse($this->_model->isVisible());
testSetDataInitializesChildIterator()
testHasChildrenReturnsFalseIfThereAreNoChildren()
testIsVisibleReturnsTrueIfThereAreVisibleChildren()
testHasChildrenReturnsTrueIfThereAreVisibleChildren()
testIsVisibleReturnsTrueIfElementHasFrontEndModel()
testIsVisibleReturnsFalseIfElementHasNoChildrenAndFrontendModel()
testSetDataInitializesChildIteratorWithEmptyArrayIfNoChildrenArePresent()