ActionFactoryTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Rule\Test\Unit\Model;
  7. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
  8. class ActionFactoryTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var \Magento\Rule\Model\ActionFactory
  12. */
  13. protected $actionFactory;
  14. /**
  15. * @var ObjectManagerHelper
  16. */
  17. protected $objectManagerHelper;
  18. /**
  19. * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
  20. */
  21. protected $objectManagerMock;
  22. protected function setUp()
  23. {
  24. $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
  25. $this->objectManagerHelper = new ObjectManagerHelper($this);
  26. $this->actionFactory = $this->objectManagerHelper->getObject(
  27. \Magento\Rule\Model\ActionFactory::class,
  28. [
  29. 'objectManager' => $this->objectManagerMock
  30. ]
  31. );
  32. }
  33. public function testCreate()
  34. {
  35. $type = '1';
  36. $data = ['data2', 'data3'];
  37. $this->objectManagerMock->expects($this->once())->method('create')->with($type, $data);
  38. $this->actionFactory->create($type, $data);
  39. }
  40. }