83 $this->componentConfigProvider = $this->getMockBuilder(
84 \
Magento\Framework\View\Element\UiComponent\Config\Provider\Component\Definition::class
85 )->disableOriginalConstructor()->getMock();
86 $this->domMerger = $this->getMockBuilder(
87 \
Magento\Framework\View\Element\UiComponent\Config\DomMergerInterface::class
88 )->getMockForAbstractClass();
89 $this->aggregatedFileCollector = $this->getMockBuilder(
90 \
Magento\Framework\View\Element\UiComponent\Config\FileCollector\AggregatedFileCollector::class
91 )->disableOriginalConstructor()->getMock();
92 $this->aggregatedFileCollectorFactory = $this->getMockBuilder(
93 \
Magento\Framework\View\Element\UiComponent\Config\FileCollector\AggregatedFileCollectorFactory::class
94 )->disableOriginalConstructor()->getMock();
95 $this->arrayObjectFactory = $this->getMockBuilder(
96 \
Magento\Framework\View\Element\UiComponent\ArrayObjectFactory::class
97 )->disableOriginalConstructor()->getMock();
98 $this->arrayObjectFactory->expects($this->at(0))
100 ->willReturn(
new \ArrayObject([]));
101 $this->uiReader = $this->getMockBuilder(
102 \
Magento\Framework\View\Element\UiComponent\Config\UiReaderInterface::class
103 )->getMockForAbstractClass();
104 $this->readerFactory = $this->getMockBuilder(
105 \
Magento\Framework\View\Element\UiComponent\Config\ReaderFactory::class
106 )->disableOriginalConstructor()->getMock();
107 $this->cacheConfig = $this->getMockBuilder(\
Magento\Framework\Config\CacheInterface::class)
108 ->getMockForAbstractClass();
109 $this->argumentInterpreter = $this->getMockBuilder(\
Magento\Framework\Data\Argument\InterpreterInterface::class)
110 ->getMockForAbstractClass();
111 $this->serializer = $this->getMockBuilder(
112 \
Magento\Framework\Serialize\SerializerInterface::class
113 )->getMockForAbstractClass();
114 $this->serializer->expects($this->any())
115 ->method(
'serialize')
116 ->willReturnCallback(
118 return json_encode(
$value);
121 $this->serializer->expects($this->any())
122 ->method(
'unserialize')
123 ->willReturnCallback(
125 return json_decode(
$value,
true);
130 $this->componentConfigProvider,
132 $this->readerFactory,
133 $this->arrayObjectFactory,
134 $this->aggregatedFileCollectorFactory,
136 $this->argumentInterpreter,
143 $this->readerFactory->expects($this->once())
145 ->with([
'fileCollector' => $this->aggregatedFileCollector,
'domMerger' => $this->domMerger])
146 ->willReturn($this->uiReader);
147 $this->aggregatedFileCollectorFactory->expects($this->once())
149 ->willReturn($this->aggregatedFileCollector);
150 $this->assertEquals($this->uiReader, $this->manager->getReader(
'some_name'));
155 $this->expectException(\
Magento\Framework\Exception\LocalizedException::class);
156 $this->expectExceptionMessage(
157 (
string)
__(
'The "" UI component element name is invalid. Verify the name and try again.')
159 $this->manager->prepareData(
null);
165 public function testPrepareGetData($componentName, $componentData, $isCached, $readerData, $expectedResult)
167 $this->readerFactory->expects($this->any())
169 ->with([
'fileCollector' => $this->aggregatedFileCollector,
'domMerger' => $this->domMerger])
170 ->willReturn($this->uiReader);
171 $this->aggregatedFileCollectorFactory->expects($this->any())
173 ->willReturn($this->aggregatedFileCollector);
174 $this->argumentInterpreter->expects($this->any())
176 ->willReturnCallback(
function ($argument) {
177 return [
'argument' => $argument[
'value']];
179 $this->arrayObjectFactory->expects($this->any())
181 ->willReturn($componentData);
182 $this->cacheConfig->expects($this->any())
185 ->willReturn($isCached);
187 $this->uiReader->expects($this->any())
189 ->willReturn($readerData);
192 $this->manager->prepareData($componentName)->getData($componentName)
201 $cachedData = new \ArrayObject(
202 [
'test_component1' =>
208 [
'custom_name1' => [
'value' =>
'custom_value1']],
220 json_encode($cachedData->getArrayCopy()),
223 'test_component1' => [
228 [
'custom_name1' => [
'argument' =>
'custom_value1']],
238 [
'test_component2' =>
242 'test_component21' => [
244 [
'argument_name21' => [
'value' =>
'value21']],
252 [
'componentGroup' => [0 => [
255 'test_component21' => [0 => [
262 'test_component2' => [
266 'attribute_name21' => [
268 [
'argument_name21' => [
'argument' =>
'value21']],
284 $this->componentConfigProvider->expects($this->any())
285 ->method(
'getComponentData')
287 if ($needEvaluate ===
true) {
288 $this->argumentInterpreter->expects($this->once())
290 ->willReturnCallback(
function ($argument) {
291 return [
'argument' => $argument[
'value']];
294 $this->argumentInterpreter->expects($this->never())->method(
'evaluate');
296 $this->assertEquals($componentData, $this->manager->createRawComponentData($componentName, $needEvaluate));
testPrepareGetData($componentName, $componentData, $isCached, $readerData, $expectedResult)
const DATA_ATTRIBUTES_KEY
const COMPONENT_ARGUMENTS_KEY
const COMPONENT_ATTRIBUTES_KEY
testCreateRawComponentData($componentName, $configData, $componentData, $needEvaluate)
getComponentDataProvider()
$aggregatedFileCollectorFactory
testPrepareDataWithoutName()