30 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
32 $this->resourceMock = $this->createPartialMock(
34 [
'loadPrimaryByRule',
'load',
'__wakeup',
'getIdFieldName']
36 $this->eventManager = $this->createPartialMock(\
Magento\Framework\Event\Manager::class, [
'dispatch']);
38 $context = $this->createPartialMock(\
Magento\Framework\Model\Context::class, [
'getEventDispatcher']);
40 $context->expects($this->once())->method(
'getEventDispatcher')->will($this->returnValue($this->eventManager));
43 \
Magento\SalesRule\Model\Coupon::class,
45 'resource' => $this->resourceMock,
54 public function testSetRule()
57 $ruleMock = $this->createPartialMock(\
Magento\SalesRule\Model\Rule::class, [
'getId',
'__wakeup']);
58 $ruleMock->expects($this->once())->method(
'getId');
60 $this->assertEquals($this->couponModel, $this->couponModel->setRule($ruleMock));
68 $this->resourceMock->expects($this->once())->method(
'loadPrimaryByRule');
70 $this->assertEquals($this->couponModel, $this->couponModel->loadPrimaryByRule(1));
78 $this->eventManager->expects($this->any())->method(
'dispatch');
79 $this->resourceMock->expects($this->once())->method(
'load');
81 $this->assertEquals($this->couponModel, $this->couponModel->loadByCode(
'code-value'));