30 $this->objectManagerMock = $this->createMock(\
Magento\Framework\ObjectManagerInterface::class);
32 $this->objectManagerHelper =
new ObjectManagerHelper($this);
33 $this->conditionFactory = $this->objectManagerHelper->getObject(
34 \
Magento\Rule\Model\ConditionFactory::class,
36 'objectManager' => $this->objectManagerMock
43 $type = \Magento\Rule\Model\Condition\Combine::class;
44 $origin = $this->getMockBuilder(
$type)
45 ->disableOriginalConstructor()
48 $this->objectManagerMock
49 ->expects($this->once())
52 ->willReturn($origin);
54 $this->conditionFactory->create(
$type);
59 $type = \Magento\Rule\Model\Condition\Combine::class;
60 $origin = $this->getMockBuilder(
$type)
61 ->disableOriginalConstructor()
64 $this->objectManagerMock->expects($this->once())
67 ->willReturn($origin);
69 $cloned = $this->conditionFactory->create(
$type);
71 $this->assertNotSame($cloned, $origin);
77 $this->objectManagerMock
78 ->expects($this->never())
81 $this->expectException(\InvalidArgumentException::class);
82 $this->expectExceptionMessage(
'Class does not exist');
84 $this->conditionFactory->create(
$type);
89 $type = \Magento\Rule\Model\ConditionFactory::class;
91 $this->objectManagerMock
92 ->expects($this->never())
95 ->willReturn(
new \stdClass());
96 $this->expectException(\InvalidArgumentException::class);
97 $this->expectExceptionMessage(
'Class does not implement condition interface');
98 $this->conditionFactory->create(
$type);
testCreateExceptionType()
testExceptingClonedObject()
testCreateExceptionClass()
testExceptingToCallMethodCreateInObjectManager()