41 $this->objectManagerMock = $this->getMockBuilder(\
Magento\Framework\ObjectManagerInterface::class)
42 ->getMockForAbstractClass();
43 $this->interpreterMock = $this->getMockBuilder(\
Magento\Framework\
Data\Argument\InterpreterInterface::class)
44 ->getMockForAbstractClass();
45 $this->contextFactoryMock = $this
46 ->getMockBuilder(\
Magento\Framework\View\Element\UiComponent\ContextFactory::class)
47 ->setMethods([
'create'])
48 ->disableOriginalConstructor()
50 $this->dataInterfaceFactoryMock = $this->getMockBuilder(\
Magento\Framework\
Config\DataInterfaceFactory::class)
51 ->setMethods([
'create'])
52 ->disableOriginalConstructor()
54 $this->safeReflectionClassMock = $this->getMockBuilder(\SafeReflectionClass::class)
55 ->disableOriginalConstructor()
57 $this->safeReflectionClassMock2 = $this->getMockBuilder(\SafeReflectionClass::class)
58 ->disableOriginalConstructor()
60 $this->dataMock = $this->createMock(\
Magento\Framework\
Config\DataInterface::class);
61 $this->objectManagerHelper =
new ObjectManagerHelper($this);
62 $this->model = $this->objectManagerHelper->getObject(
63 \
Magento\Framework\View\Element\UiComponentFactory::class,
65 'objectManager' => $this->objectManagerMock,
66 'argumentInterpreter' => $this->interpreterMock,
67 'contextFactory' => $this->contextFactoryMock,
68 'configFactory' => $this->dataInterfaceFactoryMock,
70 'componentChildFactories' => [],
71 'definitionData' => $this->dataMock
78 $identifier =
"product_listing";
79 $context = $this->createMock(\
Magento\Framework\View\Element\UiComponent\ContextInterface::class);
82 'class' =>
'Some\Class\Component',
86 'class' =>
'Some\Class\Component2' 91 $uiConfigMock = $this->createMock(\
Magento\Framework\
Config\DataInterface::class);
92 $this->dataInterfaceFactoryMock->expects($this->once())
94 ->willReturn($uiConfigMock);
95 $uiConfigMock->expects($this->once())
97 ->willReturn($bundleComponents);
99 $this->contextFactoryMock->expects($this->once())
101 ->willReturn($context);
102 $expectedArguments = [
104 'class' =>
'Some\Class\Component2' 107 'name' => $identifier
109 'context' => $context,
112 $this->objectManagerMock->expects($this->once())
114 ->with(
'Some\Class\Component2', $expectedArguments);
115 $this->model->create($identifier);
120 $identifier =
"custom_select";
122 $context = $this->createMock(\
Magento\Framework\View\Element\UiComponent\ContextInterface::class);
124 $defintionArguments = [
125 'componentType' =>
'select',
127 'class' =>
'\Some\Class',
131 $expectedArguments = [
133 'name' => $identifier
135 'context' => $context,
138 $this->dataMock->expects($this->once())
141 ->willReturn($defintionArguments);
142 $this->objectManagerMock->expects($this->once())
144 ->with(
'\Some\Class', $expectedArguments);
$safeReflectionClassMock2
testCreateRootComponent()
$dataInterfaceFactoryMock
if(!isset($_GET['name'])) $name